Skip to main content
A tool is a TypeScript function with a typed input. It reads from your product or takes an action, then returns data the caller can use. Tools are what make a conversation more than an answer box. They let someone check availability, move a booking or place an order against your real systems. Start with the task a person wants to complete, then expose the operations needed to do it. This guide adds get_hours to the starter. You will call it from the CLI, then make the same capability available in your MCP server and messaging agent.

Before you start

Create a project with the quickstart. The starter already imports tool and z in src/tools.ts and exports a tools array.

Add a tool

Add this definition inside the existing tools array in src/tools.ts. Keep the other starter tools so its existing commands and test scenarios continue to work.
src/tools.ts — add to the tools array
This example returns fixed data so you can try it immediately. In your product, run can call your API or database and return its result.

Call it

Restart the MCP server to load your change, then call the tool in another terminal:
First terminal
In the second terminal:
Second terminal
Check it worked: the CLI returns the hours from your function.
Result
No CLI configuration is needed for this new tool: unnamed commands use the tool’s name with underscores changed to dashes. The MCP server lists get_hours too. Restart npm start to use it in the playground, then ask “What time do you open?”

What each field does

signIn: "none" makes this public information available without a login. Use the default "required" for account data and configure authentication on the MCP server or messaging agent. Hints describe behavior to a host; your tool code still enforces permissions.

Add input

Describe the input a person would naturally ask for. Zod validates it before run is called. For a tool that looks up a product, the input could be:
Input schema
Return the data a later tool call needs, such as an id or status. Keep credentials and internal implementation details out of the returned result.

Format tool results

In Framework 0.8.0, a tool can provide Markdown for people while retaining structured data for models and scripts. Add these fields to a tool whose run returns the matching object:
Tool result
Expected result: { order_id: "BL-1040", ready_by: "10:30" } produces the text **Order BL-1040** is ready by 10:30. MCP returns it in content alongside the data in structuredContent; the CLI prints it by default. Messaging models still receive the data. format requires output and runs after output validation.

Use the caller’s account

run receives a second argument, context, supplied by the framework. Use its verified identity to find the account, rather than asking a model to provide an account id. The authentication guide shows how to connect your existing login and credentials provider.

Share a status during a slow operation

Hosts that support status text can show a short line while a tool runs and when it finishes:
Tool metadata
For messaging, Flow handles acknowledgement and background execution. deadlineMs limits how long a reply waits for one tool; it does not replace an API client’s own timeout.

Validate your change

Terminal
This checks tool descriptors, skill references and CLI configuration. Exercise the tool as well: a valid schema does not establish that your API call returns the right result.

Teach a workflow

Explain when and how an agent should use your tools.

Customize the CLI

Choose command names, arguments and output for your product.