fix(opencode): support proxied MCP OAuth callbacks#31013
fix(opencode): support proxied MCP OAuth callbacks#31013rev-rwasilewski wants to merge 1 commit into
Conversation
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: Potential Related PR Found:PR #30022:
|
|
Worth noting: MCP OAuth servers deployed behind AWS WAF with This affects both Dynamic Client Registration ( RFC 8252 §7.3 recommends using Relevant AWS docs: AWS Managed Rules - Common Rule Set It would be good to make sure the default redirect URI in this refactor uses |
Issue for this PR
Closes #31014.
Related to #7377, #18955, and #23787.
Type of change
What does this PR do?
This fixes MCP OAuth for environments where the browser reaches OpenCode through a public/proxied URL, but OpenCode still needs to listen on a local callback server. One example is OpenCode running inside a JupyterHub user server or another proxied container environment, where the browser sees a public URL that forwards back to the local callback listener.
Before this change,
oauth.redirectUriwas used for both the provider-facing OAuth redirect URI and for choosing the local callback listener port/path. That works for simple localhost flows, but breaks proxied setups.This separates the two concerns:
redirectUristays as the OAuth provider redirect URI, and is used by the MCP SDK for authorization and token exchange.callbackPort/callbackPathcontrol the local callback listener when using a public/non-local redirect URI.redirectUribehavior is preserved unlesscallbackPathis set.How did you verify your code works?
bun test test/mcp/oauth-provider.test.ts test/mcp/oauth-callback.test.ts test/mcp/oauth-auto-connect.test.ts --timeout 30000frompackages/opencodebun typecheckfrompackages/opencodebun turbo typecheckhook successfullyScreenshots / recordings
N/A, CLI/OAuth behavior only.
Checklist