feat: User Session and Authorization Management for MCP Servers #359
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces User Session and Authorization Management for MCP servers, enabling per-user authentication isolation and governance for MCP tool access. When enabled, each user maintains their own OAuth session per MCP server, ensuring proper access control and session isolation.
Key Changes
userSessionAuthfield to MCP server configuration allowing administrators to enable per-user session isolationmcp_oauth_sessiontable withuserIdtracking and added new indexes for efficient user-scoped queriestoolCallWithUserAuth()method that checks user authentication status before executing MCP toolsMcpAuthRequiredCardcomponent for seamless in-chat authorization prompts when tools require authenticationImpact & Benefits
Configuration
To enable User Session Authorization for an MCP server:
Files Changed
src/lib/db/pg/schema.pg.ts- Schema extensions for user session trackingsrc/lib/ai/mcp/- OAuth provider and client manager updatessrc/app/api/mcp/user-oauth/- New API routes for user OAuth flowsrc/components/mcp-editor.tsx- UI for configuring user session authsrc/components/mcp-auth-required-card.tsx- Inline auth prompt componentsrc/lib/auth/- Okta configuration with Org Authorization Server support