openclaw - 💡(How to fix) Fix MCP Client: Add OAuth2 Authorization Code Flow support for HTTP-based MCP servers [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#73352Fetched 2026-04-29 06:20:39
View on GitHub
Comments
1
Participants
2
Timeline
3
Reactions
0
Timeline (top)
closed ×1commented ×1labeled ×1

OAuth2 Authorization Code Flow support for HTTP-based MCP servers

Error Message

OpenClaw cannot connect to MCP servers that use OAuth2 Authorization Code Flow + PKCE for authentication. When configured in Cursor, the flow is: browser opens OAuth2 login page → user authenticates with corporate account → token automatically refreshed. No manual API key or env vars required. However, OpenClaw returns 'SSE error: Invalid content type, expected text/event-stream' because its mcp-http module only implements a loopback server (OpenClaw as MCP server), not an HTTP MCP client with OAuth2 support. There is no OAuth2 authorization code flow, no browser-based auth trigger, and no token refresh logic.

Root Cause

OpenClaw cannot connect to MCP servers that use OAuth2 Authorization Code Flow + PKCE for authentication. When configured in Cursor, the flow is: browser opens OAuth2 login page → user authenticates with corporate account → token automatically refreshed. No manual API key or env vars required. However, OpenClaw returns 'SSE error: Invalid content type, expected text/event-stream' because its mcp-http module only implements a loopback server (OpenClaw as MCP server), not an HTTP MCP client with OAuth2 support. There is no OAuth2 authorization code flow, no browser-based auth trigger, and no token refresh logic.

RAW_BUFFERClick to expand / collapse

Summary

OAuth2 Authorization Code Flow support for HTTP-based MCP servers

Problem to solve

OpenClaw cannot connect to MCP servers that use OAuth2 Authorization Code Flow + PKCE for authentication. When configured in Cursor, the flow is: browser opens OAuth2 login page → user authenticates with corporate account → token automatically refreshed. No manual API key or env vars required. However, OpenClaw returns 'SSE error: Invalid content type, expected text/event-stream' because its mcp-http module only implements a loopback server (OpenClaw as MCP server), not an HTTP MCP client with OAuth2 support. There is no OAuth2 authorization code flow, no browser-based auth trigger, and no token refresh logic.

Proposed solution

Implement OAuth2 Authorization Code + PKCE flow as the MCP HTTP client authentication mechanism, similar to how Cursor handles it: 1) On first connection, open browser for user to authenticate with OAuth2 provider; 2) Receive auth callback at a local redirect URI; 3) Automatically refresh tokens before expiry; 4) No manual API key or token setup required. The @modelcontextprotocol/sdk TypeScript SDK already includes OAuth2 client support (https://github.com/modelcontextprotocol/typescript-sdk/blob/main/docs/client.md).

Alternatives considered

No response

Impact

Enterprise users cannot use OpenClaw to connect to OAuth2-protected internal MCP servers. Users are forced to use Cursor or other MCP clients instead, fragmenting tool access across different agents.

Evidence/examples

No response

Additional information

No response

extent analysis

TL;DR

Implementing OAuth2 Authorization Code Flow with PKCE in OpenClaw's mcp-http module is likely to resolve the connection issue with MCP servers.

Guidance

  • Review the @modelcontextprotocol/sdk TypeScript SDK documentation to understand how OAuth2 client support is implemented, as it may provide a basis for OpenClaw's implementation.
  • Consider the four steps outlined in the proposed solution: opening a browser for user authentication, receiving the auth callback, automatically refreshing tokens, and eliminating the need for manual API key or token setup.
  • Investigate how Cursor handles OAuth2 Authorization Code Flow + PKCE for authentication to identify potential similarities or differences with the proposed solution for OpenClaw.
  • Evaluate the feasibility of integrating the OAuth2 client support from the @modelcontextprotocol/sdk into OpenClaw's mcp-http module.

Example

No specific code example is provided due to the lack of detailed implementation information in the issue.

Notes

The solution's success depends on accurately implementing the OAuth2 Authorization Code Flow with PKCE in OpenClaw, which may require additional development and testing efforts.

Recommendation

Apply workaround by implementing the proposed OAuth2 Authorization Code Flow with PKCE in OpenClaw's mcp-http module, as this directly addresses the identified issue and aligns with the authentication mechanism used by Cursor.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix MCP Client: Add OAuth2 Authorization Code Flow support for HTTP-based MCP servers [1 comments, 2 participants]