Skip to main content
Glama

get-catalog-nodes

Retrieve catalog nodes from the Consul MCP Server to access and manage services, health checks, KV store, and other Consul functionalities efficiently.

Instructions

Get nodes from the catalog

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Handler function that lists all nodes from Consul catalog using consul.catalog.node.list(), formats them with formatCatalogNode, and returns formatted text.
    async () => { try { const data = await consul.catalog.node.list(); if (!data || data.length === 0) { return { content: [{ type: "text", text: "No nodes found in the catalog" }] }; } const nodesText = `Catalog nodes:\n\n${data.map(formatCatalogNode).join("\n")}`; return { content: [{ type: "text", text: nodesText }] }; } catch (error) { console.error("Error getting catalog nodes:", error); return { content: [{ type: "text", text: "Error getting catalog nodes" }] }; } }
  • Registers the 'get-catalog-nodes' tool on the McpServer with empty input schema and the handler function.
    server.tool( "get-catalog-nodes", "Get nodes from the catalog", {}, async () => { try { const data = await consul.catalog.node.list(); if (!data || data.length === 0) { return { content: [{ type: "text", text: "No nodes found in the catalog" }] }; } const nodesText = `Catalog nodes:\n\n${data.map(formatCatalogNode).join("\n")}`; return { content: [{ type: "text", text: nodesText }] }; } catch (error) { console.error("Error getting catalog nodes:", error); return { content: [{ type: "text", text: "Error getting catalog nodes" }] }; } } );
  • Helper function used by the handler to format each CatalogNode into a readable string.
    export function formatCatalogNode(node: CatalogNode): string { return [ `Node: ${node.Node || "Unknown"}`, `Address: ${node.Address || "Unknown"}`, `ServiceID: ${node.ServiceID || "Unknown"}`, `ServiceName: ${node.ServiceName || "Unknown"}`, `ServicePort: ${node.ServicePort || "Unknown"}`, `ServiceTags: ${node.ServiceTags?.join(", ") || "None"}`, "---", ].join("\n"); }

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/kocierik/consul-mcp-server'

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