Repository navigation
feat(ai): hold MCP tools and chat to what an analyst may do - #2547
Conversation
An observer is refused every MCP tool that changes data and is not shown one in tools/list, the same as a read-only API key. The check reads the role, so it holds on every way a tenant reaches the registry: an API key, an MCP sign-in, a session and a chat turn. A chat turn run for an observer is offered no approval-gated tool, since an observer could not approve the proposal. They can still ask questions: the read tools are unchanged.
This comment has been minimized.
This comment has been minimized.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 17 minutes. View limit details
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. |
# Conflicts: # packages/domain/src/policy/roles.ts
The seven dashboard tools stay open to an analyst; every other tool that changes data is refused and hidden, and a chat turn proposes only dashboard changes to them.
The chat routes are a raw router, so the analyst gate never ran for them: an analyst could send a follow-up, which may file a new diagnosis, and stop a running pass. Both are refused now; reading the thread stays open. Also covers an analyst's tools/list over the real MCP transport.
Maple review🟢 Confidence 10/10 · safe to merge. Every refusal reads the role from the resolved tenant and each branch has a test; the ai test shards were cancelled in CI, so those cases are unverified here. Adds a role-based analyst gate to MCP
Fixed since the last review
Production impactOpen errors in the changed files (2)
After this merges, Maple checks whether they stop.
|
Maple: after this shipped✅ Shipped clean. Nothing this change touches got worse in the hour after it deployed. Deployed to Errors in the changed files:
Maple looks once, an hour after the first deploy that carries the merge. |
Third layer of the Analyst role, on top of #2546. MCP tools and the AI chat do not go through the HTTP auth middlewares, so this layer applies the same rule there: an analyst reads and builds dashboards, nothing else.
What changed
create_dashboard,update_dashboard, and add, update, remove, reorder and replace widgets). Every other MCP tool that changes data is refused with the same message as the API, and is not shown in theirtools/list.Verified
apps/ai:read-only-key.test.ts,agents.test.ts, the registry contract test, the server tests and the chat route tests, 44 passed, plus thetools/listtest over the real MCP transport: an analyst's key listscreate_dashboardand notcreate_alert_rule. An analyst gets 403 on a follow-up and on stop, and 200 on the thread's history. Cases: out of every tool in the catalog that changes data, an analyst is open to exactly the dashboard tools and Maple's feedback channel; with a read-only key, only the feedback channel; an analyst is refused a write tool by name with the role message; their chat turn proposescreate_dashboardand is not offered any other mutating tool, while a member's turn still proposes all of them.@maple/aitypecheck and the CI lint config on the changed files.Not in this layer
/internal/chat/apply) stays refused for an analyst. They cannot start an in-app turn, so the only proposals they could meet there are a member's.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.