fix(keycardai-starlette): stop rewriting the proxied authorization_endpoint (SDK-3) - #316
Merged
Merged
Conversation
…dpoint (SDK-3) The authorization-server metadata proxy returned the upstream document with resource=<origin> appended to authorization_endpoint, a shim for MCP clients on the 2025-03-26 authorization spec. The proxy now returns the upstream document unmodified, per keycard-sdk-spec oauth-metadata-endpoints spec-version 2. Co-Authored-By: Larry Osakwe <larry@keycard.ai>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
…14.2 keycardai-mcp re-exports the starlette metadata handlers and its tests now pin the unmodified AS-proxy document, which keycardai-starlette 0.14.2 is the first release to ship. The sibling-floors job skips this floor under the floors-bootstrap label until that version is on PyPI. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Larry-Osakwe
approved these changes
Sep 16, 2026
Larry-Osakwe
left a comment
Contributor
There was a problem hiding this comment.
Starlette proxy returns the parsed upstream document as is, helper and urllib imports gone, docstring updated, and the pass-through test pins an existing query verbatim. Matches oauth-metadata-endpoints.md spec-version 2. I pushed 4e9232e raising keycardai-mcp's starlette floor to 0.14.2, since the mcp tests now pin behavior only that release ships; the floors-bootstrap label covers the sibling-floors leg until 0.14.2 is on PyPI, and a keycardai-mcp patch bump follows it.
This was referenced Sep 16, 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.
Summary
Retires a compatibility shim aimed at MCP clients on the 2025-03-26 authorization spec.
authorization_server_metadatainkeycardai-starletteproxied the zone's RFC 8414 document and appendedresource=<request origin>to the upstreamauthorization_endpoint. The proxy now returns the parsed upstream document unchanged;authorization_endpointpasses through byte for byte, including any query it already carries. This implements keycard-sdk-specspecs/server-bearer-auth/oauth-metadata-endpoints.mdspec-version 2 (keycardai/keycard-sdk-spec#65, SDK-3).Why: the MCP 2025-06-18 authorization spec made the RFC 8707
resourceparameter mandatory for clients, and those clients fetch AS metadata from the issuer directly, so they never see the proxy. The rewrite reached only the 2025-03-26 generation, which the MCP spec retired in June 2025. Where it did fire, it produced tokens withaudequal to the bare request origin while the recommended verifier configuration binds the audience to the full endpoint, so a client following our own discovery got a token our own verifier rejected. Both packages are pre-1.0; this ships as a fix-level change.Code:
The
urllib.parseimports go with the helper;get_base_urlstays (still used by the protected-resource handler). Theauthorization_server_metadatadocstring now says the document is returned unmodified.Tests:
packages/starlette/tests/.../test_routers.py:test_authorization_endpoint_gains_resource_paramandtest_authorization_endpoint_preserves_existing_queryare replaced bytest_upstream_document_passed_through_unmodified, where upstream already carries?resource=stale&keep=1and the whole document is asserted equal to upstream (spec Unit Tests row 4).test_no_authorization_endpoint_left_unchangedstays.packages/mcphas no separate implementation (keycardai.mcp.server.routersre-exports the starlette handlers), but its handler and integration tests pinned the rewrite through the re-export, sotests/keycardai/mcp/server/handlers/test_metadata.pyandtests/integration/test_metadata.pynow assert the verbatim upstream value;test_authorization_endpoint_preservationgains the?resource=stale&keep=1case. No mcp source changes.No version or CHANGELOG edits; historical CHANGELOG entries are left as they are.
Verification
just check: All checks passed.just typecheck: All checks passed (all seven packages).packages/starlettetests: 121 passed.packages/mcptests: 564 passed, 18 skipped, 2 failed. Both failures (tests/integration/test_auth_provider.py::TestAuthProviderInitialization::test_auth_provider_init_with_zone_id,tests/integration/test_web_identity.py::TestWebIdentity::test_no_application_credential_does_enable_registration) fail identically on currentmainwith this change stashed; they are unrelated to metadata and not touched here.Link to Devin session: https://app.devin.ai/sessions/bbc062cf32b548ef9c4b8b444d2ec67f
Open in Devin Desktop: https://app.devin.ai/desktop/session/bbc062cf32b548ef9c4b8b444d2ec67f?variant=devin
Requested by: @Larry-Osakwe