/** * The MCP tools: schemas and implementations. Every tool takes plain JSON * arguments (never file names) and returns a `CallToolResult`. `runTool` is the * only entry point; it validates arguments and maps every failure to a safe * `isError` result, so callers never see stack traces or file-system paths. * @module mcp/tools */ export type ToolEnv = { limits: Partial; /** * Directory `!include` may read from, or null for none. */ includeDir: string | null; /** * Widest PNG a call may produce, in pixels. */ maxPngWidth: number; /** * Largest result payload in bytes. */ maxOutputBytes: number; }; export type ToolDefinition = { name: string; title: string; description: string; inputSchema: Record; outputSchema: Record; /** * Runs the PlantUML pipeline and belongs on the worker thread. */ heavy: boolean; run: (args: Record, env: ToolEnv) => Promise; }; export type CallToolResult = { content: Record[]; structuredContent?: Record; isError?: boolean; }; /** * Per-server settings the tools run with. Must stay structured-cloneable: it * is handed to the worker thread. * @typedef {object} ToolEnv * @property {Partial} limits * @property {string | null} includeDir Directory `!include` may read from, or null for none. * @property {number} maxPngWidth Widest PNG a call may produce, in pixels. * @property {number} maxOutputBytes Largest result payload in bytes. */ /** * @typedef {object} ToolDefinition * @property {string} name * @property {string} title * @property {string} description * @property {Record} inputSchema * @property {Record} outputSchema * @property {boolean} heavy Runs the PlantUML pipeline and belongs on the worker thread. * @property {(args: Record, env: ToolEnv) => Promise} run */ /** * @typedef {object} CallToolResult * @property {Record[]} content * @property {Record} [structuredContent] * @property {boolean} [isError] */ /** Widest PNG a call may request; wider rasters cost memory and exceed typical client limits. */ export declare const MAX_PNG_WIDTH = 4096; /** * @param {string} text * @returns {CallToolResult} */ export declare function errorResult(text: string): CallToolResult; /** Tool definitions in the order they are listed. */ export declare const TOOLS: readonly ToolDefinition[]; /** * @param {string} name * @returns {ToolDefinition | undefined} */ export declare function findTool(name: string): ToolDefinition | undefined; /** * The tool as it appears in `tools/list`. * @param {ToolDefinition} tool */ export declare function describeTool(tool: ToolDefinition): { name: string; title: string; description: string; inputSchema: Record; outputSchema: Record; annotations: Readonly<{ readOnlyHint: true; destructiveHint: false; idempotentHint: true; openWorldHint: false; }>; }; /** * Validate the arguments and run a tool. Never throws: every failure becomes * an `isError` result whose text is safe to show to a model. * @param {string} name * @param {unknown} args * @param {ToolEnv} env * @param {(message: string) => void} [log] Receives internal errors (for stderr). * @returns {Promise} */ export declare function runTool(name: string, args: unknown, env: ToolEnv, log?: (message: string) => void): Promise;