Skip to main content

Installing Infrahub MCP

This guide provides step-by-step instructions for installing and configuring different MCP clients to connect to the Infrahub MCP server.

For container-based deployments (Docker Compose, sidecar alongside Infrahub), see the Docker deployment guide. To run the server in Kubernetes next to an Infrahub instance installed with Helm, see Deploy on Kubernetes with Helm.

Prerequisites​

  • Python 3.13+
  • Access to an Infrahub instance
  • An API token or credentials for your Infrahub instance

Install the Infrahub MCP server​

No installation needed — uvx runs the package directly from PyPI:

uvx infrahub-mcp --help
note

The infrahub-mcp CLI entry point requires version 1.1.0 or later. For earlier versions, use uvx --from infrahub-mcp fastmcp run infrahub_mcp.server:mcp instead.

Run the server​

# With uvx (no install)
uvx infrahub-mcp

# Or if installed via pip
infrahub-mcp

# With explicit transport
infrahub-mcp --transport streamable-http --host 0.0.0.0 --port 8001

Configuration​

Set the following environment variables as needed:

VariableDescriptionDefault
INFRAHUB_ADDRESSURL of your Infrahub instancerequired
INFRAHUB_API_TOKENAPI token (or use username + password)—
MCP_HOSTHost for the web server0.0.0.0
MCP_PORTPort for the web server8001
INFRAHUB_MCP_READ_ONLYDisable write operationsfalse
INFRAHUB_MCP_LOG_LEVELSet to debug for verbose logginginfo

For the full list of configuration options (rate limiting, caching, auth, observability), see the Configuration reference.

Add to your MCP client​

Go to Settings > Cursor Settings > Tools & Integrations, click Add Custom MCP, and paste the following into mcp.json:

{
"mcpServers": {
"infrahub_mcp": {
"command": "uvx",
"args": ["infrahub-mcp"],
"env": {
"INFRAHUB_ADDRESS": "http://localhost:8000",
"INFRAHUB_API_TOKEN": "your-api-token"
}
}
}
}

For tool-approval tuning, workspace rules, and troubleshooting, see the Cursor integration guide.

Streamable HTTP with authentication​

When the MCP server runs over Streamable HTTP with token-passthrough or basic-passthrough auth, clients connect via URL and pass credentials in the Authorization header instead of using stdio with env vars. See Set up authentication for server-side configuration.

warning

These configuration files contain credentials in plain text. Do not commit them to version control — add .mcp.json to .gitignore.

In your .mcp.json:

{
"mcpServers": {
"infrahub": {
"type": "http",
"url": "http://localhost:8001/mcp",
"headers": {
"Authorization": "Bearer <your-infrahub-api-token>"
}
}
}
}

For basic passthrough, replace the Authorization value with Basic <base64(username:password)>.