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.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.
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.