Skip to main content
Glama

list_servers

Retrieve a list of MCP servers with customizable filters such as search terms, integration slugs, and pagination options for precise server data management.

Instructions

List MCP servers with optional filtering

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
count_per_pageNoNumber of results per page (maximum: 5000)
integrationsNoFilter by integration slugs
offsetNoNumber of results to skip for pagination
queryNoSearch term to filter servers

Implementation Reference

  • Handler logic for 'list_servers' tool: validates input arguments using isListServersArgs, performs an API GET request to '/servers' with provided parameters, and returns the formatted JSON response or an error.
    case "list_servers": { if (!isListServersArgs(request.params.arguments)) { throw new McpError( ErrorCode.InvalidParams, "Invalid arguments for list_servers" ); } try { const response = await this.axiosInstance.get<ListServersResponse>( "/servers", { params: { query: request.params.arguments.query, "integrations[]": request.params.arguments.integrations, count_per_page: request.params.arguments.count_per_page, offset: request.params.arguments.offset, }, } ); return { content: [ { type: "text", text: JSON.stringify(response.data, null, 2), }, ], }; } catch (error) { if (axios.isAxiosError(error)) { return { content: [ { type: "text", text: `API Error: ${ error.response?.data?.error?.message ?? error.message }`, }, ], isError: true, }; } throw error; } }
  • src/index.ts:97-125 (registration)
    Tool registration for 'list_servers' in the ListToolsRequestHandler response, defining name, description, and input schema.
    { name: "list_servers", description: "List MCP servers with optional filtering", inputSchema: { type: "object", properties: { query: { type: "string", description: "Search term to filter servers", }, integrations: { type: "array", items: { type: "string", }, description: "Filter by integration slugs", }, count_per_page: { type: "number", description: "Number of results per page (maximum: 5000)", maximum: 5000, }, offset: { type: "number", description: "Number of results to skip for pagination", }, }, }, },
  • TypeScript interface defining the input arguments for the list_servers tool.
    interface ListServersArgs { query?: string; integrations?: string[]; count_per_page?: number; offset?: number; }
  • TypeScript interface defining the expected API response structure for list_servers.
    interface ListServersResponse { servers: Array<{ name: string; url: string; external_url?: string; short_description?: string; source_code_url?: string; github_stars?: number; package_registry?: string; package_name?: string; package_download_count?: number; EXPERIMENTAL_ai_generated_description?: string; integrations: Array<{ name: string; slug: string; url: string; }>; }>; next?: string; total_count: number; }
  • Validator function to check if provided arguments match ListServersArgs interface, used in the handler.
    const isListServersArgs = (args: any): args is ListServersArgs => { if (typeof args !== "object" || args === null) return false; if ("query" in args && typeof args.query !== "string") return false; if ("integrations" in args && !Array.isArray(args.integrations)) return false; if ("count_per_page" in args && typeof args.count_per_page !== "number") return false; if ("offset" in args && typeof args.offset !== "number") return false; return true; };

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/orliesaurus/pulsemcp-server'

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