Skip to main content
Glama

register-health-check

Defines and registers a health check with Consul, specifying name, service association, TTL, HTTP endpoint, interval, and timeout for monitoring service status and availability.

Instructions

Register a health check with Consul

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
httpNoHTTP endpoint to check
idNoID of the health check (defaults to name if not provided)
intervalNoInterval for the check (e.g., '10s', '1m')
nameNoName of the health check
notesNoNotes about the health check
serviceIdNoID of the service to associate the check with
timeoutNoTimeout for the check (e.g., '5s', '30s')
ttlNoTime to live for the check (e.g., '10s', '1m')

Implementation Reference

  • The handler function that performs the actual registration of the health check using Consul's agent.check.register method. It constructs the check definition from input parameters and handles success/error responses.
    async ({ name, id, serviceId, notes, ttl, http, interval, timeout }) => {
      try {
        const checkId = id || name;
        const checkDefinition: any = {
          name,
          id: checkId,
        };
        
        if (serviceId !== undefined) checkDefinition.serviceId = serviceId;
        if (notes !== undefined) checkDefinition.notes = notes;
        if (ttl !== undefined) checkDefinition.ttl = ttl;
        if (http !== undefined) {
          checkDefinition.http = http;
          // HTTP checks require an interval
          if (interval !== undefined) checkDefinition.interval = interval;
        }
        if (timeout !== undefined) checkDefinition.timeout = timeout;
        
        const success = await consul.agent.check.register(checkDefinition);
        if (!success) {
          return { content: [{ type: "text", text: `Failed to register health check: ${name}` }] };
        }
        
        return { content: [{ type: "text", text: `Successfully registered health check: ${name} with ID: ${checkId}` }] };
      } catch (error) {
        console.error("Error registering health check:", error);
        return { content: [{ type: "text", text: `Error registering health check: ${name}` }] };
      }
    }
  • Zod schema defining the input parameters for the register-health-check tool, including optional fields for check configuration.
    {
      name: z.string().default("").describe("Name of the health check"),
      id: z.string().default("").default("").optional().describe("ID of the health check (defaults to name if not provided)"),
      serviceId: z.string().default("").optional().describe("ID of the service to associate the check with"),
      notes: z.string().default("").optional().describe("Notes about the health check"),
      ttl: z.string().default("").optional().describe("Time to live for the check (e.g., '10s', '1m')"),
      http: z.string().default("").optional().describe("HTTP endpoint to check"),
      interval: z.string().default("").optional().describe("Interval for the check (e.g., '10s', '1m')"),
      timeout: z.string().default("").optional().describe("Timeout for the check (e.g., '5s', '30s')"),
    },
  • The server.tool call that registers the 'register-health-check' tool with the MCP server, including name, description, schema, and handler.
    server.tool(
      "register-health-check",
      "Register a health check with Consul",
      {
        name: z.string().default("").describe("Name of the health check"),
        id: z.string().default("").default("").optional().describe("ID of the health check (defaults to name if not provided)"),
        serviceId: z.string().default("").optional().describe("ID of the service to associate the check with"),
        notes: z.string().default("").optional().describe("Notes about the health check"),
        ttl: z.string().default("").optional().describe("Time to live for the check (e.g., '10s', '1m')"),
        http: z.string().default("").optional().describe("HTTP endpoint to check"),
        interval: z.string().default("").optional().describe("Interval for the check (e.g., '10s', '1m')"),
        timeout: z.string().default("").optional().describe("Timeout for the check (e.g., '5s', '30s')"),
      },
      async ({ name, id, serviceId, notes, ttl, http, interval, timeout }) => {
        try {
          const checkId = id || name;
          const checkDefinition: any = {
            name,
            id: checkId,
          };
          
          if (serviceId !== undefined) checkDefinition.serviceId = serviceId;
          if (notes !== undefined) checkDefinition.notes = notes;
          if (ttl !== undefined) checkDefinition.ttl = ttl;
          if (http !== undefined) {
            checkDefinition.http = http;
            // HTTP checks require an interval
            if (interval !== undefined) checkDefinition.interval = interval;
          }
          if (timeout !== undefined) checkDefinition.timeout = timeout;
          
          const success = await consul.agent.check.register(checkDefinition);
          if (!success) {
            return { content: [{ type: "text", text: `Failed to register health check: ${name}` }] };
          }
          
          return { content: [{ type: "text", text: `Successfully registered health check: ${name} with ID: ${checkId}` }] };
        } catch (error) {
          console.error("Error registering health check:", error);
          return { content: [{ type: "text", text: `Error registering health check: ${name}` }] };
        }
      }
    );
  • src/server.ts:37-37 (registration)
    Invocation of registerHealthChecks function which includes the registration of the 'register-health-check' tool among others.
    registerHealthChecks(server, consul);
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure but only states the basic action. It doesn't mention whether this is a write operation (implied by 'Register'), what permissions are needed, potential side effects, error conditions, or response format. This leaves significant gaps for a mutation tool.

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 a single, efficient sentence that directly states the tool's purpose without unnecessary words. It's appropriately sized and front-loaded, with every word earning its place in conveying the essential information.

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?

For a mutation tool with 8 parameters and no annotations or output schema, the description is insufficiently complete. It doesn't address behavioral aspects like what happens on success/failure, authentication requirements, or how this tool relates to sibling operations, leaving the agent with incomplete context.

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%, so all 8 parameters are documented in the schema. The description adds no additional parameter information beyond what's already in the structured schema fields, meeting the baseline expectation but not providing extra value.

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 action ('Register') and resource ('a health check with Consul'), providing specific verb+resource information. However, it doesn't differentiate from sibling tools like 'deregister-health-check' or 'get-health-checks', which would require explicit comparison to achieve a perfect score.

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 like 'deregister-health-check' or 'get-health-checks'. There's no mention of prerequisites, context, or exclusions, leaving the agent without usage direction beyond the basic purpose.

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