feat(mcp): OAuth 2.1 + PKCE for outbound MCP servers#4441
feat(mcp): OAuth 2.1 + PKCE for outbound MCP servers#4441waleedlatif1 wants to merge 1 commit intostagingfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR SummaryHigh Risk Overview Adds new Extends MCP server CRUD to store Reviewed by Cursor Bugbot for commit aa8078d. Configure here. |
Greptile SummaryThis PR implements full OAuth 2.1 + PKCE support for outbound MCP servers, introducing a
Confidence Score: 5/5Safe to merge; OAuth plumbing is well-structured, all previously identified security gaps are closed, and remaining findings are minor hardening suggestions that do not affect correctness or security of the happy path. All significant issues from prior review rounds are confirmed addressed. The two new findings are narrow: state TTL via updatedAt is low-risk because states are single-use, and the form modal auth-bypass heuristic affects only the UX guard, not the server-side security boundary. apps/sim/lib/mcp/oauth/storage.ts (state TTL via updatedAt) and the mcp-server-form-modal.tsx (connection-test bypass heuristic) would benefit from a follow-up hardening pass. Important Files Changed
Sequence DiagramsequenceDiagram
participant UI as Browser/UI
participant Start as /api/mcp/oauth/start
participant CB as /api/mcp/oauth/callback
participant DB as mcp_server_oauth
participant AS as Auth Server MCP
UI->>+Start: GET with serverId and workspaceId
Start->>DB: getOrCreateOauthRow
DB-->>Start: oauth row
Start->>AS: SDK mcpAuth metadata discovery plus DCR
AS-->>Start: McpOauthRedirectRequired
Start-->>-UI: status redirect with authorizationUrl
UI->>UI: window.open authorizationUrl
AS-->>UI: redirect to callback with auth code and state
UI->>+CB: GET callback
CB->>DB: loadOauthRowByState hash lookup with TTL
DB-->>CB: oauth row
CB->>DB: clearState burn before exchange
CB->>AS: SDK mcpAuth token exchange
AS-->>CB: access and refresh tokens
CB->>DB: saveTokens encrypted
CB->>DB: clearVerifier
CB-->>-UI: postMessage ok true
Reviews (24): Last reviewed commit: "fix(mcp): final audit fixes — state TTL,..." | Re-trigger Greptile |
|
Greptile summary findings addressed in f587e82:
The point about clearing a pre-registered Client ID by emptying the field is a follow-up — |
|
@greptile |
|
@cursor review |
|
@greptile |
|
@cursor review |
|
@greptile |
|
@cursor review |
|
@greptile |
|
@cursor review |
|
@cursor review |
|
@greptile |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 3f840d6. Configure here.
3f840d6 to
0de4158
Compare
|
@greptile |
|
@cursor review |
|
@greptile |
|
@cursor review |
|
@cursor review |
|
@greptile |
|
@greptile |
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit aa8078d. Configure here.
88e7f4f to
be03225
Compare
Adds full MCP OAuth 2.1 + PKCE + Dynamic Client Registration (RFC 7591)
support for outbound MCP servers via the SDK's `authProvider` interface.
- `mcp_server_oauth` table holds per-server SDK OAuth artifacts
(client info, encrypted tokens, PKCE verifier, state) workspace-scoped
and shared across workspace members.
- `mcp_servers.{auth_type, oauth_client_id, oauth_client_secret}` columns
capture probe result and optional pre-registered credentials for ASes
that don't support DCR.
- `SimMcpOauthProvider` implements the SDK's `OAuthClientProvider` with a
storage-backed redirect-sentinel pattern; the popup flow runs through
`/api/mcp/oauth/{start,callback}` and posts back to the opener.
- Unauthorized errors during tool execution surface as `reauth_required`
so the UI can re-prompt without a stale-server flicker.
- Tests, audit script baseline, and turbo bump included.
5c4c68d to
d02a868
Compare
Summary
OAuthClientProviderWWW-Authenticate/oauth-protected-resource)mcp_server_oauthtable; SDK refreshes automatically before expiry/api/mcp/oauth/start→/api/mcp/oauth/callback) withstateCSRF protectionreauth_requiredfrom tool execution when refresh token is invalid so the UI can prompt to reconnectType of Change
Testing
Tested manually against OAuth-protected MCP servers (Linear). Existing header-auth servers regression-checked.
Checklist