Skip to content

fix(mcp): start OAuth when initialize succeeds without tokens#36352

Open
Epochex wants to merge 1 commit into
langgenius:mainfrom
Epochex:fix/mcp-oauth-discovery
Open

fix(mcp): start OAuth when initialize succeeds without tokens#36352
Epochex wants to merge 1 commit into
langgenius:mainfrom
Epochex:fix/mcp-oauth-discovery

Conversation

@Epochex
Copy link
Copy Markdown

@Epochex Epochex commented May 18, 2026

What

Fix MCP OAuth authorization flow for servers that return 200 OK on initialize even when no tokens are present.

Today ToolMCPAuthApi marks the provider as authed=true as soon as it can connect, which breaks OAuth-protected servers like Google Drive MCP: initialize succeeds, but later tool calls fail because no access token was ever obtained.

How

After a successful connect, if the provider has client_information configured but still has no tokens, start the OAuth flow via core.mcp.auth.auth_flow.auth() and return the authorization_url response instead of saving authed=true.

Tests

  • uv run --project api pytest -q api/tests/unit_tests/controllers/console/workspace/test_tool_providers.py -k mcp_auth
  • uv run --project api ruff check api/controllers/console/workspace/tool_providers.py api/tests/unit_tests/controllers/console/workspace/test_tool_providers.py

Fixes #36230

@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label May 18, 2026
@Epochex
Copy link
Copy Markdown
Author

Epochex commented May 18, 2026

Actions checks haven’t started for this fork PR yet (workflow runs show “Action required”).

I ran the focused checks locally and they pass:

  • uv run --project api pytest -q api/tests/unit_tests/controllers/console/workspace/test_tool_providers.py -k mcp_auth
  • uv run --project api ruff check api/controllers/console/workspace/tool_providers.py api/tests/unit_tests/controllers/console/workspace/test_tool_providers.py

Could a maintainer please approve/run the workflows so CI can execute?

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

Labels

size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCP OAuth flow never triggers for servers that return 200 OK on initialize without auth (Google Drive MCP)

1 participant