Skip to main content
Tools let a model call server-side code. Give each tool a focused description, validate its input, declare its behavioral annotations, and return an official MCP CallToolResult.

Register a tool

inputSchema accepts a Standard Schema implementation that can produce JSON Schema. Zod is one option; ArkType and Valibot are also supported.
Field descriptions become hints for clients and models. The schema validates input before the callback runs and supplies the callback’s inferred TypeScript type.

Return structured output

Declare outputSchema when clients need a typed structured result. Every successful result from a schema-backed tool must include matching structuredContent. An error result may instead set isError: true.
Prefer raw results:

Bind a View

Export the tool reference from the server entry so mcp-env.d.ts can expose its input and output types to View code. Place the React entry at views/<name>/view.tsx, set view.name to that directory name, and return its data in structuredContent.
A view-bound tool must declare outputSchema, and one View can bind to only one tool. The view reads the structured data while the model reads content.

Use request context

The second callback argument is scoped to the current request. It includes an abort signal, client-reported capability metadata, progress and logging methods, and the originating Hono request when HTTP context exists.
Client metadata is self-reported and must not be used for authorization. ctx.auth is available only when the server has an OAuth provider; use its verified provider user for access control.

Notify tool-list listeners

Publish a tool-list invalidation when the tools clients can discover have changed:
Clients with an active subscription listener can then request tools/list again. This notification does not register or replace tools; register tools while constructing the server, before it starts handling requests.

Test tools

Run mcp-use dev, open the built-in inspector, and test valid inputs, schema failures, error results, and structured output:
For view-bound tools, also verify that the View renders the returned structuredContent.