Skip to main content
Glama

get-health-checks

Retrieve health checks for specified services using the Consul MCP Server, enabling monitoring and management of service status through standardized queries.

Instructions

Get health checks for a service

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
serviceNoName of the service to get health checks for

Implementation Reference

  • The async handler function that retrieves health checks for the specified service using Consul's health.service API, processes the data, formats it using formatHealthCheck, and returns the formatted text.
    async ({ service }) => {
      try {
        const data = await consul.health.service({ service });
        if (!data || data.length === 0) {
          return { content: [{ type: "text", text: `No health checks found for service: ${service}` }] };
        }
        
        // Extract health checks from the response
        const checks = data.flatMap(entry => entry.Checks || []);
        if (checks.length === 0) {
          return { content: [{ type: "text", text: `No health checks found for service: ${service}` }] };
        }
        
        const checksText = `Health checks for service ${service}:\n\n${checks.map(formatHealthCheck).join("\n")}`;
        return { content: [{ type: "text", text: checksText }] };
      } catch (error) {
        console.error("Error getting health checks:", error);
        return { content: [{ type: "text", text: `Error getting health checks for service: ${service}` }] };
      }
    }
  • Zod schema defining the input parameter 'service' (string, name of the service).
    {
      service: z.string().default("").describe("Name of the service to get health checks for"),
    },
  • Registration of the 'get-health-checks' tool using server.tool(), including name, description, schema, and inline handler.
    server.tool(
      "get-health-checks",
      "Get health checks for a service",
      {
        service: z.string().default("").describe("Name of the service to get health checks for"),
      },
      async ({ service }) => {
        try {
          const data = await consul.health.service({ service });
          if (!data || data.length === 0) {
            return { content: [{ type: "text", text: `No health checks found for service: ${service}` }] };
          }
          
          // Extract health checks from the response
          const checks = data.flatMap(entry => entry.Checks || []);
          if (checks.length === 0) {
            return { content: [{ type: "text", text: `No health checks found for service: ${service}` }] };
          }
          
          const checksText = `Health checks for service ${service}:\n\n${checks.map(formatHealthCheck).join("\n")}`;
          return { content: [{ type: "text", text: checksText }] };
        } catch (error) {
          console.error("Error getting health checks:", error);
          return { content: [{ type: "text", text: `Error getting health checks for service: ${service}` }] };
        }
      }
    );
  • formatHealthCheck function used by the handler to format individual health check objects into multi-line strings for output.
    export function formatHealthCheck(check: HealthCheck): string {
      return [
        `Node: ${check.Node || "Unknown"}`,
        `CheckID: ${check.CheckID || "Unknown"}`,
        `Name: ${check.Name || "Unknown"}`,
        `Status: ${check.Status || "Unknown"}`,
        `ServiceName: ${check.ServiceName || "Unknown"}`,
        `ServiceID: ${check.ServiceID || "Unknown"}`, 
        `ServiceTags: ${check.ServiceTags?.join(", ") || "None"}`,
        `ServiceName: ${check.ServiceName || "Unknown"}`,
        `Output: ${check.Output || "No output"}`,
        "---",
      ].join("\n");
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states what the tool does but doesn't describe how it behaves - no information about what format the health checks are returned in, whether this is a read-only operation, if there are rate limits, authentication requirements, or error conditions. For a tool with zero annotation coverage, this is insufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise - a single sentence that directly states the tool's purpose. There's no wasted language or unnecessary elaboration, making it easy to parse and understand immediately.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of annotations and output schema, the description is incomplete for a tool that presumably returns health check data. It doesn't explain what constitutes a 'health check', what format the results are in, or what information the agent can expect to receive. For a tool in a monitoring/health context, this leaves significant gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, with the single parameter 'service' clearly documented in the schema. The description doesn't add any meaningful parameter semantics beyond what's already in the schema, so it meets the baseline of 3 when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Get') and resource ('health checks for a service'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'register-health-check' or 'deregister-health-check', which would require more specificity to earn a 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. There's no mention of prerequisites, when-not-to-use scenarios, or comparisons to related tools like 'get-services' or 'get-catalog-service' that might provide overlapping functionality.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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

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