fix(mcp): handle oauth flows that connect without tokens#27785
Open
ImDevinC wants to merge 3 commits into
Open
fix(mcp): handle oauth flows that connect without tokens#27785ImDevinC wants to merge 3 commits into
ImDevinC wants to merge 3 commits into
Conversation
Treat MCP servers that can connect their transport without actually persisting OAuth credentials as still needing authentication. This keeps MCP auth state, CLI messaging, and the explicit startAuth flow aligned for issue anomalyco#5953. Fixes anomalyco#5953 Tested: - bun test test/mcp/oauth-auto-connect.test.ts test/mcp/oauth-browser.test.ts test/mcp/lifecycle.test.ts - bun typecheck - reviewed the MCP-only diff against CONTRIBUTING.md and .github/pull_request_template.md to confirm the change stays scoped to the auth fix and includes targeted regression coverage Co-authored-by: opencode <noreply@opencode.com>
Contributor
|
The following comment was made by an LLM, it may be inaccurate: Based on my search, I found a potentially related PR: Related PR:
The other OAuth-related PRs (#27068, #26854, #23572) are about different aspects of OAuth handling (discovery, scope metadata, callback server cleanup) and don't appear to be duplicates of the current fix. |
Collaborator
|
/review |
Stop persisting MCP auth records when only the server URL remains after credentials are invalidated. This keeps logout state aligned with actual OAuth material during the issue anomalyco#5953 fix. Tested: - bun test test/mcp/oauth-auto-connect.test.ts - bun typecheck Co-authored-by: opencode <noreply@opencode.com>
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.
Issue for this PR
Closes #5953
Type of change
What does this PR do?
This fixes the MCP OAuth path where a remote server can complete transport setup without ever persisting OAuth credentials. Instead of treating that as a successful auth, the MCP service now keeps the server in
needs_auth, surfaces a clearer CLI error, and preserves the explicitstartAuth()redirect flow for servers that can connect anonymously before OAuth is completed.How did you verify your code works?
I validated it with targeted MCP coverage:
bun test test/mcp/oauth-auto-connect.test.ts test/mcp/oauth-browser.test.ts test/mcp/lifecycle.test.tsbun typecheckXDG_DATA_HOME="$(mktemp -d)" "$HOME/Projects/opencode/packages/opencode/dist/opencode-darwin-arm64/bin/opencode" mcp auth slack --log-level DEBUGScreenshots / recordings
N/A, no UI changes.
Checklist