feat(mcp_registry): #201 PR 4 of 5. HTTPMCPServerRegistryBackend read paths + tier negotiation#333
Merged
Merged
Conversation
… paths + tier negotiation Ships the HTTP-catalog reference implementation for the MCPServerRegistryBackend Protocol arc with read paths (list / load / load_all / validate) + tier-1/2/3 capability negotiation + httpx exception mapping + conformance suite parametrize. Install / uninstall write paths land at PR 5. Closes 36 prep-pass findings (8 P0, 18 P1, 10 P2 from 5-stream Sonnet prep pass) BEFORE implementation and 8 pre-landing P0 / P1 findings AFTER implementation (RuntimeError on closed client race, OPTIONS non-404 / 405 silent fallback, catalog_url query-string normalization, MCPServerRef.source spec compliance, validate() 404 message wording, factory ValueError credential redaction, MCPServerRef.from_dict version normalization, plus import + URL-normalization cleanups). Test delta: +75 net new (3232 -> 3307 collected; 3248 passed, 59 skipped, 0 regressions). PR 4 extends the post-#285-revert /ship streak to 11. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Reflects that HTTPMCPServerRegistryBackend read paths + tier negotiation shipped in PR 4; table row was still showing "Planned" / #201 link. Updates to in-progress status with spec/36 link and accurate capability description. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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
Ships the HTTP-catalog reference implementation for the
MCPServerRegistryBackendProtocol (#201 PR 4 of 5):atomic_agents/mcp_registry/http.pyNEW (~1050 lines):HTTPMCPServerRegistryBackendwith read paths (list/load/load_all/validate), tier-1/2/3 capability negotiation via the Decision 4 five-step probe, threading-locked capability cache, per-request bearer auth headers, full httpx exception mapping, response-body shape validation against catalog-server injection, and the bulk?expand=specendpoint that eliminates N+1 round trips at agent construction (MUST 10). Install/uninstall stubs raiseNotImplementedErroruntil PR 5.MCPServerSpec.to_dict()/from_dict()promoted to public methods on the dataclass inatomic_agents/mcp.pyso the HTTP backend can deserialize wire JSON without depending onprofile/types.pyprivate helpers. The helpers inprofile/types.pynow delegate to the class methods (backward-compat preserved).httpbranch added toget_default_mcp_server_registry_backendinmcp_registry/__init__.py. Operators setATOMIC_AGENTS_MCP_SERVER_REGISTRY_BACKEND=httpplusATOMIC_AGENTS_MCP_SERVER_REGISTRY_BACKEND_URL=https://catalog/?agent_scope=...and optionallyATOMIC_AGENTS_MCP_SERVER_REGISTRY_AUTH_TOKEN=...to wire the HTTP backend without touching code.[http]optional extra (httpx>=0.27) added topyproject.toml. Filesystem-default operators pay zero httpx import cost (lazy import inside the http branch).httpfactory env-var documentation.Workflow validation: 5-stream Sonnet prep pass caught 36 findings (8 P0, 18 P1, 10 P2) before any code shipped; the pre-landing /ship review army (5 specialists + Claude adversarial + Step 9 checklist) surfaced 34 follow-up findings of which 8 P0 / P1 were applied inline before push. See the Pre-Landing Review section for the full list.
Test Coverage
Pre-Landing Review
Pass 1 (CRITICAL): No findings. PR 4 has no SQL changes, no LLM prompt changes, no schema breaks, no audit-trail shape changes.
Pass 2 (INFORMATIONAL): 34 findings from the review army; 8 P0 / P1 fixed inline before push, 10 P2 cleanup applied, ~12 P3 deferred as documented in spec/36 §"Reserved at lock" + new follow-up tracking.
Cross-confirmed P0 fixes applied:
MCPRegistryUnavailablein all 5 except blocks. The adversarial reviewer cited this as "the most exploitable finding" because a reader holdingself._real_clientoutside_client_lockagainst a concurrentclose()would surface a rawRuntimeErrorbypassing the MCPRegistry contract.MCPRegistryAuthRequired; 5xx and other 4xx raiseMCPRegistryUnavailable. A misconfigured token would have silently downgraded a tier-3 server to tier-1.catalog_urlper spec/36 line 228 (the redactor aggressively strips after://even when no credentials present, breaking downstream navigation). Recommended operator pattern isauth_tokenenv var, not URL-embedded credentials.__init__(strip trailing slashes AND query string). Maintainability M4 (six.rstrip('/')sites collapsed into one)._redact_url_for_errorper the PR 1 P0 redaction discipline.P1 test additions:
MCPServerSpec.to_dict / from_dictpublic round-trip + extra-key forward-compat + required-keyKeyErrorhttpx.InvalidURLstrict assertion via injected MockTransport (was accepting bothValueErrorandMCPRegistryUnavailable; mapping not verified)args/env/descriptionhttpx.DecodingErrormapping testagent_scopequery-param forwarding verificationValueErrorand env-var auth-token readP2 mechanical cleanup:
from dataclasses import replaceto top-level (M5), redundanturlencodeimport removed (M6),validate()404 message rewording to honestly reflect spec ambiguity (A-F2),MCPServerRef.from_dictversion=""normalization (A-F5),_ensure_probeddocstring concurrent-first-call note (R-F6), README + CLAUDE.md test counts (3232 → 3307).P3 deferred (file-tracked or naturally rolled into PR 5):
__all__exports for HTTP backend (aligned with[redis]precedent; not exported)wire_versionforward-compat warning (deferred to v1.1)Plan Completion
Plan Completion Audit: 25 / 25 DONE, 0 partial, 0 deferred, 0 unverifiable.
atomic_agents/mcp_registry/http.pycreated withHTTPMCPServerRegistryBackend(read paths + write stubs)_http_clienttest seam_get_httpx()sentinel;__init__is side-effect-free (MUST 2)probe_failure_cache_s=60.0distinct fromrequest_timeout_s=10.0auth_tokennever in error messagesMCPServerRef.sourceuses raw catalog URL per specsupports_install=False, supports_uninstall=False, supports_capability_handshake=Trueinstall/uninstallraiseNotImplementedError(PR 5 TODO comment)make_http_mcp_server_registry_backend_from_urlfactoryregister_mcp_server_registry_backend("http", ...)at module bottomhttpbranch inmcp_registry/__init__.py[http] = ["httpx>=0.27"]inpyproject.tomlMCPServerSpec.to_dict()/from_dict()promoted to public methodsprofile/types.pyhelpers delegate to class methods (backward compat preserved)tests/test_mcp_server_registry_http_backend.pyNEW (54 tests; spec target was ~31)paramsflipped to["filesystem", "http"]on both fixturespopulated_backendfixture HTTP branch with 3-server MockTransport catalog[Unreleased]entry for PR 4Documentation
README.md: Backend protocols table row for
MCPServerRegistryBackendupdated fromPlannedto🟡 In progress (PR 4 of 5)with the new HTTP reference impl listed alongside filesystem. Test count refreshed (3,232 → 3,307).CHANGELOG.md:
[Unreleased]entry coversHTTPMCPServerRegistryBackend, tier negotiation,[http]extra (httpx>=0.27),MCPServerSpec.to_dict / from_dictpromotion, test delta+75, and/shipstreak extension to 11.CLAUDE.md: Test count refreshed to 3,307 collected. Architecture diagram shows
MCPServerRegistry 🟡matching PR 4 of 5 in-progress state.docs/spec/36-mcp-server-registry-backend.md: Four new PR 4 subsections all present (§HTTP wire format with Required/Optional field tables, §Tier negotiation, §Capability handshake, §Per-scope filtering) plus updated §Exception surface (httpx mapping table) and §Default factory (env-var documentation).
Test plan
tests/test_mcp_server_registry_*.py: 216 passed, 9 skippedruff check+ruff format --checkclean on all PR 4 files.github/workflows/test.yml)__init__test_concurrent_first_probes_both_succeedverifies D-PR4-3 design🤖 Generated with Claude Code