feat(server): /.well-known/adcp-agents.json discovery endpoint#404
Draft
feat(server): /.well-known/adcp-agents.json discovery endpoint#404
Conversation
Implements AdCP spec PR #3903 (commit 5c3e3e626). Sellers now serve a dynamic multi-agent topology document on all three transport modes; buyers can discover it via fetch_adcp_agents(). - serve() exposes /.well-known/adcp-agents.json on streamable-http, a2a, and both transports via a thin ASGI wrapper injected before auth middleware - Document is generated at request time from get_tools_for_handler() so per-instance capability filters are always accurate; comply_test_controller is excluded from the public surface - BearerTokenAuthMiddleware.dispatch() now bypasses auth for GET /.well-known/ requests (spec-mandated public discovery; JSON-RPC peek was silently 401ing these requests before) - fetch_adcp_agents(agent_base_url) client-side helper mirrors fetch_adagents() with SSRF-safe URL construction - AdcpAgentsNotFoundError and AdcpAgentsValidationError added to exceptions hierarchy with context-correct suggestion text - 16 smoke tests cover all three transports, advertise_all gating, comply_test_controller exclusion, and client-side 200/404 paths Note: CI schema validation against adcp-agents.json requires sync_schemas.py to pull the upstream schema once adcontextprotocol/adcp PR #3903 releases. Refs #381 https://claude.ai/code/session_01S3J5mFsF94rDjmrhNg8G8a
- Add AdcpAgentsTimeoutError to exceptions hierarchy (namespace fix) - Add SSRF protection to fetch_adcp_agents: validates scheme (http/https only) and rejects private/reserved IPs and localhost before making any network call - Remove shadow urlparse import inside fetch_adcp_agents; use module-level urlparse - Raise AdcpAgentsTimeoutError instead of AdagentsTimeoutError on timeout - Export AdcpAgentsTimeoutError from adcp.__init__ and update __all__ - Extract _send_adcp_agents_response() helper to eliminate duplicate response-assembly code in serve.py - Move import json to module level in serve.py - Add 5 new tests: SSRF rejection, timeout namespace, auth middleware bypass, and update public API snapshot https://claude.ai/code/session_01S3J5mFsF94rDjmrhNg8G8a
5 tasks
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
Implements the
/.well-known/adcp-agents.jsonmulti-agent topology discovery endpoint per AdCP spec PR #3903 (commit5c3e3e626).streamable-http,a2a, andbothtransports. Document is generated at request time (not cached) so per-instance capability filters and flag-gated features are always current.BearerTokenAuthMiddlewareexemptsGET /.well-known/*before reading the request body, keeping discovery unauthenticated per spec.fetch_adcp_agents(agent_base_url)fetches and validates a seller's topology doc. SSRF-protected: rejects non-http/https schemes, private/reserved IPs, and localhost.AdcpAgentsValidationError,AdcpAgentsNotFoundError,AdcpAgentsTimeoutError— all exported fromadcptop-level.advertise_allgating;comply_test_controllerexclusion; auth middleware bypass; SSRF rejection; timeout namespace.Document shape (conservative, spec-aligned)
{ "adcp_version": "3.0", "agents": [ { "name": "my-seller", "capabilities": ["get_products", "create_media_buy"] } ] }Test plan
pytest tests/test_adcp_agents_discovery.py -v— 19 passedpytest tests/ -q(excluding network test) — 3096 passed, 0 new failuresruff check src/— all checks passedmypy src/adcp/— no new errors (pre-existing missing-stubs errors unchanged)tests/fixtures/public_api_snapshot.json)Pre-PR review sign-offs
Refs #381
https://claude.ai/code/session_01S3J5mFsF94rDjmrhNg8G8a
Generated by Claude Code