feat: per-client server and tool access, and tool counts on my servers #45

Merged
marti merged 7 commits from feature/client-tool-access into develop 2026-11-08 19:20:51 +01:00
Owner

Summary

Users choose which servers and tools each connected client and MCP key can use. Everything is allowed until switched off, and the switches only narrow what the user can already reach.

 tools/list, tools/call, mcphub__status
   loadUserServerContexts
+  loadClientBlocks(user, grant or MCP key)
   filter: ready, not hidden by user
+  filter: server not blocked for this client
   filter: tool not disabled by admin, not hidden by user
+  filter: tool not blocked for this client
<ClientsPage>
  <ConnectedClientList> Access -> /clients/:grantId
  <TokenManager>        Access -> /clients/keys/:keyId
<ClientAccessPage> / <McpKeyAccessPage>
  <AccessView> client logo, then a server switch and "Choose tools" per server
<MyServersPage> "Tools enabled" stat, "8 of 12 tools enabled" on each card

Blocks live in client_hidden_servers and client_hidden_tools. Each row belongs to one OAuth client (per user) or one MCP key. OAuth rows are not keyed by grant, because a password change revokes every grant and the client would sign in again with its restrictions gone.

Evidence

  • Before: every client and MCP key of a user saw the same tools, and My servers showed only a tool total.
    After: nix develop -c ./scripts/ci.sh exits 0: lint, typecheck, build, audit, and API 331, web 153, runner 46 and shared 5 tests passing.
gateway.test.ts
  block a tool for one client  -> gone from its tools/list, call is "Unknown tool", other client unchanged, live session notified
  block a whole server         -> gone from tools/list and mcphub__status
  revoke the grant, sign in again -> block still applies
  limit one MCP key            -> other key unchanged, another user's key id answers 404, admin token id answers 404
portal.test.ts
  hide a tool -> toolCount 1, enabledToolCount 0 for that user, 1 for another

Also checked in the running app with sample data, at 1280 px and 390 px wide, with no sideways scrolling.

Merge Danger

Door: two-way

Migration 0007_client_access only adds two tables. Rolling back removes the switches, so clients regain everything their user can reach.

Blast Radius: gateway

Every tools/list, tools/call and mcphub__status on /mcp now reads the block tables. A client that registers again through dynamic registration gets a new client id and starts with nothing blocked. A per-user server's tools can be switched individually only after an admin runs Test, as on its server page today.

trail check flags schema.ts and portal/servers.ts against two learnings. Both are false matches: no admin tool is added to /mcp, and catalog deletion and the missing-tool-is-enabled rule are unchanged.

🤖 Generated with Claude Code

## Summary Users choose which servers and tools each connected client and MCP key can use. Everything is allowed until switched off, and the switches only narrow what the user can already reach. ```diff tools/list, tools/call, mcphub__status loadUserServerContexts + loadClientBlocks(user, grant or MCP key) filter: ready, not hidden by user + filter: server not blocked for this client filter: tool not disabled by admin, not hidden by user + filter: tool not blocked for this client ``` ```text <ClientsPage> <ConnectedClientList> Access -> /clients/:grantId <TokenManager> Access -> /clients/keys/:keyId <ClientAccessPage> / <McpKeyAccessPage> <AccessView> client logo, then a server switch and "Choose tools" per server <MyServersPage> "Tools enabled" stat, "8 of 12 tools enabled" on each card ``` Blocks live in `client_hidden_servers` and `client_hidden_tools`. Each row belongs to one OAuth client (per user) or one MCP key. OAuth rows are not keyed by grant, because a password change revokes every grant and the client would sign in again with its restrictions gone. ## Evidence - **Before:** every client and MCP key of a user saw the same tools, and My servers showed only a tool total. **After:** `nix develop -c ./scripts/ci.sh` exits 0: lint, typecheck, build, audit, and API 331, web 153, runner 46 and shared 5 tests passing. ```text gateway.test.ts block a tool for one client -> gone from its tools/list, call is "Unknown tool", other client unchanged, live session notified block a whole server -> gone from tools/list and mcphub__status revoke the grant, sign in again -> block still applies limit one MCP key -> other key unchanged, another user's key id answers 404, admin token id answers 404 portal.test.ts hide a tool -> toolCount 1, enabledToolCount 0 for that user, 1 for another ``` Also checked in the running app with sample data, at 1280 px and 390 px wide, with no sideways scrolling. ## Merge Danger **Door:** two-way Migration `0007_client_access` only adds two tables. Rolling back removes the switches, so clients regain everything their user can reach. **Blast Radius:** gateway Every `tools/list`, `tools/call` and `mcphub__status` on `/mcp` now reads the block tables. A client that registers again through dynamic registration gets a new client id and starts with nothing blocked. A per-user server's tools can be switched individually only after an admin runs Test, as on its server page today. `trail check` flags `schema.ts` and `portal/servers.ts` against two learnings. Both are false matches: no admin tool is added to `/mcp`, and catalog deletion and the missing-tool-is-enabled rule are unchanged. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Blocks are keyed by user and client rather than grant, so they survive a
revoked grant and a new sign-in. A password change revokes every grant.

trail check flags schema.ts and portal/servers.ts against two learnings.
Both are false matches: no admin tool is added to /mcp, and catalog
deletion and the missing-tool-is-enabled rule are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rebuilds the client_access migration, still unreleased, so one row shape
belongs to an OAuth client or an MCP key. Moves the access routes out of
the OAuth grant routes because both kinds share them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
feat(web): show the client logo on access pages and tools after servers
All checks were successful
CI / check (pull_request) Successful in 6m9s
c62ec6f626
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
marti merged commit 1465b4daf2 into develop 2026-11-08 19:20:51 +01:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
marti/mcphub!45
No description provided.