Skip to main content
Glama

list_mcp_servers

Retrieve available MCP servers from the registry with pagination support for semantic analysis and tool discovery.

Instructions

List MCP servers from the MCP Registry with optional pagination. Returns raw server data for semantic analysis.

Input Schema

NameRequiredDescriptionDefault
cursorNoPagination cursor for retrieving next set of results
limitNoMaximum number of servers to return (1-100, default: 50)
registry_urlNoBase URL of the MCP Registry API (defaults to official registry - https://registry.modelcontextprotocol.io/v0/servers)

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "cursor": { "description": "Pagination cursor for retrieving next set of results", "type": "string" }, "limit": { "description": "Maximum number of servers to return (1-100, default: 50)", "maximum": 100, "minimum": 1, "type": "number" }, "registry_url": { "description": "Base URL of the MCP Registry API (defaults to official registry - https://registry.modelcontextprotocol.io/v0/servers)", "format": "uri", "type": "string" } }, "type": "object" }

Implementation Reference

  • The async handler function that implements the core logic of the 'list_mcp_servers' tool: constructs the registry API URL with pagination params, fetches the data, formats it with metadata and pagination info, and returns as text content.
    async ({ limit = 50, cursor, registry_url = DEFAULT_REGISTRY_URL }) => { const url = new URL(registry_url); if (cursor) { url.searchParams.set("cursor", cursor); } if (limit) { url.searchParams.set("limit", limit.toString()); } const response = await fetch(url.toString()); if (!response.ok) { throw new Error(`HTTP ${response.status}: ${response.statusText}`); } const data = await response.json(); // Return all servers without filtering - let semantic search handle matching const hasMoreData = data.metadata && data.metadata.next_cursor; const paginationHint = hasMoreData ? `Note: This is a paginated result. There are more MCP servers available. Use cursor "${data.metadata.next_cursor}" to retrieve the next page.\n\n` : ''; const totalCount = data.servers ? data.servers.length : 0; const countInfo = `Total MCP servers in this response: ${totalCount}\n\n`; return { content: [ { type: "text", text: `${countInfo}${paginationHint}${JSON.stringify({ servers: data.servers, metadata: data.metadata }, null, 2)}` } ] }; }
  • Zod input schema defining optional parameters: limit (1-100), cursor for pagination, and registry_url.
    { limit: z.number().min(1).max(100).optional().describe("Maximum number of servers to return (1-100, default: 50)"), cursor: z.string().optional().describe("Pagination cursor for retrieving next set of results"), registry_url: z.string().url().optional().describe("Base URL of the MCP Registry API (defaults to official registry - https://registry.modelcontextprotocol.io/v0/servers)") },
  • The registerListMcpServers function that calls server.tool() to register the 'list_mcp_servers' tool with its name, description, input schema, and handler.
    export function registerListMcpServers(server: McpServer) { server.tool( "list_mcp_servers", "List MCP servers from the MCP Registry with optional pagination. Returns raw server data for semantic analysis.", { limit: z.number().min(1).max(100).optional().describe("Maximum number of servers to return (1-100, default: 50)"), cursor: z.string().optional().describe("Pagination cursor for retrieving next set of results"), registry_url: z.string().url().optional().describe("Base URL of the MCP Registry API (defaults to official registry - https://registry.modelcontextprotocol.io/v0/servers)") }, async ({ limit = 50, cursor, registry_url = DEFAULT_REGISTRY_URL }) => { const url = new URL(registry_url); if (cursor) { url.searchParams.set("cursor", cursor); } if (limit) { url.searchParams.set("limit", limit.toString()); } const response = await fetch(url.toString()); if (!response.ok) { throw new Error(`HTTP ${response.status}: ${response.statusText}`); } const data = await response.json(); // Return all servers without filtering - let semantic search handle matching const hasMoreData = data.metadata && data.metadata.next_cursor; const paginationHint = hasMoreData ? `Note: This is a paginated result. There are more MCP servers available. Use cursor "${data.metadata.next_cursor}" to retrieve the next page.\n\n` : ''; const totalCount = data.servers ? data.servers.length : 0; const countInfo = `Total MCP servers in this response: ${totalCount}\n\n`; return { content: [ { type: "text", text: `${countInfo}${paginationHint}${JSON.stringify({ servers: data.servers, metadata: data.metadata }, null, 2)}` } ] }; } ); }
  • src/server.ts:10-10 (registration)
    Invocation of the registerListMcpServers function to add the tool to the main MCP server instance.
    registerListMcpServers(server);
  • Default URL for the MCP Registry API used in the tool handler.
    const DEFAULT_REGISTRY_URL = "https://registry.modelcontextprotocol.io/v0/servers";

Other 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/formulahendry/mcp-server-mcp-registry'

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