feat: personal MCP keys for bearer auth on /mcp #35
Loading…
Reference in a new issue
No description provided.
Delete branch "feature/mcp-keys"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Users can create personal MCP keys (
mhm_...) on the Clients page and connect any MCP client to/mcpwithAuthorization: Bearer mhm_..., for clients that cannot do OAuth. OAuth is unchanged.The kinds stay separate:
mhk_never opens/mcp,mhm_never opens/api/admin/*or/mcp/admin, and neither can manage tokens.Evidence
Before:
POST /mcpwith any non-OAuth bearer -> 401; no way to create a key as a non-admin.After: new tests in
apps/api/test/gateway.test.ts > MCP keys:api_token_idmhk_on/mcp,mhm_on/api/admin/serversand/mcp/admin,mhm_on/api/me/mcp-keys, and deleting another user's key are all refusedinvalid_tokenWeb:
ClientsPage.test.tsxcreates a key and sees it once with the Claude Code command.scripts/ci.shpasses locally (lint, typecheck, 502 tests, build, audit).trail checkflags two learnings (admin tools on the user gateway, hand-written MCP tools) on keyword matches only: this adds no tools and keeps admin power off/mcp.Merge Danger
Door: two-way
Migration
0005_mcp_keysonly adds an enum, a defaulted column and a nullable FK column; reverting the code leaves them harmless.Blast Radius: auth
/mcpauthentication gained a second path. A bug there would let a key reach/mcpit shouldn't, so the review should focus onservices/gateway/auth.tsandverifyTokeninservices/api-tokens.ts. The admin token UI was moved intoTokenManager(wording now "API token created" / "API token revoked").🤖 Generated with Claude Code