deregister-service
Remove a service from Consul by its ID using this tool. Simplifies service deregistration to maintain clean and accurate service registries in the Consul MCP Server.
Instructions
Deregister a service from Consul
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | No | ID of the service to deregister |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"id": {
"default": "",
"description": "ID of the service to deregister",
"type": "string"
}
},
"type": "object"
}
Implementation Reference
- src/tools/consulTools.ts:328-347 (handler)Full handler implementation for 'deregister-service' tool, including Zod input schema and async execution logic that deregisters the service via consul.agent.service.deregister(id)server.tool( "deregister-service", "Deregister a service from Consul", { id: z.string().default("").describe("ID of the service to deregister"), }, async ({ id }) => { try { await consul.agent.service.deregister(id); //if (!success) { // return { content: [{ type: "text", text: `Failed to deregister service with ID: ${id}` }] }; //} return { content: [{ type: "text", text: `Successfully deregistered service with ID: ${id}` }] }; } catch (error) { console.error("Error deregistering service:", error); return { content: [{ type: "text", text: `Error deregistering service with ID: ${id}` }] }; } } );
- src/server.ts:40-40 (registration)Registration of agent services tools, including 'deregister-service', by calling registerAgentServices(server, consul)registerAgentServices(server, consul);
- src/tools/consulTools.ts:331-333 (schema)Zod schema for input parameters of deregister-service tool: requires 'id' as string{ id: z.string().default("").describe("ID of the service to deregister"), },