Skip to main content
Glama

list-all-tools

Discover all available tools from connected servers. Start tasks efficiently by first identifying additional tools to use, ensuring optimal task execution.

Instructions

List all available tools from all connected servers. Before starting any task based on the user's request, always begin by using this tool to get a list of any additional tools that may be available for use.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function that implements the logic for the 'list-all-tools' tool. It fetches connected servers, lists tools from each via serverManager.listTools, handles errors per server, and returns a JSON-formatted response with all tools grouped by server name.
    async (args, extra) => { try { const servers = serverManager.getConnectedServers(); if (servers.length === 0) { return { content: [ { type: "text", text: "No connected servers.", }, ], }; } const allTools: Record<string, any> = {}; // Get tools list from each server for (const serverName of servers) { try { const toolsResponse = await serverManager.listTools(serverName); allTools[serverName] = toolsResponse; } catch (error) { allTools[serverName] = { error: `Failed to get tools list: ${ (error as Error).message }`, }; } } return { content: [ { type: "text", text: JSON.stringify(allTools, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: `Failed to get tools list from all servers: ${ (error as Error).message }`, }, ], isError: true, }; } }
  • src/index.ts:21-80 (registration)
    Registration of the 'list-all-tools' tool using server.tool(), including description, empty input schema, and inline handler function.
    // Tool to return tools list from all servers server.tool( "list-all-tools", "List all available tools from all connected servers. Before starting any task based on the user's request, always begin by using this tool to get a list of any additional tools that may be available for use.", {}, // Use empty object when there are no parameters async (args, extra) => { try { const servers = serverManager.getConnectedServers(); if (servers.length === 0) { return { content: [ { type: "text", text: "No connected servers.", }, ], }; } const allTools: Record<string, any> = {}; // Get tools list from each server for (const serverName of servers) { try { const toolsResponse = await serverManager.listTools(serverName); allTools[serverName] = toolsResponse; } catch (error) { allTools[serverName] = { error: `Failed to get tools list: ${ (error as Error).message }`, }; } } return { content: [ { type: "text", text: JSON.stringify(allTools, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: `Failed to get tools list from all servers: ${ (error as Error).message }`, }, ], isError: true, }; } } );
  • McpServerManager.listTools helper method, which delegates to the connected client's listTools to fetch tools from a specific server. Used in the list-all-tools handler.
    async listTools(serverName: string): Promise<any> { const client = this.getClient(serverName); return await client.listTools(); }
  • McpServerManager.getConnectedServers helper method, which returns the list of currently connected server names. Used in the list-all-tools handler.
    getConnectedServers(): string[] { return Array.from(this.clients.keys()); }

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/tpavelek/mcp-hub-mcp'

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