Skip to content

fix(mcp): generate OAuth state on-the-fly during initial connection#16248

Open
jonahsnider wants to merge 1 commit intoanomalyco:devfrom
jonahsnider:fix-streamable-http-mcp-auth
Open

fix(mcp): generate OAuth state on-the-fly during initial connection#16248
jonahsnider wants to merge 1 commit intoanomalyco:devfrom
jonahsnider:fix-streamable-http-mcp-auth

Conversation

@jonahsnider
Copy link

Issue for this PR

Closes #16247

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

When connecting to a remote MCP server requiring OAuth, the SDK's auth flow calls provider.state() to get the state parameter.
This method was throwing when no state had been pre-generated, causing a non-UnauthorizedError that prevented the server from being recognized as needing auth.
The error fell through to the SSE transport fallback, which also failed, resulting in a generic "Non-200 status code" status instead of needs_auth.

How did you verify your code works?

Following the reproduction steps in #16247, you'll see that the TUI properly marks the server as needing authentication, rather than having an SSE transport error:

Screenshot of /status in OpenCode TUI

Screenshots / recordings

N/A - not a UI change

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions
Copy link
Contributor

github-actions bot commented Mar 6, 2026

The following comment was made by an LLM, it may be inaccurate:

Based on the search results, I found a potentially related PR:

Related PR:

The search also returned several other OAuth-related PRs (#11477, #11925, #13085, #9034) but these appear to be feature additions rather than duplicate fixes for the same issue.

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.

Unauthenticated streamable HTTP MCP servers are reported as SSE errors instead of missing auth

1 participant