Skip to main content
Glama

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
NameRequiredDescriptionDefault
serverIdYesThe ID of the server

Implementation Reference

  • 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; } }
  • 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 }), }, ], }; }
  • 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, ], }; });
  • TypeScript interface defining the input arguments for the tool.
    interface GetServerToolsArgs { serverId: string; }

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/tesla0225/mcp-create'

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