Repository navigation
fix(registry): match agent_url spec-exactly on the directory inverse-lookup - #8314
Merged
Merged
Conversation
…lookup
`GET /v1/agents/{agent_url}/publishers` ran its parameter through
`canonicalizeAgentUrl` — the registry IDENTITY key, which folds a non-root
trailing slash (#7830) — before calling `getPublishersForAgentDetail`. That
DB helper is spec-exact by design (it keys for the index, then restricts to
the raw `agent_url` spellings that match per #7829), but it was handed an
already-folded URL, so the fold decided the authorization answer:
- a request for `https://a.example/mcp/` was answered with
`https://a.example/mcp`'s publishers — an authorization the publisher's
adagents.json does not grant, and a direct disagreement with the
validator and with the sibling `/domains` route; and
- an agent whose publishers declared it WITH a trailing slash resolved for
neither spelling, because the folded lookup never matched its raw rows.
The key is now only a validity gate; the lookup takes the URL as the caller
wrote it, exactly as `/registry/lookup/agent/:agentUrl/domains` does. The
`agent_url` echo is the AdCP canonicalization of the request with the
trailing slash preserved, which is what docs/aao/directory-api.mdx has
always specified ("Canonicalized echo of the lookup key").
docs/aao/directory-api.mdx already documented slash-significant matching, so
this brings the implementation to the spec rather than changing it; the page
and the OpenAPI description now also record the behavior change for
consumers that had adapted to the folded answers.
Refs #7830, #7829.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
scripts/check-changeset-protocol-scope.cjs excludes static/openapi/registry.yaml and docs/aao from the protocol surface, so this registry behavior fix must not carry an `adcontextprotocol` changeset. The behavior change is recorded in docs/aao/directory-api.mdx and in the OpenAPI description instead. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Contributor
There was a problem hiding this comment.
Ladon verdict: Approve
Approve — fail-open authorization bug fixed on the AAO directory inverse-lookup route.
What was checked:
- The
/v1/agents/{agent_url}/publishersroute previously passedcanonicalizeAgentUrl(rawAgentUrl)(which folds/mcp/→/mcp) intogetPublishersForAgentDetail, so a/mcp/request answered with/mcp's publishers — reporting an authorization the publisher's adagents.json did not grant. The fix passesrawAgentUrlto the DB (keyed internally, restricted to spec-exact spellings) and keepscanonicalizeAgentUrlonly as a 400 validity gate. This is a fail-open→fail-closed change on a trust boundary. - Echo now uses
specExactAgentUrl(rawAgentUrl)at registry-api.ts:11382/11477/11510, preserving the slash. The?? rawAgentUrlfallback on an unconvertible U-label host is cosmetic and not load-bearing. - Change aligns
/publisherswith the sibling/domainsroute and the documented federated-index-db design; DB calls remain parameterized against gate-validated input. - Docs (directory-api.mdx), both OpenAPI descriptions, and the new 164-line integration test are mutually coherent; the test covers both spellings, both mounts, the reverse (slashless-declared) case, and echo canonicalization.
- No changeset required — platform/registry API behavior (static/openapi + docs/aao), not the AdCP wire surface under static/schemas/source/**.
Decision rationale: No critical/high/medium findings. gated_paths is false. high_risk is true but the only reason is a (modified) file (server/src/routes/**) with no medium-or-higher finding — presumed safe per the high-risk reading rules; does not trigger row 5 (no medium) or row 3 (no deletion). No author team gate. No prior decision. Falls through to row 9 → approve.
bokelley
added a commit
that referenced
this pull request
Oct 19, 2026
…e can ask the directory (#8316) The registry lists an agent once, under its folded identity key: `/mcp` and `/mcp/` are one agent (#7830). The directory answers authorization questions spec-exactly, trailing slash significant (#7829, #8314). Both rules are right, and together they left a hole on the public agents page: it asked `GET /v1/agents/${agent.url}/publishers` with the listed (folded) URL, so an agent whose publishers declared it as `/mcp/` showed "No indexed publisher authorizations" — the page was asking about a spelling no publisher wrote. `GET /api/registry/agents` now returns `declared_urls[]` per agent: the listed URL first, then the owner's registered spelling, then every raw `agent_url` the directory has indexed under that identity. One bulk query (`bulkDeclaredAgentUrls`) over `v_effective_agent_authorizations` for the whole page; a failure logs and falls back to the identity URL rather than failing the listing. The legacy `agent_publisher_authorizations` arm is not consulted — it is raw-matched with no canonical column, so its rows can only be found by the exact spelling the caller already has. agents.html splits the directory call out of the renderer into `fetchPublisherRecords`, asks once per declared spelling, and merges by publisher_domain with `authorized` beating `revoked`. A 404 for one spelling is an empty page, not an error — with several spellings it is the normal answer for all but one. The same split applies to the listing's own property enrichment: `getPropertiesForAgent` and `getPublisherDomainsForAgent` are spec-exact reads too, so a slash-declared agent showed no properties either. Both now run per declared spelling and merge. Single-spelling agents — nearly all of them — make exactly the same calls as before. `/publishers` itself is unchanged and stays spec-exact. Refs #7830, #7829. Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
This was referenced Oct 19, 2026
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.
Problem
GET /v1/agents/{agent_url}/publishers(and its/api/v1/...twin) ran itsparameter through
canonicalizeAgentUrl— the registry identity key,which folds a non-root trailing slash (#7830) — before calling
getPublishersForAgentDetail.That DB helper is spec-exact by design: it keys for the index and then
restricts to the raw
agent_urlspellings that match per #7829. But it washanded an already-folded URL, so the fold decided the authorization answer.
Two symptoms, in opposite directions:
https://a.example/mcp/was answeredwith
https://a.example/mcp's publishers — an authorization thepublisher's
adagents.jsondoes not grant, disagreeing withAgentValidatorand with the sibling/registry/lookup/agent/:agentUrl/domainsroute.
trailing slash resolved for neither spelling, because the folded lookup
value never matched its raw rows.
docs/aao/directory-api.mdxhas always specified the correct behavior —"Path case and a non-root trailing slash are significant —
/mcpand/mcp/are different agents" — so this brings the implementation to thespec rather than changing the spec.
Fix
canonicalizeAgentUrlbecomes a validity gate only (an input theregistry cannot key at all cannot name an indexed agent); the lookup takes
the URL as the caller wrote it, exactly as
/domainsdoes:The
agent_urlecho (200 body, 404 body, ETag input) is now the AdCPcanonicalization of the request — host lowercased, default port and dot
segments resolved — with the trailing slash preserved, which is what the
spec's "Canonicalized echo of the lookup key" means. It can no longer read
back as a different agent than the one that was matched.
The in-line comment records why the identity key must not become the lookup
value, so the next reader does not "simplify" it back.
Tests
server/tests/integration/registry-directory-publishers-spec-exact.test.ts(7 cases, over HTTP through
HTTPServer+ supertest):/publishersand/domainsreturn the same answer for both spellings(the invariant the maintainer asked for), including the mirrored fixture
where the authorization is declared without the slash — exactness has to
cut both ways;
/v1mount answers identically to/api/v1;Verified to fail without the fix: 5 of the 7 cases go red, covering both
the over-reporting and the under-reporting direction.
Also re-ran the adjacent suites green:
registry-directory-spec-exact(including its "agrees with the validator" case),
registry-api-agent-publishers,registry-agent-publishers-detail,registry-reader-baseline-public-endpoints,registry-identity-route-keying.Published-behavior notes
Since this changes answers consumers may have adapted to:
docs/aao/directory-api.mdx— a dated note under the endpointdefinition: through 2026-10-18 the directory folded the two spellings and
answered both with the slashless agent's publishers; matching is now
exact; a caller that asked with the wrong spelling now gets
404or200with an empty
publishers[], and should ask with the spelling thepublisher's
adagents.jsonlists. It also states the contrast that theregistry's own per-agent identity surfaces (compliance, badges,
monitoring) deliberately do fold — identity and authorization are separate
questions (fix(registry): key the requested URL on identity read routes #8312).
static/openapi/registry.yaml— regenerated from the zod source inregistry-api.ts; both path descriptions now state the matching rule andthe behavior change.
No changeset:
scripts/check-changeset-protocol-scope.cjsexcludesstatic/openapi/registry.yamlanddocs/aao/from the protocol surface, soa registry behavior fix must not carry an
adcontextprotocolbump (the pushhook rejects one). The two notes above are the record.
Known gap, unchanged here
server/public/agents.htmlfetches/v1/agents/${agent.url}/publishersusing the registry's identity URL, which is the folded (slashless) spelling.
For an agent whose publishers declared it with a trailing slash, that page
shows "no indexed publisher authorizations" — it did before this PR too
(the folded lookup never matched those rows either), so this is not a
regression, but it is now the visible remainder of the same split. Fixing it
means passing the declared spelling to the directory call, which needs the
agents listing to expose it. Flagging rather than widening this PR.
Refs #7830, #7829.
🤖 Generated with Claude Code
Open workspace in Conductor