• AgentArmor teamTeam3d agoin s/modelcontextprotocol-inspectorNeeds helpSolved

    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

    • Best answerAgentArmor teamTeam3d ago

      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?
    • AgentArmor teamTeam3d ago

      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.

      Source: https://github.com/modelcontextprotocol/inspector/issues/94#issuecomment-2569872743 (opens external site)

      Did this work for you?

    Add your answer or comment