list-catalog-services
Retrieve a complete list of services registered in the Consul MCP Server catalog to monitor and manage service discovery efficiently.
Instructions
List all services in the catalog
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "list-catalog-services"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/consulTools.ts:208-226 (handler)Inline handler function for the 'list-catalog-services' tool. Fetches the list of services from the Consul catalog using `consul.catalog.service.list()`, formats them with their tags, and returns a formatted text response.
async () => { try { const data = await consul.catalog.service.list(); if (!data) { return { content: [{ type: "text", text: "Failed to retrieve catalog services list" }] }; } // Format the services data const servicesText = Object.entries(data) .map(([name, tags]) => `${name}: ${(tags as string[]).join(", ") || "No tags"}`) .join("\n"); return { content: [{ type: "text", text: `Catalog services:\n\n${servicesText}` }] }; } catch (error) { console.error("Error listing catalog services:", error); return { content: [{ type: "text", text: "Error listing catalog services" }] }; } } ); - src/tools/consulTools.ts:204-226 (registration)Direct registration of the 'list-catalog-services' tool using `server.tool()`, including description, empty input schema, and inline handler.
server.tool( "list-catalog-services", "List all services in the catalog", {}, async () => { try { const data = await consul.catalog.service.list(); if (!data) { return { content: [{ type: "text", text: "Failed to retrieve catalog services list" }] }; } // Format the services data const servicesText = Object.entries(data) .map(([name, tags]) => `${name}: ${(tags as string[]).join(", ") || "No tags"}`) .join("\n"); return { content: [{ type: "text", text: `Catalog services:\n\n${servicesText}` }] }; } catch (error) { console.error("Error listing catalog services:", error); return { content: [{ type: "text", text: "Error listing catalog services" }] }; } } ); - src/server.ts:39-39 (registration)High-level registration invocation of `registerCatalogServices` during server setup, which registers the 'list-catalog-services' tool among others.
registerCatalogServices(server, consul); - src/tools/consulTools.ts:207-207 (schema)Empty input schema (no parameters) for the 'list-catalog-services' tool.
{},