Skip to content

feat(mcp): test every enabled MCP server with one command - #313

Merged
Zongwei9888 merged 1 commit into
HKUDS:mainfrom
raymondginger2018-sudo:pr/mcp-test-all
Nov 23, 2026
Merged

Zongwei9888 merged 1 commit into
HKUDS:mainfrom
raymondginger2018-sudo:pr/mcp-test-all

Conversation

@raymondginger2018-sudo

Copy link
Copy Markdown
Contributor

Summary

deepcode mcp test <name> performs a real handshake for a single server. Checking a whole configuration therefore means running it once per server and reading each exit code — exactly the loop a startup check or a CI job has to write itself.

mcp test --all walks the effective inventory and probes every enabled server, then prints one summary and returns one exit code.

Changes

  • cli/mcp_cli.py — test takes an optional <name> plus --all; exactly one is required (neither/both exits 2). The --all path reuses McpService.probe per enabled server and prints through a new _print_probe_all.
  • core/application/views.py — mcp_probe_all_view aggregates per-server mcp_probe_view results into {ok, total, failed, servers[]}.
  • tests/test_mcp_cli.py — three cases: aggregation across enabled servers, disabled servers skipped, argument validation.

mcp test <name> is unchanged. The loop calls the same probe, so per-server startup timeouts, credential resolution and OAuth handling are untouched.

Output

$ deepcode mcp test --all
PASS  fixture: 3 tools, 1 resources, 1 prompts in 0.412s
FAIL  broken: connection failed: ...
1 passed, 1 failed of 2 enabled MCP servers.
$ echo $?
1

With --json:

{
  "ok": false,
  "total": 2,
  "failed": 1,
  "servers": [
    {"name": "fixture", "ok": true, "toolCount": 3, "resourceCount": 1, "promptCount": 1, "elapsedSeconds": 0.412, "error": null},
    {"name": "broken", "ok": false, "toolCount": 0, "resourceCount": 0, "promptCount": 0, "elapsedSeconds": 0.003, "error": "..."}
  ]
}

Tests

  • tests/test_mcp_cli.py: 11 passed (8 existing + 3 new).
  • ruff 0.15.21 (the version pinned in .pre-commit-config.yaml): check and format --check both clean.

Notes

  • Disabled servers are skipped — they are not started in a session either.
  • A configuration with no enabled servers reports total: 0 and exits 0.
  • Probes run sequentially on purpose: each one spawns (or connects to) a server process, and a batch mode that fans out would change load characteristics for servers that are already running in the session.

`deepcode mcp test <name>` performs a real handshake for one server. Checking a
whole configuration means running it once per server and reading each exit code,
which is exactly the loop a startup check or a CI job has to write. `mcp test
--all` walks the effective inventory, probes every enabled server, and reports
one summary:

    PASS  fixture: 3 tools, 1 resources, 1 prompts in 0.412s
    FAIL  broken: connection failed: ...
    1 passed, 1 failed of 2 enabled MCP servers.

The single-server path is unchanged (`mcp test <name>`); passing neither or both
is rejected with exit 2. `--json` emits {ok,total,failed,servers[]} so callers
can assert on it. Probes reuse McpService.probe, so per-server timeouts,
credential resolution and OAuth are unchanged.

Tests: tests/test_mcp_cli.py gains three cases (failure aggregation across
enabled servers, disabled servers skipped, argument validation); the file runs
11 passed and ruff 0.15.21 (check + format) is clean.
@Zongwei9888
Zongwei9888 merged commit 1e9df27 into HKUDS:main Nov 23, 2026
12 checks passed
@Zongwei9888

Copy link
Copy Markdown
Contributor

Thanks @raymondginger2018-sudo, merged on 2026-11-23 as 1e9df27. mcp test --all is a useful startup/CI check.

We added one follow-up (97713dd):

  • A server that cannot be probed no longer stops the whole run with exit 2. It is reported as FAIL and the other servers are still tested. A project entry blocked because the workspace is not trusted is reported with its blocking reason, and a malformed entry, which makes the resolver reject the whole layer, gives a FAIL line for every server. Both cases have tests.
  • Ctrl-C now stops --all. probe_mcp_server caught BaseException, so it turned the cancellation from asyncio.run into a failed result, and the loop went on to the next server. The probe now re-raises when its own task is being cancelled, and deepcode mcp exits 130 on Ctrl-C like the other commands. A cancellation that comes from the server side is still reported as a failure.
  • docs/integrations/MCP.md documents --all, and notes that without --workspace it tests the user-level servers only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants