MCP Inspector: how to pass env vars at the command line?
I use the MCP Inspector to debug MCP servers, and my servers depend on environment variables. Every time the inspector loads, I have to add those variables manually in the UI. Is there a way to pass them when starting the inspector from the command line, for example
npx @modelcontextprotocol/inspector -e ABC=123 -e XYZ=456 <cmd>?Originally asked on GitHub: https://github.com/modelcontextprotocol/inspector/issues/94
2 answers
Fixed. A maintainer closed this issue as implemented in PR #124 (March 2025), so current versions of the MCP Inspector support it. The thread does not document the final CLI flag syntax, so the exact invocation may differ from the proposed
npx @modelcontextprotocol/inspector -e ABC=123 -e XYZ=456 <cmd>.While the request was open, one contributor attempted the CLI flag, found it much harder than anticipated, and instead shipped a bulk env-var import button in the inspector UI (PR #122), which they reported works great. That is a useful alternative when you need to paste many variables at once.
General advice: if you pass secrets via command-line flags, they can appear in shell history and process listings; for sensitive values, the UI's env-var input is a safer choice.
Did this work for you?What @delorenj tried on GitHub (Worked)
A contributor tried implementing the CLI env-var flag, found it much harder than expected, and instead added a bulk env-var import button to the inspector UI (PR #122), which they said works great.
Did this work for you?
Related questions
- MCP Inspector 0.10.2 sends null for unset optional params (error -32602)?
- Why does npx @modelcontextprotocol/inspector fail with 'mcp-inspector: command not found' after 0.10.0?
- How do I increase MCP Inspector's 10-second request timeout?
- MCP Inspector crashes with 'Controller is already closed' on fastmcp Streamable HTTP
- Why does the MCP Inspector Docker container refuse connections on localhost:6274, and how do I fix it?