Skip to main content
Glama

call-tool

Execute a specific tool from a designated MCP server by providing the server name, tool name, and arguments. Use after identifying tools with find-tools.

Instructions

Call a specific tool from a specific server. TIP: Use find-tools first to discover the tool and get the correct serverName and toolName

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
serverNameYesName of the MCP server to call tool from
toolArgsYesArguments to pass to the tool
toolNameYesName of the tool to call

Implementation Reference

  • Handler function for the 'call-tool' tool. Destructures arguments, calls serverManager.callTool, and returns the result as JSON text content or an error.
    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:97-134 (registration)
    Registration of the 'call-tool' tool on the MCP server, including name, description, input schema derived from CallToolParamsSchema, and handler function.
    server.tool( "call-tool", "Call a specific tool from a specific server. TIP: Use find-tools first to discover the tool and get the correct serverName and toolName", { 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, }; } }, );
  • Zod schema defining the input parameters for the 'call-tool' tool: serverName (string), toolName (string), toolArgs (record of unknown).
    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"), }); export type CallToolParams = z.infer< typeof CallToolParamsSchema >;
  • Helper method in McpServerManager class that retrieves the client for the server and calls the target tool using the MCP client SDK.
    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, }); }

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/warpdev/mcp-hub-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server