get-server-tools
Retrieve a list of tools available on a specified MCP server using its server ID, enabling efficient management and customization of server resources.
Instructions
Get the tools available on a server
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| serverId | Yes | The ID of the server |
Implementation Reference
- index.ts:640-654 (handler)Core implementation that retrieves tools from the target server by calling listTools() on its MCP client.async getServerTools(serverId: string): Promise<any> { const server = this.servers.get(serverId); if (!server) { throw new Error(`Server ${serverId} not found`); } try { // Get tools from the server using the MCP client const tools = await server.client.listTools(); return tools; } catch (error) { console.error(`Error getting tools from server ${serverId}:`, error); throw error; } }
- index.ts:1131-1148 (handler)Tool dispatch handler in the main MCP server that validates input and delegates to ServerManager.getServerTools.case "get-server-tools": { const args = request.params .arguments as unknown as GetServerToolsArgs; if (!args.serverId) { throw new Error("Missing required argument: serverId"); } const tools = await serverManager.getServerTools(args.serverId); return { content: [ { type: "text", text: JSON.stringify({ tools }), }, ], }; }
- index.ts:932-945 (schema)Tool schema definition including name, description, and input schema requiring serverId.const getServerToolsTool: Tool = { name: "get-server-tools", description: "Get the tools available on a server", inputSchema: { type: "object", properties: { serverId: { type: "string", description: "The ID of the server", }, }, required: ["serverId"], }, };
- index.ts:1011-1022 (registration)Registers getServerToolsTool in the list of available tools returned by ListToolsRequest.server.setRequestHandler(ListToolsRequestSchema, async () => { console.error("Received ListToolsRequest"); return { tools: [ createServerFromTemplateTool, executeToolTool, getServerToolsTool, deleteServerTool, listServersTool, ], }; });
- index.ts:37-39 (schema)TypeScript interface defining the input arguments for the tool.interface GetServerToolsArgs { serverId: string; }