[PR #5014] feat(mcp): add OAuth authentication support for remote MCP servers #11204

Closed
opened 2026-02-16 18:16:00 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/5014

State: closed
Merged: Yes


Summary

  • Add OAuth 2.0 authentication support for remote MCP servers, including dynamic client registration (RFC 7591)
  • Implement local callback server, CLI commands (mcp auth, mcp logout), and TUI status display for OAuth flows

Changes
Phase 1 - Core OAuth infrastructure

  • Token and client info storage (mcp/auth.ts)
  • OAuthClientProvider implementation (mcp/oauth-provider.ts)
  • Config schema extended with McpOAuth (optional clientId, clientSecret, scope)

Phase 2 - Callback server and MCP integration

  • Local HTTP callback server on port 19876 (mcp/oauth-callback.ts)
  • New MCP status types: needs_auth, needs_client_registration
  • Methods: startAuth, authenticate, finishAuth, removeAuth

Phase 3 - CLI and server API

  • CLI commands: mcp list, mcp auth [name], mcp logout [name]
  • API endpoints: POST /mcp/:name/auth, POST /mcp/:name/auth/callback, DELETE /mcp/:name/auth

Phase 4 - TUI integration

  • OAuth status indicators in sidebar
  • Status dialog updates for auth states

Phase 5 - Documentation

  • MCP OAuth configuration and usage docs

Tried authenticating with an internal MCP server and it seems to be working correctly.

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/5014 **State:** closed **Merged:** Yes --- **Summary** - Add OAuth 2.0 authentication support for remote MCP servers, including dynamic client registration (RFC 7591) - Implement local callback server, CLI commands (mcp auth, mcp logout), and TUI status display for OAuth flows **Changes** Phase 1 - Core OAuth infrastructure - Token and client info storage (mcp/auth.ts) - OAuthClientProvider implementation (mcp/oauth-provider.ts) - Config schema extended with McpOAuth (optional clientId, clientSecret, scope) Phase 2 - Callback server and MCP integration - Local HTTP callback server on port 19876 (mcp/oauth-callback.ts) - New MCP status types: needs_auth, needs_client_registration - Methods: startAuth, authenticate, finishAuth, removeAuth Phase 3 - CLI and server API - CLI commands: mcp list, mcp auth [name], mcp logout [name] - API endpoints: POST /mcp/:name/auth, POST /mcp/:name/auth/callback, DELETE /mcp/:name/auth Phase 4 - TUI integration - OAuth status indicators in sidebar - Status dialog updates for auth states Phase 5 - Documentation - MCP OAuth configuration and usage docs Tried authenticating with an internal MCP server and it seems to be working correctly.
yindo added the pull-request label 2026-02-16 18:16:00 -05:00
yindo closed this issue 2026-02-16 18:16:00 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#11204