Files
AutopilotMonitor/src/McpServer
Oliver Kieselbach 69067e7f8c feat(mcp,backend): role-aware tool surface — hide GA-only tools from normal users
Normal (non-Global-Admin) MCP users no longer see any Global-Admin / cross-tenant
hints — reducing both confusion and attack surface / curiosity. The per-request
stateless server already runs inside the access-guard's runWithCaller context, so
the caller role is known at server-creation time.

- index.ts: createMcpServer(ga) reads isGlobalAdmin() and tailors instructions
  (non-GA gets a tenant-scoped scope line, no cross-tenant mention).
- tools.ts / sessions.ts / search.ts / admin.ts: thread `ga` into every registrar.
  * GA-only tools (list_tenants, list_tables, query_table, query_backend_logs,
    get_platform_metrics, get_ops_events, list_session_reports, list_blocked_devices,
    get_api_usage) are registered only when ga — absent from tools/list for non-GA.
  * Dual-role tools: GA/cross-tenant wording in descriptions and tenantId param
    text is gated behind `ga ? ... : ...`; non-GA sees clean tenant-scoped text.
- prompts.ts: compare-agent-versions (uses GA-only get_platform_metrics) hidden for
  non-GA; cve-exposure-audit cross-tenant wording scrubbed for non-GA.
- error-handler.ts: 403 message no longer names "Global Admin".
- backend McpUserFunction (/api/auth/mcp): omit isGlobalAdmin from the response when
  false, so a normal user gets no hint that a GA tier exists. The MCP guard reads
  `=== true` (absent → non-GA), so behavior is unchanged.

Verified: GA catalog 29 tools / non-GA 20 (9 GA-only hidden), zero GA/cross-tenant
wording in any non-GA description, prompts split 3/2. tsc clean; backend targeted
suite 135 green; mcp unit 52 green.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-27 21:40:47 +02:00
..
2026-03-26 07:02:33 +01:00