call-tool
Call and execute specific tools from managed MCP servers to bypass tool limits and reduce AI errors by focusing on essential functions.
Instructions
Call a specific tool from a specific server
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| serverName | Yes | Name of the MCP server to call tool from | |
| toolArgs | Yes | Arguments to pass to the tool | |
| toolName | Yes | Name of the tool to call |
Implementation Reference
- src/index.ts:91-121 (handler)Handler function that destructures arguments, calls serverManager.callTool, and returns the result as JSON or an error message.async (args, extra) => { try { const { serverName, toolName, toolArgs } = args; const result = await serverManager.callTool( serverName, toolName, toolArgs ); return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: `Tool call failed: ${ (error as Error).message }`, }, ], isError: true, }; } }
- src/index.ts:83-122 (registration)Registers the 'call-tool' tool on the MCP server with description, schema, and handler function.server.tool( "call-tool", "Call a specific tool from a specific server", { serverName: CallToolParamsSchema.shape.serverName, toolName: CallToolParamsSchema.shape.toolName, toolArgs: CallToolParamsSchema.shape.toolArgs, }, async (args, extra) => { try { const { serverName, toolName, toolArgs } = args; const result = await serverManager.callTool( serverName, toolName, toolArgs ); return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: `Tool call failed: ${ (error as Error).message }`, }, ], isError: true, }; } } );
- src/types.ts:27-35 (schema)Zod schema defining the input parameters for the call-tool: serverName (string), toolName (string), toolArgs (record).export const CallToolParamsSchema = z.object({ serverName: z .string() .describe("Name of the MCP server to call tool from"), toolName: z.string().describe("Name of the tool to call"), toolArgs: z .record(z.unknown()) .describe("Arguments to pass to the tool"), });
- src/server-manager.ts:205-215 (helper)Core helper method in McpServerManager that retrieves the client for the server and calls the specified tool via client.callTool.async callTool( serverName: string, toolName: string, args: Record<string, unknown> ): Promise<any> { const client = this.getClient(serverName); return await client.callTool({ name: toolName, arguments: args, }); }