Repository navigation
feat(mcp): bearer token support when adding remote MCP servers - #1398
Conversation
CAM's platform feedback: /account/mcp-servers only offered name and URL, so bearer-token MCP servers could not be connected. Add an optional bearer token on the UI, account API, and mcp_server_add capability, and pass it as a durable Authorization header through the per-user MCP client hub. Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (4)
📝 WalkthroughWalkthroughMCP server setup now accepts optional bearer tokens. Shared utilities normalize credentials and create Authorization headers. The hub applies headers during connection while excluding tokens from persisted D1 settings and snapshots. The UI, capability, tests, and documentation expose the new flow. ChangesMCP bearer-token authentication
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant ManagementUI
participant AccountMcpServerHandler
participant SettingsService
participant McpClientHub
participant MCPServer
ManagementUI->>AccountMcpServerHandler: Submit bearerToken
AccountMcpServerHandler->>SettingsService: Call addMcpServer
SettingsService->>SettingsService: Normalize token and derive Authorization header
SettingsService->>McpClientHub: Register server with headers
McpClientHub->>MCPServer: Connect with Authorization header
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
🔎 Preview deployed: https://kody-pr-1398.kody-a99.workers.dev Worker: Mocks:
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit b41eb43. Configure here.
|
@coderabbitai review |
|
Bugbot correctly flagged that pasting "Authorization: Bearer …" would be double-wrapped. Strip the header name before scheme/token normalization. Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>

Summary
Addresses CAM's platform feedback:
/account/mcp-serversonly accepted name + URL, so bearer-token MCP servers could not be connected.Adds an optional bearer token on:
/account/mcp-serversadd form (password field)bearerToken)mcp_server_addcapabilityNormalization accepts bare tokens (
Bearer <token>), scheme-prefixed values, and fullAuthorization: …header pastes. The credential is stored only in the per-user MCP client hub's Agents SDKserver_options(never in D1 or list/detail responses).Test plan
bearerTokenSystem recap — extends existing primitives (medium risk)
Mode: recap · Base:
main@c7cd824· Head: follow-up after Bugbot paste-fixClassification: extends — MCP client add contract and account UI now accept optional static Authorization credentials.
Primitives touched
mcp-client-serversbearerToken→ durable Authorization header on hub transportapp-uiSystem map
Add-server flows (UI / API / capability) now pass an optional bearer credential into the per-user MCP client hub as a durable Authorization header.
Legend: green = composes (wiring only) · amber = extended by this PR · red = new primitive · gray = context (unchanged, included only when an edge crosses it).
Before / after
mcp_server_add{ name, url }{ name, url, bearerToken? }addServerheaders.Authorizationpersisted in DOserver_optionsInvariants
Per-user isolation unchanged: credentials stay in the user-scoped MCP client hub DO and are never returned by list/detail APIs.
Summary by CodeRabbit
New Features
Documentation
Bug Fixes