Installing Infrahub MCP
This guide provides step-by-step instructions for installing and configuring different MCP clients to connect to the Infrahub MCP server.
Prerequisites
- Ensure you have access to an Infrahub MCP server endpoint
- Each client may have additional prerequisites listed in their respective sections
Install & run the Infrahub MCP server
- Clone the repository
git clone https://github.com/opsmill/infrahub-mcp-server.git
cd infrahub-mcp-server
- Install dependencies
- Python 3.13+
- fastmcp
- infrahub_sdk
uv sync
- Run the server
uv run fastmcp run src/infrahub_mcp/server.py:mcp
Configuration
Set the following environment variables as needed:
Variable | Description | Default |
---|---|---|
INFRAHUB_ADDRESS | URL of your Infrahub instance | http://localhost:8000 |
INFRAHUB_API_TOKEN | API token for Infrahub | placeholder UUID |
MCP_HOST | Host for the web server | 0.0.0.0 |
MCP_PORT | Port for the web server | 8001 |
Add to your MCP client
- Cursor
- VS Code
- Claude Desktop
Manual steps
- Go to Settings > Cursor Settings > Tools & Integrations
- Under MCP tools, click Add Custom MCP
- Paste the configuration below into mcp.json
- MCP tools, click Add Custom MCP
- Save the file to apply the configuration
- Restart Cursor if prompted
Configuration
{
"mcpServers": {
"infrahub_mcp": {
"command": "uv",
"args": [
"run",
"fastmcp",
"run",
"src/infrahub_mcp/server.py:mcp"
],
"env": {
"PYENV_VERSION": "3.13.3",
"INFRAHUB_ADDRESS": "http://localhost:8000",
"INFRAHUB_API_TOKEN": "06438eb2-8019-4776-878c-0941b1f1d1ec",
}
}
}
}
Manual steps
Use the command line
code --add-mcp '{"type":"stdio","name":"infrahub-mcp","version":"0.0.1","description":"MCP server to interact with Infrahub","command":"uv","args":["run","fastmcp","run","src/infrahub_mcp/server.py:mcp"],"author":"Opsmill","tags":["infrahub-mcp","mcp","server"],"categories":["mcp"],"env":{"MCP_HOST":"0.0.0.0","MCP_PORT":"8001","INFRAHUB_ADDRESS":"http://localhost:8000","INFRAHUB_API_TOKEN":"placeholder UUID"}}'
Then open the MCP Servers configuration file (Cmd+Shift+P and type "MCP: Open User Configuration") and replace the default env values with your own.
Then go to Extensions, find the Infrahub MCP server in the list, open the menu with right-click and click on Start Server.
Manual steps
- Go to Settings > Developer
- Click Edit config to open the claude_desktop_config.json file
- Add the MCP server configuration to the
mcpServers
section - Paste the configuration below
- Modify the default env values with your own
- Save the file to apply the configuration
- Restart Claude Desktop
Configuration
{
"mcpServers": {
"infrahub_mcp": {
"transport": "stdio",
"command": "uv",
"args": [
"run",
"fastmcp",
"run",
"src/infrahub_mcp/server.py:mcp"
],
"env": {
"PYENV_VERSION": "3.13.3",
"INFRAHUB_ADDRESS": "http://localhost:8000",
"INFRAHUB_API_TOKEN": "06438eb2-8019-4776-878c-0941b1f1d1ec",
}
}
}
}