Skip to main content

mcpdoctor

Python License Dependencies

Your MCP server won't connect, and the client won't tell you why. mcpdoctor will.

You add a server to Claude Desktop / Claude Code / Cursor / VS Code, restart, and get silence — no error, no server. Install guides put the average first-time MCP install at up to 3 hours of guessing (mcpindex.dev, How to Install MCP Servers — "The Installation Trap"). mcpdoctor finds your client configs, checks every server entry stage by stage, and prints which step failed, why, and the exact fix — usually in under a second per server.

Zero dependencies. Read-only: it never modifies your configs. Env values are never printed (key names only).

The four classic causes (from every troubleshooting guide)

  1. Wrong config file / wrong key — e.g. servers written under mcpServers in a VS Code file, which reads servers. The client loads nothing and says nothing.
  2. Silent JSON failure — a trailing comma or a // comment makes the whole file unparseable; most clients respond by loading zero servers, with no error dialog.
  3. GUI apps don't inherit your shell PATH — npx works in your terminal, but the GUI app was launched with a minimal PATH, so spawning the server fails with a silent ENOENT.
  4. The server itself dies or misbehaves on startup — it crashes before the handshake, prints log lines to stdout (which is the JSON-RPC channel), never answers, or rejects initialize.

What it checks

For every server entry in every config it finds, in order:

Stage Checks
parse JSON/TOML syntax — with the exact line/column, and specific detection of trailing commas, comments, UTF-8 BOMs, invalid UTF-8, and duplicate keys (a repeated server name silently shadows the earlier definition in every JSON parser)
schema The client's top-level key, entry shape, command present and a single executable (a whole command line in command — "npx -y srv" — is caught and the split shown), args a list of strings, env an object whose values are strings/numbers/booleans
resolve The command resolved twice: against your shell PATH and against the minimal PATH a GUI app inherits — plus existence/executability for absolute paths
run The server is actually spawned (with its env merged) and spoken to in raw JSON-RPC over stdio: initialize → notifications/initialized → tools/list, with stderr captured separately

Failures are classified into cause codes: TRAILING_COMMA, COMMENT_IN_JSON, CONFIG_PARSE_ERROR, WRONG_TOP_LEVEL_KEY, SCHEMA_ERROR, MISSING_COMMAND, COMMAND_EMBEDDED_ARGS, INVALID_FIELD, COMMAND_NOT_FOUND, GUI_PATH, NOT_EXECUTABLE, PROCESS_EXITED_EARLY (with the missing env var named when stderr names one), STDOUT_POLLUTION, TIMEOUT, INVALID_RESPONSE, INIT_ERROR, TOOLS_LIST_FAILED.

Healthy servers also get a tool tax line: tool count, tool-definition size in characters, and an approximate token estimate — clearly labelled as an estimate (chars ÷ 4; real tokenizers differ per model).

What it does NOT do

  • It does not modify, fix, or reformat your configs. It tells you the fix; you apply it.
  • It does not check remote (URL/HTTP) servers in v0.1 — they are reported as skipped.
  • It does not guarantee a server works inside a specific client version — it reproduces the client's config location, PATH environment, and handshake as documented; client bugs are out of scope.
  • The token figure is a rough estimate, not a billing number.

Known limitations

  • First fault wins. Diagnosis stops at the first failing stage per server, and within the run stage a server that prints a banner to stdout and then crashes is reported for the banner (INVALID_RESPONSE/STDOUT_POLLUTION) — fix that and re-run to see the next fault.
  • GUI PATH is a simulation of the documented minimal PATH per OS, not a query of your actual GUI session. If you customized the GUI environment (e.g. launchctl setenv PATH …), a GUI_PATH verdict can be wrong for your machine — the prescribed fix (use the absolute path) is still correct and harmless.
  • Windows paths are untested on Windows. The path table is implemented and resolved via %APPDATA% / the user profile, but the test suite runs on POSIX.
  • Relative paths resolve against mcpdoctor's working directory — a relative command or a relative script in args is interpreted from wherever you run the doctor. Clients differ (project root, home directory), so run the doctor from the directory your client would use.
  • Worst-case time per server is ~2× --timeout plus a few seconds (one timeout for initialize, one for tools/list, plus drain/terminate grace). A config whose first server hangs still gets every later server diagnosed.
  • Secret scrubbing has a floor. Env values and secret-flag arguments of 4+ characters are scrubbed from all output; shorter values are not (replacing them would mangle unrelated text). A server that prints a secret it obtained some other way (a file, a derived token) can still echo it — the doctor cannot know that string is secret.
  • Single-line messages over ~1 MB are treated as invalid output: stream reads are size-capped so a broken server cannot flood the doctor's memory. No real MCP server sends a 1 MB single-line handshake response.
  • Daemonizing servers: if the entry point forks and the parent exits, the doctor reports the parent's exit (correctly — a stdio server must stay attached), but it cannot kill or reap the detached grandchild; that process belongs to the OS.
  • Duplicate keys are only flagged at the top level and server-name level. A repeated key deep inside one entry (e.g. two "command" keys) is collapsed silently, as in every JSON parser.
  • A config path that is a directory (e.g. ~/.cursor/mcp.json/ exists as a folder) is reported as "not found" during discovery; pass it via --config to get the explicit "not a file" error.

Quickstart

pip install mcpdoctor-py        # (not yet published — install from source for now)
# from source:
pip install -e .

mcpdoctor                    # discover and check all client configs
mcpdoctor --json             # machine-readable report
mcpdoctor --config ~/.cursor/mcp.json --client cursor
mcpdoctor --timeout 5        # shorter handshake timeout (default 10s)

Exit codes: 0 = every checked server healthy · 1 = at least one broken · 2 = no client configs found (nothing to check).

Demo

A real run against deliberately broken configs (full capture in demo.txt):

Claude Desktop — ~/.config/Claude/claude_desktop_config.json
  ✗ (config file) [parse/TRAILING_COMMA] JSON syntax error at line 4, column 3…
      Fix: Remove the trailing comma at line 4 of … — JSON does not allow a
      comma before a closing brace/bracket, and most clients respond by
      silently loading zero servers.

Claude Code — ~/.claude.json
  ✗ chatty-server [run/STDOUT_POLLUTION] The server answered initialize, but
    printed 1 non-JSON line(s) to stdout first — strict clients refuse the
    connection.
  ✗ crashy-server [run/PROCESS_EXITED_EARLY] The server process exited with
    code 1 before answering the initialize handshake. (stderr traceback shown)
  ✓ notes-server: Healthy — fixture-healthy 1.2.3 answered initialize and
    tools/list with 2 tool(s); tool definitions are 359 chars ≈ ~90 tokens
    (rough estimate, chars/4).

Cursor — ~/.cursor/mcp.json
  ✗ ghost-server [resolve/GUI_PATH] "npx" resolves in your shell … but is
    invisible on the minimal PATH a GUI app inherits — the classic silent
    spawn ENOENT.
      Fix: … Replace "command" with the absolute path "…/bin/npx".

Config locations

macOS/Linux are fully working. Windows paths are included in the table below (resolved via %APPDATA% / the user profile when run on Windows):

Client macOS Linux Windows
Claude Desktop ~/Library/Application Support/Claude/claude_desktop_config.json ~/.config/Claude/claude_desktop_config.json %APPDATA%\Claude\claude_desktop_config.json
Claude Code ~/.claude.json (+ project .mcp.json) same %USERPROFILE%\.claude.json
Cursor ~/.cursor/mcp.json same %USERPROFILE%\.cursor\mcp.json
VS Code ~/Library/Application Support/Code/User/mcp.json ~/.config/Code/User/mcp.json %APPDATA%\Code\User\mcp.json
Codex ~/.codex/config.toml same %USERPROFILE%\.codex\config.toml

Tests & benchmark

51 real tests — the original 20 planted cases plus 31 hardening regression tests from an adversarial probe pass (BOM and invalid-UTF-8 configs, duplicate server names, secret leakage through crash stderr, a 30 MB stderr line, embedded arguments in command, missing/bad shebangs, tools/list failures, Codex TOML, double-forking servers). Real config files and real server processes on disk throughout; no mocked subprocess for the live-run cases:

pip install -e . pytest
python -m pytest tests/ -q
python benchmarks/run_benchmark.py

Benchmark result (this machine, 2026-11-29): 20/20 diagnoses correct, median diagnosis time 0.08s, total 8.64s for all 20 cases. Full table: benchmarks/BENCHMARK.md. Framing honesty: the "up to 3 hours" figure is the install guides' claim about manual first-time installs — it is not measured here; what is measured is the doctor's accuracy and speed on these fixtures.

License

MIT — see LICENSE.

Metadata

Release files for mcpdoctor-py 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mcpdoctor-py 0.1.1
File Size Uploaded Provenance Actions
mcpdoctor_py-0.1.1.tar.gz 31.4 kB With provenance Details for mcpdoctor_py-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mcpdoctor-py 0.1.1
File Interpreter ABI Platform Actions
mcpdoctor_py-0.1.1-py3-none-any.whl Python 3 none any Details for mcpdoctor_py-0.1.1-py3-none-any.whl

Total release size: 57.4 kB

Release files / mcpdoctor_py-0.1.1.tar.gz

Download URL mcpdoctor_py-0.1.1.tar.gz
Size 31.4 kB
Tags Source
SHA-256 checksum
How to use checksums
2c4359923e1d23d3f2aa2f00ba50818ad0717247edc36618c8c8b58e412cc6f9
BLAKE2b-256 checksum
How to use checksums
9a297c534c79d29338bfe5d85d4959da2028f1eb615d47a2df6828d0f74a93f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Release files / mcpdoctor_py-0.1.1-py3-none-any.whl

Download URL mcpdoctor_py-0.1.1-py3-none-any.whl
Size 26.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
429e6cf7060e6e832fce5d73daa3e5403989c7b438de10df147cfe1cbf5dfafb
BLAKE2b-256 checksum
How to use checksums
e1909cbf22b7cf8a2185b6481fc682b77cceedc3aa9b9f75fd48f298b0aee561
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Security for mcpdoctor-py 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for mcpdoctor_py-0.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page