Repository navigation
Description
Bug Description
The 2026-07-28 MCP spec clarifies client-credential binding: client credentials are bound to the authorization server that issued them — clients MUST key persisted credentials by the issuer identifier, MUST NOT reuse them with a different authorization server, and MUST re-register when the authorization server changes (SEP-2352). The spec also tightens authorization-response validation (iss per RFC 9207 — MCP clients MUST validate a present iss against the recorded issuer before redeeming the code, SEP-2468), resource-server discovery via Protected Resource Metadata (RFC 9728), and per-server Resource Indicators (RFC 8707).
OpenHands' OAuth token store and refresh logic key everything by server URL instead of issuer:
openhands-agent-server/openhands/agent_server/mcp_oauth_store.pybuilds FastMCP token-store keys like<server-url>/tokens,<server-url>/client_info,<server-url>/token_expiry(see_OAUTH_KEY_SPECS), and_find_matching_oauth_servermatches byserver.urlonly.openhands-sdk/openhands/sdk/mcp/oauth.py(MCPOAuth._refresh_token) happily refreshes against a discovered authorization-server metadata endpoint without recording/validating the issuer that minted the stored credentials.
Consequences under the new spec:
- If a server's authorization-server mapping changes (common with SSO providers, or a mirror/proxy standing in front of the same MCP endpoint), the stored token is reused against the new issuer — exactly what SEP-2352 forbids.
- There is no
issvalidation (RFC 9207) before code redemption, so a malicious/compromised authorization server can substitute its own token for a different issuer.
Expected Behavior
- Persist OAuth state keyed by the authorization-server issuer (e.g. the issuer identifier from authorization-server metadata), with the server URL as a secondary scope.
- Validate
isson authorization responses (RFC 9207 / SEP-2468) before redeeming the code; reject mismatches. - Use Protected Resource Metadata (RFC 9728) + Resource Indicators (RFC 8707) to scope tokens to the intended MCP server (the stack upgrade epic [Epic] MCP 2026-07-28 spec support: upgrade to mcp 2.x / fastmcp 4.x (stateless MCP, server/discover, per-request _meta) #6017 covers the SDK-level pieces).
Actual Behavior
- Token-store keys and refresh matching are per-server-URL (
mcp_oauth_store.py_OAUTH_KEY_SPECS,_find_matching_oauth_server); no issuer binding, noissvalidation.
Steps to Reproduce
- Configure an OAuth-protected MCP server (e.g. GitLab or Atlassian) and complete install-time OAuth — tokens stored under the server URL.
- Swap the auth gateway / authorization-server discovery URL (or point the same host at a different AS).
- Observe the stored token being reused against the new issuer without re-registration.
Acceptance Criteria
- OAuth credentials stored/retrieved by issuer identifier (with server-URL fallback for legacy persisted state)
-
issparameter validated per RFC 9207 before code redemption; mismatch raises instead of silently proceeding - Credentials never reused across a changed authorization server (SEP-2352)
Evidence and Additional Context
openhands-agent-server/openhands/agent_server/mcp_oauth_store.py(_OAUTH_KEY_SPECS,_find_matching_oauth_server)openhands-sdk/openhands/sdk/mcp/oauth.py(_discover_oauth_metadata— records metadata but not issuer binding)- Spec: https://modelcontextprotocol.io/specification/2026-07-28/changelog (Major Port over BashSession and tests #7 is OAuth; Minor Port over BashSession and tests #7 RFC 9207, Port over remaining tests for
str_replace_editor#9 SEP-2352 issuer-binding) - Related epic: [Epic] MCP 2026-07-28 spec support: upgrade to mcp 2.x / fastmcp 4.x (stateless MCP, server/discover, per-request _meta) #6017
This issue was filed by an AI agent (OpenHands) on behalf of branben.
Activity
all-hands-bot commentedon Oct 15, 2026
No exact or near-exact duplicate exists. The strongest overlap is the open umbrella epic #6017, whose acceptance criteria explicitly enumerate 'OAuth refresh keys by authorization-server issuer, not server URL (SEP-2352)' and whose desired-behavior item 5 covers issuer-bound credentials / RFC 9207 / RFC 9728 / RFC 8707 — i.e. the same root cause this issue reports. However, #6017 is a broad tracking epic (mcp 2.x/fastmcp 4.x upgrade, transport, result shapes), and #6019 is a concrete, reproducible sub-issue with its own acceptance criteria. Consistent with the sibling issue #6018 (same author, same filing burst, resolved by the bot as 'not an exact duplicate' of the epic, keep open but anchor in the epic), this should be treated as overlapping-scope rather than a duplicate and should not be auto-closed. The other OAuth issues (#6020, #5375, #5276, #5863, #5860) are related but distinct root causes (registration/CIMD, redirect URI, callback error handling).
Found 3 possible duplicate issues:
These may not be exact duplicates, but the scope appears to overlap enough that keeping discussion in one place may be more useful.
This comment was created by an AI assistant (OpenHands) on behalf of the repository maintainer.
all-hands-bot commentedon Oct 16, 2026
The following comments were added by the OpenHands AI agent.
Decision needed
I read the repository's root
AGENTS.md,CONTRIBUTING.md,openhands-agent-server/AGENTS.md,openhands-sdk/openhands/sdk/AGENTS.md, and.agents/skills/custom-codereview-guide.md, plus the code paths this issue names (mcp_oauth_store.py,openhands/sdk/mcp/oauth.py,openhands/sdk/mcp/config.py,mcp_router.py), the related epic #6017, and the pinned dependencies. One material scope decision cannot be inferred from that evidence, so this issue is not markedready-for-dev.What the repository evidence shows:
openhands-sdk/pyproject.tomlpinsfastmcp>=3.2.0,<4anduv.lockresolvesmcp 1.28.1.mcp 1.28.1has no issuer binding and no RFC 9207isshandling at all, and its authorization callback returns only(code, state)— there is noissto validate before code redemption.issvalidation exist only in themcp 2.xline (OAuthClientInformationFull.issuer,credentials_match_issuer,validate_authorization_response_iss). Reaching that line is the blocked stack upgrade in epic [Epic] MCP 2026-07-28 spec support: upgrade to mcp 2.x / fastmcp 4.x (stateless MCP, server/discover, per-request _meta) #6017 (mcp>=2/fastmcp>=4), which issue Unlocked installs resolve browser-use 0.11.13 with mcp 2.x — browser tools silently disappear #5152 (browser-use 0.11.xvsmcp 2.x) currently blocks.<server-url>/tokens,/client_info,/token_expiry) and still does so infastmcp 4.1.0;MCPSettingsOAuthTokenStoreis an adapter over those keys, so it cannot re-key persisted state by issuer independently of FastMCP.auto-close=false.Because the primary acceptance criteria here are only achievable on the upgraded stack that #6017 owns, the smallest coherent scope depends on your intent:
mcp 2.x/fastmcp 4.xupgrade?issvalidation cannot be implemented in this repository. Is the intended scope to wait for the upgrade, or something achievable now (for example persisting the discovered issuer alongside stored OAuth state, which would not by itself satisfy RFC 9207 validation before code redemption)?priority:low.branben commentedon Oct 16, 2026
Thanks for the thorough root-cause analysis — it matches our verification. Decisions (BLUF):
1. Stay open, anchored in #6017 as the repo-owned OAuth slice → yes.
This is the tracking issue for the issuer-keying slice (U5 in the epic plan). It stays open; the epic consumes it. Deliverable timing is tied to the stack upgrade — see point 2.
2. Deliverable before the upgrade → none; this is gated on
mcp>=2/fastmcp>=4.Confirmed: mcp 1.28.1 has no issuer binding and no RFC 9207
isshandling, and FastMCP owns the token-store key format (<server-url>/tokens,/client_info,/token_expiry) even in 4.1.0 — so issuer-keying genuinely cannot be implemented under the current pin. Scope: after the upgrade, re-keyMCPSettingsOAuthTokenStoreby authorization-server issuer (a suffix on the mcp 2.x base keys) and validateissper RFC 9207 before code redemption. No interim half-measure (e.g. persisting a discovered issuer alongside state) — it would not satisfy RFC 9207 and would be throwaway.3. Priority → keep
priority:low; hypothesis-backed, not reproduction-backed.Trigger is code-inspection inference (credential reuse after authorization-server change), not a confirmed user-triggered failure. We don't have a concrete provider + workflow reproduction. Revisit priority if/when a real user report lands.
This decision summary was prepared by an AI agent (OpenHands) on behalf of the issue author.