Skip to main content
Glama

get-services

Retrieve active services using the standardized Model Context Protocol interface for Consul, enabling efficient access to service data and health checks.

Instructions

Get running services

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function that executes the tool logic: lists running services from Consul agent using consul.agent.service.list(), formats them with formatService, and returns formatted text.
    async () => { const data = await consul.agent.service.list(); if (!data) { return { content: [{ type: "text", text: "Failed to retrieve services list data" }] }; } const dataText = `List of services:\n\n${Object.values(data).map(formatService).join("\n")}`; return { content: [{ type: "text", text: dataText }] }; }
  • Registration of the 'get-services' tool on the MCP server within the registerServiceList function.
    server.tool( "get-services", "Get running services", {}, async () => { const data = await consul.agent.service.list(); if (!data) { return { content: [{ type: "text", text: "Failed to retrieve services list data" }] }; } const dataText = `List of services:\n\n${Object.values(data).map(formatService).join("\n")}`; return { content: [{ type: "text", text: dataText }] }; } );
  • Helper function to format a single Consul service object into a multi-line string for display.
    export function formatService(feature: ServiceList): string { const props = feature; return [ `ID: ${props.ID || "Unknown"}`, `Port: ${props.Port || "Unknown"}`, `Service: ${props.Service || "Unknown"}`, `Tags: ${props.Tags || "Unknown"}`, "---", ].join("\n"); }
  • TypeScript interface defining the structure of a Consul service list entry, used by the formatService helper.
    export interface ServiceList { ID: string; Service: string; Tags: string[]; Port: number; }
  • src/server.ts:36-36 (registration)
    Top-level call to registerServiceList function, attaching the 'get-services' tool to the MCP server instance.
    registerServiceList(server, consul);

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