inspector icon indicating copy to clipboard operation
inspector copied to clipboard

Exporting MCP_CATALOG_PATH breaks --config across CLI, mcpdo, Web, and TUI

Open KilianTheMagnificent opened this issue 2 weeks ago • 6 comments

Which version line?

v2 — current (@modelcontextprotocol/inspector@latest)

Which client?

All / shared core

Inspector version

2.16.0

Node version

v26.13.1

Operating system (and browser, for the web client)

macOS 27.3 (arm64)

Transport

Not applicable / never connected

MCP server under inspection

Not applicable — fails during launch-flag validation before connecting to any server.

Steps to reproduce

  1. Create two minimal config files in a temp directory:
    TESTDIR=$(mktemp -d)
    echo '{"mcpServers":{}}' > "$TESTDIR/my-catalog.json"
    echo '{"mcpServers":{"demo":{"command":"node","args":["-e",""]}}}' > "$TESTDIR/foreign.json"
    
  2. Verify --config works when MCP_CATALOG_PATH is unset:
    env -u MCP_CATALOG_PATH npx -y @modelcontextprotocol/[email protected] --cli --config "$TESTDIR/foreign.json" --method servers/list
    
  3. Export MCP_CATALOG_PATH (to change the default catalog path per shell) and pass --config without --catalog on any of the four clients:
    MCP_CATALOG_PATH="$TESTDIR/my-catalog.json" npx -y @modelcontextprotocol/[email protected] --cli --config "$TESTDIR/foreign.json" --method servers/list
    MCP_CATALOG_PATH="$TESTDIR/my-catalog.json" npx -y --package=@modelcontextprotocol/[email protected] mcpdo --config "$TESTDIR/foreign.json" servers/list
    MCP_AUTO_OPEN_ENABLED=false MCP_CATALOG_PATH="$TESTDIR/my-catalog.json" npx -y @modelcontextprotocol/[email protected] --web --config "$TESTDIR/foreign.json"
    MCP_CATALOG_PATH="$TESTDIR/my-catalog.json" npx -y @modelcontextprotocol/[email protected] --tui --config "$TESTDIR/foreign.json" </dev/null
    

Expected behavior

MCP_CATALOG_PATH changes the default catalog location (in place of ~/.mcp-inspector/mcp.json), so passing --config <file> without an explicit --catalog flag should ignore MCP_CATALOG_PATH and open <file> read-only across all four clients — just as CLI and mcpdo connect already ignore MCP_CATALOG_PATH for ad-hoc targets (#1573). Explicitly passing both --catalog and --config should still fail as mutually exclusive.

Actual behavior

All four clients treat the ambient MCP_CATALOG_PATH env var as an explicit --catalog flag and exit 1 with --catalog and --config are mutually exclusive. This also breaks the documented mcpdo flow (skills/mcpdo/SKILL.md: export MCP_CATALOG_PATH per shell + mcpdo connect <entry> --config path/to/mcp.json), as well as mcpdo servers/show and mcpdo auth/list with --config.

Logs, errors, or screenshots

# Control (MCP_CATALOG_PATH unset) — exit 0
{"servers":[{"name":"demo","type":"stdio","detail":"node -e "}]}

# CLI (MCP_CATALOG_PATH set) — exit 1
{"error":{"code":"error","message":"--catalog and --config are mutually exclusive. --catalog is the writable catalog; --config is a read-only session file."}}

# mcpdo (MCP_CATALOG_PATH set) — exit 1
{"error":{"code":"error","message":"--catalog and --config are mutually exclusive. --catalog is the writable catalog; --config is a read-only session file."}}

# Web (MCP_CATALOG_PATH set) — exit 1
Error: --catalog and --config are mutually exclusive. --catalog is the writable catalog; --config is a read-only session file.

# TUI (MCP_CATALOG_PATH set) — exit 1
Error running MCP Inspector: --catalog and --config are mutually exclusive. --catalog is the writable catalog; --config is a read-only session file.

Relevant env fallback sites checked on v2/main:

  • clients/cli/src/cli.ts:2081 (envCatalog gated on adHoc, not options.config)
  • clients/mcpdo/src/connection/mcp.ts:430, 465, 666, 820 (servers/list, servers/show, connect, auth/list)
  • clients/web/server/run-web.ts:126 (opts.catalog ?? process.env.MCP_CATALOG_PATH)
  • clients/tui/tui.tsx:120 (options.catalog?.trim() || process.env.MCP_CATALOG_PATH)

Before you submit

  • [x] I searched existing issues and this is not a duplicate.
  • [x] This is not a security vulnerability report (those go through the private advisory process).

AI disclosure: Reproduced locally and drafted with an AI coding agent (Antigravity / Gemini) running @modelcontextprotocol/[email protected] on macOS arm64 / Node v26.13.1.

KilianTheMagnificent avatar Nov 19 '26 00:11 KilianTheMagnificent

Independent Windows reproduction of #3021, with an implementation-focused prompt for the v2 maintainer workflow (AI-assisted testing and write-up disclosed).

Pinned environment: published @modelcontextprotocol/[email protected], isolated Node v24.22.1 (satisfies its declared engine range), Windows PowerShell host; disposable HOME, APPDATA, catalog and read-only config fixtures containing only synthetic server names. No real MCP servers, credentials or user config were accessed. The system-wide Node version was not changed.

Observed seven-case matrix (all expected outcomes independently checked):

  • mcp-inspector --cli --config foreign.json --method servers/list, no MCP_CATALOG_PATH: exit 0; returns foreign_fixture.
  • Same command with ambient MCP_CATALOG_PATH=catalog.json: exit 1; --catalog and --config are mutually exclusive (regression).
  • mcpdo --config foreign.json servers/list, no ambient catalog: exit 0; returns foreign_fixture.
  • Same mcpdo command with ambient catalog: exit 1, same conflict (regression).
  • Both flags explicitly specified (--catalog catalog.json --config foreign.json): exit 1, expected conflict.
  • Ambient catalog without --config: CLI exit 0 and mcpdo exit 0; both list catalog_fixture (two positive controls).

The independent run completed with all seven assertions passing. Private reproducibility receipt SHA-256: 836C95975CBA6D7EF8B8442270ED9789BEE78363E92A7F5CCFD48C349A577E63 (digest is custody evidence, not a public raw log).

Implementation prompt for the maintainers (following CONTRIBUTING.md, not an outside PR):

In Inspector v2, distinguish an explicit --catalog argument from the ambient default MCP_CATALOG_PATH. If --config is explicitly provided, suppress only the ambient catalog fallback; keep explicit --catalog + --config mutually exclusive. Retain ambient catalog selection when neither an explicit read-only config nor an ad-hoc target is provided. Apply identical precedence in CLI clients/cli/src/cli.ts, mcpdo's servers/list, servers/show, connect, and auth/list branches (clients/mcpdo/src/connection/mcp.ts), Web clients/web/server/run-web.ts, and TUI clients/tui/tui.tsx. Add tests proving this seven-case matrix and checking that --config never creates, seeds, migrates, or writes a catalog. Preserve explicit conflict errors, ad-hoc targeting and existing credential-isolation behavior. Prefer one shared precedence helper or equivalent targeted changes to avoid inconsistent modes.

This independently confirms the original macOS report on Windows. It does not establish Web/TUI runtime results; those paths are source-identified targets for maintainer-side tests.

Footloose9 avatar Nov 19 '26 05:11 Footloose9

Confirmed this independently on Linux x86_64 with Inspector 2.16.0 and Node v24.22.3. With --config alone, Web served the Inspector page on loopback (HTTP 200), and TUI displayed the synthetic server entry without connecting. With MCP_CATALOG_PATH set and the same --config flag, both exited with code 1 and --catalog and --config are mutually exclusive, even though no --catalog flag was supplied. Passing both flags explicitly still failed as expected. The config and catalog fixtures were unchanged. I did not test browser rendering or a live server connection.

AI disclosure: OpenAI Codex assisted with the checks and this write-up.

hchiao1 avatar Nov 20 '26 14:11 hchiao1

Thanks @Footloose9 and @hchiao1 for the independent checks!

Quick summary for maintainers: this now reproduces on @modelcontextprotocol/[email protected] across macOS, Windows, and Linux covering all four clients (--cli, mcpdo, --web, and --tui), while explicit --catalog + --config still returns the expected mutual-exclusion error.

AI disclosure: This reply was drafted with an AI assistant and reviewed/approved by me.

KilianTheMagnificent avatar Nov 20 '26 17:11 KilianTheMagnificent

My pleasure. Happy to help.

Footloose9 avatar Nov 20 '26 20:11 Footloose9

Triage: Priority Medium (total 8)

  • Severity 3 — an exported MCP_CATALOG_PATH makes --config fail on all four clients and breaks the documented mcpdo flow; env -u MCP_CATALOG_PATH is a workaround
  • Urgency 2 — on a published version, but with an easy workaround
  • Bonuses: +1 bug label, +1 high engagement (independent reproductions on macOS, Windows and Linux)

Board: #28, Status Incoming (awaiting maintainer review — no milestone yet).

cliffhall avatar Nov 24 '26 03:11 cliffhall

Fixed by #3034 (merged into v2/main).

cliffhall avatar Nov 24 '26 07:11 cliffhall