Skip to main content
Glama

Consul MCP Server

A Model Context Protocol (MCP) server that provides AI assistants with tools to interact with HashiCorp Consul. Built with FastMCP.

Features

This MCP server exposes Consul's core functionality through three types of integrations:

Tools

  • Service Management: Register, deregister, and list services

  • Health Checks: Query service health status and check details

  • Key-Value Store: Get and put values in Consul's KV store

  • Service Mesh Intentions: Create, list, get, and delete Connect intentions

Resources

  • consul://services - List all registered services

  • consul://service/{name}/health - Get health status for a specific service

  • consul://kv/{key} - Retrieve values from KV store

  • consul://intentions - List all Connect intentions

  • consul://intention/{id} - Get specific intention details

Prompts

  • setup_consul_service - Guided service registration

  • debug_service_health - Service health troubleshooting

  • configure_intentions - Service mesh intention configuration

  • optimize_kv_structure - KV store organization recommendations

Related MCP server: GCP MCP Server

Installation

Prerequisites

  • Python 3.10 or higher

  • uv (recommended)

  • Docker (for running Consul locally)

Quick Install

# Clone the repository
git clone https://github.com/tywe00/consul-mcp-server.git
cd consul-mcp-server

# Install dependencies
make sync

Configuration

Environment Variables

Copy .env.example to .env and configure:

CONSUL_URL=http://localhost:8500
LOG_LEVEL=INFO

Running Consul Locally

If you don't have Consul running, start it with Docker:

make consul-run

Access Consul UI at: http://localhost:8500/ui

To stop Consul:

make consul-stop

Usage

Running the Server

Stdio Transport (default)

make run

HTTP Transport

make run-http

With MCP Inspector (for testing)

make inspector

Using with Claude Desktop

Add to your Claude Desktop configuration (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):

{
  "mcpServers": {
    "consul": {
      "command": "uv",
      "args": [
        "--directory",
        "/path/to/consul-mcp-server",
        "run",
        "consul-mcp-server"
      ]
    }
  }
}

Using with Other MCP Clients

This server implements the standard MCP protocol and works with any MCP-compatible client. Configure your client to connect via stdio or HTTP transport.

Development

Setup Development Environment

# Install with dev dependencies
make sync

Available Commands

Run make help to see all available commands:

make help          # Show all available commands
make sync          # Install/update all dependencies
make install       # Install production dependencies only
make test          # Run tests
make test-cov      # Run tests with coverage report
make lint          # Check code quality
make format        # Auto-format code
make type-check    # Run type checker
make run           # Run the server (stdio transport)
make run-http      # Run the server (HTTP transport)
make inspector     # Run with MCP Inspector for testing
make consul-run    # Start Consul Docker container
make consul-stop   # Stop Consul Docker container
make clean         # Clean build artifacts and cache
make build         # Build distribution packages

Running Tests

# Run all tests
make test

# Run with coverage
make test-cov

Code Quality

# Format code
make format

# Lint code
make lint

# Type checking
make type-check

Project Structure

consul-mcp-server/
├── src/
│   ├── __init__.py
│   ├── server.py           # Main server entry point
│   ├── mcp_instance.py     # FastMCP singleton instance
│   ├── tools/
│   │   └── tools.py        # Consul tool implementations
│   ├── resources/
│   │   └── resources.py    # Consul resource providers
│   └── prompts/
│       └── prompts.py      # AI assistant prompts
├── tests/
│   └── test_tools.py       # Tool tests
├── pyproject.toml          # Project configuration
├── fastmcp.json           # FastMCP configuration
└── README.md

Available Tools

Service Management

list_services

# List all registered services
list_services(consul_url="http://localhost:8500")

register_service

# Register a new service
register_service(
    id="web-1",
    name="web",
    address="10.0.0.1",
    port=8080,
    consul_url="http://localhost:8500"
)

deregister_service

# Remove a service
deregister_service(id="web-1", consul_url="http://localhost:8500")

get_service_health

# Check service health
get_service_health(service_name="web", consul_url="http://localhost:8500")

Key-Value Store

kv_put

# Store a value
kv_put(key="config/app/setting", value="production", consul_url="http://localhost:8500")

kv_get

# Retrieve a value
kv_get(key="config/app/setting", consul_url="http://localhost:8500")

Service Mesh Intentions

list_intentions

# List all intentions
list_intentions(consul_url="http://localhost:8500")

create_intention

# Create an intention
create_intention(
    source="web",
    destination="api",
    action="allow",
    consul_url="http://localhost:8500"
)

get_intention

# Get specific intention
get_intention(intention_id="abc-123", consul_url="http://localhost:8500")

delete_intention

# Delete an intention
delete_intention(intention_id="abc-123", consul_url="http://localhost:8500")

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository

  2. Create your feature branch (git checkout -b feature/amazing-feature)

  3. Commit your changes (git commit -m 'Add amazing feature')

  4. Push to the branch (git push origin feature/amazing-feature)

  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

Support

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables management of Mistral AI agents through MCP tools including creating, listing, searching, viewing details, and deleting agents. Integrates with Mistral API to provide agent management capabilities through natural language interactions.
      1
      -
    • A
      license
      B
      quality
      Not graded
      maintenance
      Enables AI assistants to interact with and manage Google Cloud Platform resources including Artifact Registry, BigQuery, Cloud Build, Compute Engine, Cloud Run, Cloud Storage, and monitoring services through a standardized MCP interface.
      1
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      Exposes Azure AI Foundry agents, workflows, and AI Search vector-database capabilities as MCP tools, enabling natural language interaction with agents, semantic search, and index management.
      10
      2
      MIT