My MCP servers pile up over time, and a session that needs one of them still starts them all. A pair of flags gives me a session with exactly the servers I choose.
--mcp-config loads MCP servers from one or more JSON files or strings. --strict-mcp-config makes Claude Code skip the servers configured in places such as .mcp.json, ~/.claude.json or a plugin, and load only the ones you pass.
claude --strict-mcp-config --mcp-config ./only-this.json
A minimal file for one local server looks like this, using the mcpServers wrapper that Claude Code reads:
{
"mcpServers": {
"example": {
"command": "npx",
"args": ["-y", "@example/mcp-server"]
}
}
}
The CLI reference adds that with -p, Claude Code waits for servers that are still pending to connect before it runs the first turn, up to the MCP_TIMEOUT startup timeout (30 seconds by default). That helps scripted runs, because the tools exist when the prompt starts. It requires Claude Code v2.1.221 or later.
@example/mcp-server is a placeholder for the server you actually use. Under a managed MCP file the strict flag behaves differently, and the docs section on exclusive control with managed-mcp.json explains how. An MCP server runs code on your machine, so only name servers you trust.
Further reading: Claude Code CLI reference