Skip to content

fix(mcp): preserve refresh credentials when callback URL changes - #1

Merged
neubig merged 2 commits into
2Zest:codex/mcp-oauth-public-callbackfrom
neubig:fix/mcp-oauth-refresh-preserve-client
Nov 15, 2026
Merged

neubig merged 2 commits into
2Zest:codex/mcp-oauth-public-callbackfrom
neubig:fix/mcp-oauth-refresh-preserve-client

Conversation

@neubig

@neubig neubig commented Nov 15, 2026 •

Copy link
Copy Markdown

Why

Follow-up to OpenHands#6221. Changing the public callback URL must not require consent again while the installed client's refresh token is still usable.

Summary

  • ff76595b7f6528e202bb7cb8d05c9732fe1daacd: failing regression test, pushed before the fix.
  • 039452194: defer the redirect-registration check until fresh authorization; use FastMCP's existing one-time stale-client retry.
real loopback OAuth sign-in → save issued credentials
expire access token → supply public callback URL
before: discard client → register again → authorization URL
 after: retain client → refresh token → tools, no consent

The test uses a real FastMCP OAuth provider and the agent-server start/status APIs. Only the saved expiry is advanced; tokens and registration come from a complete authorization-code exchange. It verifies tool discovery, retained client identity, new expiry, no extra registration, and provider-side refresh-token rotation.

How to Test

uv run pytest tests/agent_server/test_mcp_oauth_redirect.py -q

Before fix: new regression fails at assert "authorization_url" not in started (reproduced twice). Baseline: 17 passed. After fix: all 18 redirect tests pass, including re-registration when fresh authorization is necessary. Wider related suite is running.

Ruff, pycodestyle, import guards and pyright --project pyproject.toml pass for both changed files. The default local pyright hook finds an unrelated /tmp/pyrightconfig.json; its project-explicit equivalent passes. Tests use existing compatible dependencies, not a new environment sync; upstream CI remains necessary for the locked full environment.

Scope

Base is the branch of upstream PR OpenHands#6221, not main. Merge this follow-up into that branch before merging the upstream SDK PR. Canvas PR OpenHands/OpenHands#19744 needs no code change for this regression. No release versions, settings, or API contracts change here.

This PR was created by an AI agent (OpenHands) on behalf of Graham Neubig.

Co-authored-by: openhands <openhands@all-hands.dev>
Keep the installed client available for refresh. Reuse FastMCP stale-client retry only when a new authorization flow needs another redirect URI.

Co-authored-by: openhands <openhands@all-hands.dev>
@neubig
neubig merged commit 0394521 into 2Zest:codex/mcp-oauth-public-callback Nov 15, 2026
2 checks passed
@neubig

neubig commented Nov 15, 2026

Copy link
Copy Markdown
Author

The failing-test commit ff76595b7 was pushed before fix commit 039452194. The original SDK PR branch has now been fast-forwarded with both commits; GitHub automatically recognized this follow-up as merged. Independent review found no material defect and independently reran all 18 redirect tests successfully. The authenticated account cannot approve its own follow-up PR; the original SDK PR has instead received an APPROVE review after integration. No main branch was changed.

This comment was created by an AI agent (OpenHands) on behalf of Graham Neubig.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants