Skip to content

Add MCP discovery readiness and gateway protocol diagnostics#71

Merged
lbliii merged 8 commits into
mainfrom
codex/mcp-saga-readiness
May 30, 2026
Merged

Add MCP discovery readiness and gateway protocol diagnostics#71
lbliii merged 8 commits into
mainfrom
codex/mcp-saga-readiness

Conversation

@lbliii

@lbliii lbliii commented May 30, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add server/discover support and explicit unsupported protocol-version repair data for MCP clients preparing for stateless negotiation
  • Teach the gateway to probe child CLIs, record negotiated protocol mode/version, and surface that status in --status
  • Update milo verify, docs, scaffold tests, and the greet example to cover the new discovery path and compatibility matrix

Testing

  • make lint
  • make docs-test
  • Focused MCP, gateway, child-process, scaffold, and verifier test suites passed
  • make test-cov reached the coverage floor; one unrelated free-threading stress test was flaky on full-suite reruns but passed when rerun directly under PYTHON_GIL=0

Copilot AI review requested due to automatic review settings May 30, 2026 14:11
@github-actions

Copy link
Copy Markdown

Coverage Report

88.2% overall coverage

File Coverage
src/milo/\_\_init\_\_.py 100.0%
src/milo/\_cells.py 85.9%
src/milo/\_child.py 89.3%
src/milo/\_cli\_help.py 90.5%
src/milo/\_command\_defs.py 99.2%
src/milo/\_compat.py 63.3%
src/milo/\_errors.py 92.8%
src/milo/\_jsonrpc.py 82.6%
src/milo/\_mcp\_router.py 98.0%
src/milo/\_protocols.py 100.0%
src/milo/\_scaffold/\_\_init\_\_.py 100.0%
src/milo/\_types.py 100.0%
src/milo/app.py 58.9%
src/milo/cli.py 87.3%
src/milo/commands.py 89.3%
src/milo/completions.py 96.0%
src/milo/components\_cli.py 88.1%
src/milo/config.py 87.3%
src/milo/context.py 86.6%
src/milo/dev.py 91.9%
src/milo/doctor.py 89.9%
src/milo/flow.py 96.5%
src/milo/form.py 91.7%
src/milo/gateway.py 73.0%
src/milo/groups.py 93.5%
src/milo/help.py 100.0%
src/milo/input/\_\_init\_\_.py 100.0%
src/milo/input/\_platform.py 77.8%
src/milo/input/\_reader.py 96.2%
src/milo/input/\_sequences.py 100.0%
src/milo/live.py 0.0%
src/milo/llms.py 78.8%
src/milo/mcp.py 89.5%
src/milo/middleware.py 100.0%
src/milo/observability.py 100.0%
src/milo/output.py 90.5%
src/milo/pipeline.py 90.1%
src/milo/plugins.py 100.0%
src/milo/reducers.py 100.0%
src/milo/registry.py 89.1%
src/milo/schema.py 92.7%
src/milo/state.py 91.7%
src/milo/streaming.py 100.0%
src/milo/templates/\_\_init\_\_.py 100.0%
src/milo/testing/\_\_init\_\_.py 100.0%
src/milo/testing/\_mcp.py 100.0%
src/milo/testing/\_record.py 86.7%
src/milo/testing/\_replay.py 87.1%
src/milo/testing/\_snapshot.py 100.0%
src/milo/theme.py 100.0%
src/milo/verify.py 83.2%
src/milo/version\_check.py 60.6%

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/discover responses (supported versions, capabilities, server info, instructions) for both leaf MCP server and gateway.
  • Add explicit -32004 unsupported protocol-version error data (supported, requested) and enforce _meta protocol-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.

Comment thread src/milo/_child.py Outdated
import time
from typing import Any

from milo._jsonrpc import MCP_PROTOCOL_VERSION_META_KEY, MCP_VERSION
Comment thread src/milo/_child.py Outdated

def _try_stateless_from_discover(self, response: dict[str, Any]) -> bool:
error = response.get("error")
if isinstance(error, dict) and error.get("code") == -32004:
@lbliii lbliii merged commit 1f53708 into main May 30, 2026
7 checks passed
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