feat: test tools from the UI, user activity log, one clients page, prune stale tools #27

Merged
marti merged 1 commit from feature/open-issues-23-26 into develop 2026-11-06 19:10:51 +01:00
Owner

Closes #23, closes #24, closes #25, closes #26.

Summary

#23 Test a tool. There is a Test button on the admin Tools tab and on the portal server page. It opens a form built from the tool's inputSchema, with a JSON fallback for schemas the form can't render.

flowchart LR
    A["Admin: POST /api/admin/servers/:id/tools/:name/call"] --> P{per-user server?}
    P -- no --> S[pooled shared connection]
    P -- yes --> T["one-shot process on test values<br/>(probe key, queued with Test, killed after)"]
    U["User: POST /api/me/servers/:id/tools/:name/call"] --> C["checkToolCall: access, ready,<br/>not admin-disabled (hidden ok)"] --> O[user's own connection]
    S & T & O --> R["recordToolCall -> tool_calls<br/>(no args, no results)"]
  • Admins can test any tool, disabled ones included. The admin route is kept off /mcp/admin (adminMcp: false).
  • checkToolCall and recordToolCall are pulled out of callGatewayTool; /mcp behaves the same as before.

#24 Own logs. GET /api/me/tool-calls and a portal Activity page show only the user's own tool calls (filters: server, status).

  • A shared server's connection error is replaced by generic text, since the gateway never shows users those details.
  • Test calls appear here too, with no client.

#25 One Clients page.

 nav
   My servers
-  Connect a client      (/connect)
-  Connected clients     (/clients)
+  Clients               (/clients, "Connect a client" opens a modal, ?connect=1)
+  Activity              (/activity)

/connect redirects to /clients?connect=1.

#26 Stale tools.

 upsertToolCatalog(serverId, tools)    # shared connect, list_changed, admin Test
+  delete rows not in `tools` where enabled = true
   upsert listed tools (one shared lastSeenAt)

Disabled rows that are no longer listed are kept and marked "Not listed at the last refresh" in the admin Tools tab. The gateway treats a tool missing from the catalog as enabled, so deleting them would let a Test run on narrower test values switch a disabled tool back on for real users. This differs from the "hard delete everything" option agreed earlier: review found that hole.

Evidence

  • Before: a stale tool survived a Test, and a server returning an empty list kept every old row.
    After: upstream-pool.test.ts checks that enabled tools the server no longer lists are dropped and disabled ones are kept, including on an empty list.
  • New tests:
    • tool-test-calls.test.ts (14 tests): admin and user paths, disabled, hidden, no access, 404, 409, isError, per-user test values, rows logged without arguments.
    • my-tool-calls.test.ts: a user sees only their own rows, ?userId= is ignored, filters, paging, shared-server error masking.
    • Web: toolForm.test.ts, the ServerPage modal flow, ActivityPage.test.tsx, ClientsPage.test.tsx (button, ?connect=1, /connect redirect).
  • Typecheck and lint pass. API: 310/310 tests, web: 123/123, runner and shared pass.
  • trail check flags README.md:13 and schema.ts:356 against the "no admin tools on the user /mcp gateway" learning. Both are keyword matches: nothing is added to /mcp, and the new admin call route is excluded from the admin MCP.

Merge Danger

Door: two-way

No migration. The routes, pages and catalog rule are all revertible. Catalog rows deleted by a refresh come back on the next refresh that lists them.

Blast Radius: moderate

  • The gateway call path was refactored (covered by gateway.test.ts).
  • Portal navigation changed: old /connect links redirect.
  • Admins can now run any upstream tool from the UI, with shared or test credentials.

🤖 Generated with Claude Code

Closes #23, closes #24, closes #25, closes #26. ## Summary **#23 Test a tool.** There is a Test button on the admin Tools tab and on the portal server page. It opens a form built from the tool's `inputSchema`, with a JSON fallback for schemas the form can't render. ```mermaid flowchart LR A["Admin: POST /api/admin/servers/:id/tools/:name/call"] --> P{per-user server?} P -- no --> S[pooled shared connection] P -- yes --> T["one-shot process on test values<br/>(probe key, queued with Test, killed after)"] U["User: POST /api/me/servers/:id/tools/:name/call"] --> C["checkToolCall: access, ready,<br/>not admin-disabled (hidden ok)"] --> O[user's own connection] S & T & O --> R["recordToolCall -> tool_calls<br/>(no args, no results)"] ``` - Admins can test any tool, disabled ones included. The admin route is kept off `/mcp/admin` (`adminMcp: false`). - `checkToolCall` and `recordToolCall` are pulled out of `callGatewayTool`; `/mcp` behaves the same as before. **#24 Own logs.** `GET /api/me/tool-calls` and a portal **Activity** page show only the user's own tool calls (filters: server, status). - A shared server's connection error is replaced by generic text, since the gateway never shows users those details. - Test calls appear here too, with no client. **#25 One Clients page.** ```diff nav My servers - Connect a client (/connect) - Connected clients (/clients) + Clients (/clients, "Connect a client" opens a modal, ?connect=1) + Activity (/activity) ``` `/connect` redirects to `/clients?connect=1`. **#26 Stale tools.** ```diff upsertToolCatalog(serverId, tools) # shared connect, list_changed, admin Test + delete rows not in `tools` where enabled = true upsert listed tools (one shared lastSeenAt) ``` Disabled rows that are no longer listed are kept and marked "Not listed at the last refresh" in the admin Tools tab. The gateway treats a tool missing from the catalog as enabled, so deleting them would let a Test run on narrower test values switch a disabled tool back on for real users. This differs from the "hard delete everything" option agreed earlier: review found that hole. ## Evidence - **Before:** a stale tool survived a Test, and a server returning an empty list kept every old row. **After:** `upstream-pool.test.ts` checks that enabled tools the server no longer lists are dropped and disabled ones are kept, including on an empty list. - New tests: - `tool-test-calls.test.ts` (14 tests): admin and user paths, disabled, hidden, no access, 404, 409, `isError`, per-user test values, rows logged without arguments. - `my-tool-calls.test.ts`: a user sees only their own rows, `?userId=` is ignored, filters, paging, shared-server error masking. - Web: `toolForm.test.ts`, the ServerPage modal flow, `ActivityPage.test.tsx`, `ClientsPage.test.tsx` (button, `?connect=1`, `/connect` redirect). - Typecheck and lint pass. API: 310/310 tests, web: 123/123, runner and shared pass. - `trail check` flags README.md:13 and schema.ts:356 against the "no admin tools on the user /mcp gateway" learning. Both are keyword matches: nothing is added to `/mcp`, and the new admin call route is excluded from the admin MCP. ## Merge Danger **Door:** two-way No migration. The routes, pages and catalog rule are all revertible. Catalog rows deleted by a refresh come back on the next refresh that lists them. **Blast Radius:** moderate - The gateway call path was refactored (covered by `gateway.test.ts`). - Portal navigation changed: old `/connect` links redirect. - Admins can now run any upstream tool from the UI, with shared or test credentials. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
feat: test tools from the UI, user activity log, one clients page, prune stale tools
All checks were successful
CI / check (pull_request) Successful in 5m53s
ca60f30946
- Test a single tool from the admin Tools tab and the portal server page,
  with a form built from its inputSchema. Admin calls use Test's context
  (test values on per-user servers, one-shot unpooled process); user calls
  use the user's own values and the gateway's checks (hidden tools ok,
  admin-disabled refused). Logged to tool_calls without arguments or
  results. The admin route is kept off /mcp/admin (adminMcp: false).
- GET /api/me/tool-calls and a portal Activity page with the user's own
  calls; a shared server's connection error is replaced by generic text.
- /clients is the single Clients page; the connect instructions are a
  modal (?connect=1) and /connect redirects there.
- A catalog refresh deletes enabled tools the server no longer lists.
  Disabled ones stay and are marked in the admin UI, because a missing
  tool counts as enabled and a narrower probe must not re-enable it.

trail check flags README.md:13 and schema.ts:356 against the learning that
ruled out admin tools on the user /mcp gateway: keyword matches only, no
admin tools are added to /mcp, and the new admin call route is excluded
from the admin MCP.

Closes #23
Closes #24
Closes #25
Closes #26

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
marti merged commit 3aff62fd31 into develop 2026-11-06 19:10: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!27
No description provided.