Skip to main content

VS Code

VS Code supports MCP through its extension API — the Infrahub MCP server shows up as a tool provider alongside Copilot. This page covers the code --add-mcp setup and the VS Code Copilot compatibility flag.

Quick start

See the Installation guide for the minimal VS Code configuration snippet. This page covers VS Code-specific details and the Copilot compatibility flag.

Register via CLI

The fastest way to register the server is with VS Code's --add-mcp flag:

code --add-mcp '{
"type": "stdio",
"name": "infrahub-mcp",
"description": "MCP server to interact with Infrahub",
"command": "uvx",
"args": ["infrahub-mcp"],
"env": {
"INFRAHUB_ADDRESS": "http://localhost:8000",
"INFRAHUB_API_TOKEN": "placeholder-token"
}
}'

Then open the MCP user configuration (Cmd/Ctrl+Shift+P → MCP: Open User Configuration) and replace placeholder-token with your real API token.

Remote (HTTP) transport

{
"servers": {
"infrahub_mcp": {
"type": "http",
"url": "http://localhost:8001/mcp"
}
}
}

VS Code Copilot compatibility

VS Code Copilot Chat does not follow JSON Schema $ref references in tool definitions. If you see errors about unresolved schemas, enable $ref inlining on the server:

export INFRAHUB_MCP_DEREFERENCE_SCHEMAS=true

This makes every tool definition self-contained. There's no downside for clients that do handle $ref — the schemas just become more verbose.

Using the tools

Once registered, MCP tools show up alongside Copilot's native tools. In Copilot Chat, reference them like any other tool:

Use the Infrahub server to list all DcimDevice kinds and summarize their roles.

Troubleshooting

SymptomFix
MCP command not foundUpdate VS Code — MCP support lands in recent versions.
$ref schema errorsSet INFRAHUB_MCP_DEREFERENCE_SCHEMAS=true.
Server shows as stoppedRight-click the extension, choose Start Server, and check the Output panel.