Add MCP discovery readiness and gateway protocol diagnostics#71
Merged
Conversation
Coverage Report✅ 88.2% overall coverage
|
There was a problem hiding this comment.
Pull request overview
Adds MCP “discovery readiness” to Milo’s leaf server and gateway, enabling probe-first/stateless-oriented clients to detect supported protocol versions and receive explicit repair data when a request declares an unsupported _meta protocol version.
Changes:
- Implement
server/discoverresponses (supported versions, capabilities, server info, instructions) for both leaf MCP server and gateway. - Add explicit
-32004unsupported protocol-version error data (supported,requested) and enforce_metaprotocol-version validation in the shared MCP router. - Update gateway child negotiation to probe discovery first and surface negotiated child protocol mode/version in
--status, plus expand verifier/scaffold/docs/tests to cover the new discovery check.
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_verify.py | Updates verify expectations to 7 checks and validates mcp_discover behavior. |
| tests/test_scaffold.py | Updates scaffolded suite expected pass count. |
| tests/test_mcp_transport.py | Adds transport-level tests for server/discover and -32004 repair data. |
| tests/test_mcp_router.py | Adds routing for server/discover and validates unsupported _meta protocol version rejection. |
| tests/test_mcp_handler.py | Adds handler-level coverage for server/discover. |
| tests/test_mcp_compat_docs.py | New regression tests ensuring docs mention compatibility matrix and repair fields. |
| tests/test_gateway.py | Adds gateway server/discover test and status output coverage for child protocol diagnostics. |
| tests/test_child.py | Updates/expands child process tests for discovery probing, protocol mode/version tracking, and error recording. |
| tests/test_ai_native.py | Adds discovery coverage across CLI and gateway dispatch paths. |
| src/milo/verify.py | Adds a new mcp_discover check and extends subprocess transport check to include discovery. |
| src/milo/mcp.py | Implements server/discover, centralizes server capabilities/info, and maps unsupported protocol exceptions to -32004 with data. |
| src/milo/gateway.py | Implements gateway server/discover, adds child protocol diagnostics to --status, and returns structured error data for unsupported protocol. |
| src/milo/_scaffold/default/tests/test_app.py | Scaffold tests now assert server/discover exposes supported versions. |
| src/milo/_scaffold/default/README.md | Updates scaffold docs to mention discovery coverage and the extra verify check. |
| src/milo/_mcp_router.py | Adds server/discover dispatch and _meta protocol-version validation with a dedicated exception type. |
| src/milo/_jsonrpc.py | Introduces shared protocol constants: supported versions, _meta key, and -32004 error code. |
| src/milo/_child.py | Adds discovery-first negotiation for child CLIs, tracks protocol mode/version, and records last error for diagnostics. |
| site/content/docs/get-started/quickstart.md | Updates quickstart verify output/examples to include mcp_discover. |
| site/content/docs/build-clis/mcp.md | Documents discovery support, -32004 repair data, and a compatibility matrix. |
| examples/greet/tests/test_greet.py | Example tests now cover server/discover contract. |
| docs/agent-quickstart.md | Updates agent quickstart verify output and documents the -32004 repair workflow. |
| changelog.d/stateless-mcp-readiness.added.md | Changelog entry for discovery support and explicit unsupported-version errors. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| import time | ||
| from typing import Any | ||
|
|
||
| from milo._jsonrpc import MCP_PROTOCOL_VERSION_META_KEY, MCP_VERSION |
|
|
||
| def _try_stateless_from_discover(self, response: dict[str, Any]) -> bool: | ||
| error = response.get("error") | ||
| if isinstance(error, dict) and error.get("code") == -32004: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
server/discoversupport and explicit unsupported protocol-version repair data for MCP clients preparing for stateless negotiation--statusmilo verify, docs, scaffold tests, and the greet example to cover the new discovery path and compatibility matrixTesting
make lintmake docs-testmake test-covreached the coverage floor; one unrelated free-threading stress test was flaky on full-suite reruns but passed when rerun directly underPYTHON_GIL=0