Skip to main content
Glama

list-servers

Display all active MCP servers connected to the central hub server for easy monitoring and management of distributed resources.

Instructions

List all connected MCP servers

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the "list-servers" tool. It calls serverManager.listServers() to get the list of connected servers and returns it formatted as JSON text content in the MCP response format.
    async (args, extra) => { try { const servers = serverManager.listServers(); return { content: [ { type: "text", text: JSON.stringify({ servers }, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error listing servers: ${(error as Error).message}`, }, ], }; } }
  • src/index.ts:286-313 (registration)
    Registration of the "list-servers" tool using the MCP server's tool() method, with an empty schema (no parameters) and an inline handler function.
    server.tool( "list-servers", "List all connected MCP servers", {}, // No parameters needed async (args, extra) => { try { const servers = serverManager.listServers(); return { content: [ { type: "text", text: JSON.stringify({ servers }, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error listing servers: ${(error as Error).message}`, }, ], }; } } );
  • Helper method listServers() in McpServerManager class, which delegates to getConnectedServers() to retrieve the list of connected server names.
    listServers(): string[] { return this.getConnectedServers(); }
  • Supporting helper method getConnectedServers() that extracts the names of connected servers from the internal Map of clients.
    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/warpdev/mcp-hub-mcp'

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