Overview
Tool files define your MCP tools — metadata, input validation, and request handlers. Each.ts file in src/tools/ is auto-discovered by the framework.
File Convention
.ts) becomes the tool name used by the MCP server. For example, src/tools/show-albums.ts registers a tool named show-albums.
Structure
Each tool file exports three things:Exports
tool (AppToolConfig)
The resource name, matching a directory in
src/resources/ (e.g., 'albums' for src/resources/albums/). Links this tool to its UI. Omit for tools that return data only (no UI).Human-readable title for the tool, shown in host UIs.
Description of what the tool does.
Tool metadata, including UI visibility.
"model"— The AI model can call this tool"app"— The app can call this tool (viauseCallServerTool)
schema (Zod record)
A record of Zod types defining the tool’s input parameters. Automatically converted to JSON Schema for the MCP server.
default (handler)
The default export is the tool handler function. It receives the validated input arguments and a ToolHandlerExtra object.
{ structuredContent: unknown }— Structured data passed to the resource viauseToolData(){ content: [{ type: 'text', text: string }] }— Text content- A plain string is normalized to
{ content: [{ type: 'text', text }] }
ToolHandlerExtra
Theextra parameter provides context from the MCP SDK:
Authentication info from the optional
src/server.ts auth function.Unique session identifier.
Abort signal for cancellation.
Tools Without UI
Tools that don’t need a UI can omit theresource field. These are registered as plain MCP tools (no resource or iframe).
A common pattern is pairing a UI tool (for review) with a backend-only tool (for execution). The review UI calls the backend tool via useCallServerTool after the user confirms:
review-purchase) returns structuredContent with a reviewTool field that tells the review resource which backend tool to call on confirm/cancel:
useCallServerTool with the arguments plus confirmed: true. The tool returns both content (human-readable text for the host model) and structuredContent (with status and message for the UI). The review resource reads structuredContent.status to determine success/error styling and displays structuredContent.message. The same review tool handles all review variants — purchases, code diffs, social posts — differentiated by the action field. See the template’s review resource for the full implementation.
Tools without a UI are hidden from the inspector’s simulation selector (there’s nothing to render). They are still registered in the dev MCP server, so they can be called by UI resources via useCallServerTool or by the host directly. In production, they work as standard MCP tools.
Multiple Tools Per Resource
Multiple tool files can reference the same resource by name:useToolData().
See Also
Server Entry
Optional auth and server configuration.
Simulation
Define test fixtures for your tools.