Skip to main content
Glama

register-service

Register a service with Consul by specifying its name, ID, port, address, and optional tags. Simplifies service discovery and management within the Consul MCP Server framework.

Instructions

Register a service with Consul

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressNoAddress the service is running on
idNoID of the service (defaults to name if not provided)
nameNoName of the service to register
portNoPort the service is running on
tagsNoTags to associate with the service

Implementation Reference

  • The handler function for the 'register-service' tool. It constructs a service definition from inputs and calls consul.agent.service.register to register the service with Consul.
    async ({ name, id, port, address, tags }) => {
      try {
        const serviceId = id || name;
        const serviceDefinition: any = {
          name,
          id: serviceId,
        };
        
        if (port !== undefined) serviceDefinition.port = port;
        if (address !== undefined) serviceDefinition.address = address;
        if (tags !== undefined) serviceDefinition.tags = tags;
        
        await consul.agent.service.register(serviceDefinition);
        //if (!success) {
        //  return { content: [{ type: "text", text: `Failed to register service: ${name}` }] };
        //}
        
        return { content: [{ type: "text", text: `Successfully registered service: ${name} with ID: ${serviceId}` }] };
      } catch (error) {
        console.error("Error registering service:", error);
        return { content: [{ type: "text", text: `Error registering service: ${name}` }] };
      }
    }
  • Zod schema defining the input parameters for the 'register-service' tool.
    {
      name: z.string().default("").describe("Name of the service to register"),
      id: z.string().default("").optional().describe("ID of the service (defaults to name if not provided)"),
      port: z.number().optional().describe("Port the service is running on"),
      address: z.string().default("").optional().describe("Address the service is running on"),
      tags: z.array(z.string()).optional().describe("Tags to associate with the service"),
    },
  • Registration of the 'register-service' tool on the MCP server using server.tool(), including description, input schema, and handler function.
    server.tool(
      "register-service",
      "Register a service with Consul",
      {
        name: z.string().default("").describe("Name of the service to register"),
        id: z.string().default("").optional().describe("ID of the service (defaults to name if not provided)"),
        port: z.number().optional().describe("Port the service is running on"),
        address: z.string().default("").optional().describe("Address the service is running on"),
        tags: z.array(z.string()).optional().describe("Tags to associate with the service"),
      },
      async ({ name, id, port, address, tags }) => {
        try {
          const serviceId = id || name;
          const serviceDefinition: any = {
            name,
            id: serviceId,
          };
          
          if (port !== undefined) serviceDefinition.port = port;
          if (address !== undefined) serviceDefinition.address = address;
          if (tags !== undefined) serviceDefinition.tags = tags;
          
          await consul.agent.service.register(serviceDefinition);
          //if (!success) {
          //  return { content: [{ type: "text", text: `Failed to register service: ${name}` }] };
          //}
          
          return { content: [{ type: "text", text: `Successfully registered service: ${name} with ID: ${serviceId}` }] };
        } catch (error) {
          console.error("Error registering service:", error);
          return { content: [{ type: "text", text: `Error registering service: ${name}` }] };
        }
      }
    );
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. While 'register' implies a write/mutation operation, the description doesn't disclose critical behavioral traits like required permissions, whether registration is idempotent, potential side effects, or how Consul handles duplicate registrations. 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 extremely concise at just 5 words, front-loading the essential purpose with zero wasted words. Every word earns its place, making it efficient for quick comprehension by an AI agent.

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 5 parameters, no annotations, and no output schema, the description is incomplete. It lacks behavioral context, usage guidance, and any information about return values or potential errors. The high schema coverage helps with parameters but doesn't compensate for the broader contextual 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 description provides no parameter information beyond what's already in the schema (which has 100% coverage). Since schema_description_coverage is high, the baseline is 3 even without additional parameter semantics in the description. The description doesn't add value beyond the schema's parameter documentation.

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 service with Consul'), providing a specific verb+resource combination. However, it doesn't distinguish this tool from sibling tools like 'register-health-check' or 'deregister-service', which would require explicit differentiation 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 sibling tools like 'deregister-service' or 'register-health-check', leaving the agent without contextual usage direction.

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