Repository navigation
feat(mcp): request_server tool and template.mcp_server card - #25180
Conversation
36ac868 to
bdd9cc2
Compare
3fba3e7 to
2258b7b
Compare
93eecc6 to
e1caf0f
Compare
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks. The gateway builds the server entry, only the owner's browser can apply the card, and the patch removes nothing that existing readers depend on. Notes
[DESIGN-REVIEWED] 6d643d5 Description read[DESCRIPTION-READ] cf7ac7cec9a6717534e7be1c28c3f0951729cb217dfbf4b09260b321b958bab0 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. One gap: the Goal says "any template-based session", but on the default agent and worker the new tool always refuses, and on a kiro-cli custom agent it does too. Notes
What this change shipsInventory (10 items) — 9 justifiedIntent: let an agent ask in chat for an MCP server it is missing, with the owner approving it on a card. ADDITION.
[FIRST-PRINCIPLES-REVIEWED] 6d643d5 Description read[DESCRIPTION-READ] d2325ad2ac9f81c2c999b23b41256cc8b56b37628e6e69017d87bfde6cc67a70 That sha256 names the PR description this verdict read. Recompute it with |
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing blocks: all three card states (pending, applied, undone) are shown, and the blind reader read the main button "Add server" correctly. Its hesitation was about wording, not about what the button does. Notes
[UX-REVIEWED] 6d643d5 Description read[DESCRIPTION-READ] e8f5dfd3115cc4d3412c193eee6c27c0932d34316d4adb722103119021fb9cee That sha256 names everything this verdict read: the PR description, plus the 6 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
GPT 6.1 Review — ✅ no blocking findings (all downgraded on adjudication)GPT 6.1 flagged blocking issues on This comment is updated in place on each push. Review detailsBLOCKING -- src/kiro_crew/dashboard/handlers/template_server_request.py:536 -- A concurrent rebuild can restore a server after successful Undo
Adjudication (Opus 5.5) — is blocking on each finding proportionate?F1 is LOW harm. Every condition below was checked in the code. The failure needs the owner to Undo at the same moment a separate MCP-page rebuild has already read the additions record but not yet written its spec. That rebuild reads the record in The real fix is expensive. It needs a new lock over the whole read-additions-to-write-spec phase of False positive or not applicable? A repository writer can comment: |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
|
Findings on
The description and |
6f790ec to
749d3ca
Compare
749d3ca to
4b28ec5
Compare
|
Findings on
Rebased onto main |
4b28ec5 to
bb9c2af
Compare
|
UX findings on
GPT's race finding is deferred to #25974 by owner decision, and there is no code change for it. Rebased onto main |
|
UX finding on
The screenshots still show the earlier wording of this one row; the description says so. The head is rebased onto main |
|
Findings on
Rebased onto main |
|
Findings on
Rebased onto main |
Any template-based session asks the user, mid-chat, for an MCP server it lacks. The kirocrew-core tool names a server and its source; the gateway resolves the caller and its template from the attested session, builds the entry from a server it runs or the official registry plan, and raises a template.mcp_server card that lists every template and open session the addition reaches. Only the owner's browser applies it, into the per-template additions record; its Undo removes only the record its own card wrote. Unattended turns (schedule, subagent, channel, patrol or any turn the user did not send) are refused with the reason. propose_change cannot raise the kind, and the card carries no autoApprove or allowedTools.
|
Findings on
The H17 |
Problem / Motivation
Goal: An agent in any template-based session can ask, in the chat, for an MCP server it lacks, and the user approves it on a change card.
A session on an agent template (the default
kirocrewagent, a custom or third-party agent, the worker, a conductor) has no way to ask for a server mid-chat. Crewmates haverequest_capabilities; nothing else does, andpropose_changehas no kind that adds a server to a template. So an agent that needs a capability either stops or works around the gap, for example by launching the server's program from the shell, which bypasses the per-tool gate.Why it matters
The workaround runs a server's code as one shell command: policy, approval and the audit trail never see the server's calls. The supported path has to be easier than the workaround, and it has to keep the owner as the only one who grants anything.
Not a goal
autoApproveorallowedTools.What changed (motivation → approach → change)
Goal → approach: the one-pager on the issue and its amendment put the request tool on
kirocrew-core(the one server every session carries), a gateway route that resolves the caller from the attested session, a card kind that writes the per-template additions record from part (a), and an Undo that removes it. The design review's six points are each handled:request_serversends only{server?, source, registry_id?, reason?}; the route refuses any other field (400 invalid_body). The gateway builds the entry withmember_capability_catalog.resolve_server, now shared withrequest_capabilities(extracted fromadditions_to_draft, same behaviour): a server this gateway runs and has switched on, or the official registry's install plan. A gateway entry carrying env, headers or credential arguments is refusedcarries_settings; such a server is added on the MCP page, where secrets come from the existing store.propose_changecannot raise the kind (GATEWAY_RESOLVED_KINDS,403 use_request_server) andlist_change_kindsleaves it out.template_mcp_additions.validate_entry, soautoApprove,allowedToolsand every other trust key are refused. The "Each tool" row says "nothing is auto-approved; this agent's existing permissions still apply" (the UX reviewer's wording); it makes no promise that each tool asks.template_mcp_additions.add_additionfrom part (a); nothing is written into a spec file. An alias session (kirocrew-ledger-conductor) records under its target.addition_reach(an addition to the goal conductor also lists its deprecated alias), every open dashboard session on those templates, and crew members built from them, plus whether running sessions pick it up at their next turn (the live gate) or restart. A worker session's request records on the worker's own entry.DELETE /api/agents/detail/{name}/mcp-additions/{server}?card_id=<card>, callingremove_addition(card_id=...), so a later approval of the same server on another card survives a stale Undo.cards.request_serveris a user-turn operation of the existing caller gate, with no own-thread exemption. A subagent, a schedule or workflow slot, a channel turn and any turn the user did not send (patrol, loop wake,session_send) get a refusal naming the reason and what to do instead.A third-party template on a harness where an addition cannot reach its sessions (kiro-cli) is refused
409 unsupportedwith part (a)'sUNSUPPORTED_REASON. A crewmate is sent torequest_capabilities. A request from the defaultkirocrewagent or the worker is refused by (a)'saddition_support(409 unsupported, pointing to the MCP page) and raises no card: those agents carry every server installed there, and the MCP page's add would also approve every tool. Mount-only requests for them are a follow-up.Change:
mcp_tools/server_request.py: therequest_servertool onkirocrew-core(strict session key, stateless).dashboard/handlers/template_server_request.py: the agent routePOST /api/cards/agent/request-server(strict/api/cards/agentprefix) and the owner-only, card-hookedPOST/DELETE /api/agents/detail/{name}/mcp-additions[/{server}]. The POST refuses any internal caller (403 owner_only) and any request with no card (403 card_required). Each write rebuilds the agent specs, then applies live or resets sessions, as an MCP page change does.change_card_catalog*: thetemplate.mcp_serverkind, its preview, evidence (card_id) and Undo; readers for its state and context.docs/architecture/mcp.md: new section Asking for an MCP server mid-chat (request_server), the core tool list and the card kinds paragraph.Merge order: part (a) #25172 has merged; this PR is rebased onto
mainand importskiro_crew.template_mcp_additions. This PR makes two changes to (a)'s module.add_additiongains a keywordonly_if_absent(default off, so existing callers are unchanged), which the Apply and a failed Undo's restore both use, so neither overwrites a newer card's approval. Andmerge_intonow layers the MCP page's currentdisabledToolsfor each added server onto the merged entry, read through the existingmate_worker.globally_disabled_refs, so an addition never brings back a tool the owner switched off.Backwards compatibility
Compatible: one new tool, one new kind that only the new route raises, and three new routes.
request_capabilitieskeeps its behaviour: the server resolution moved intoresolve_serverwith the same checks, order and messages.Removes nothing: the diff only adds a tool, a card kind and routes; the shared helper is an extraction with the crewmate path calling it.
Tests
test/test_template_server_request.py(18 tests), through the real routes, card engine and additions record under a temp data home:command,url,entry,template,session) are refused, andpropose_changecannot raise the kind with its own entry;UNSUPPORTED_REASON;409 already_added);disabledToolsfor that server onto it;list_change_kinds;test_the_card_never_promises_a_prompt);request_capabilities.Mutation checks, each reverted by path and each reddening a named test:
test_only_the_owner_s_browser_applies_the_cardtest_the_request_never_takes_a_launch_line_from_the_agentpropose_changerefusal of the kind removed →test_the_request_never_takes_a_launch_line_from_the_agentcards.request_serverdropped from the user-turn operations →test_an_unattended_turn_is_refused_with_its_reason[not_user_turn-not_user_turn]validate_entry→test_a_trust_key_never_rides_on_the_cardcard_id→test_a_stale_undo_never_removes_a_later_approvalonly_if_absent→test_a_concurrent_apply_never_replaces_an_earlier_approvaltest_a_spawn_merged_template_needs_no_spec_rewritetest_a_racing_rebuild_converges_on_the_undone_recordtest_the_card_says_every_open_chat_restarts_when_not_livetest_request_raises_a_card_the_owner_applies_and_undoesUpdated pins: the card route table regex admits a hyphen in a path, the MCP route table row count and digest, and the boot chain's
_deferredrun (one more deferred route).Proof: not provable -- other: new feature, no fix to revert; the mutation checks above stand in for it.
Locally, on this head: the change-card, member-capability, tool-registry, tool-title, facade-mirror, identity-topology and server-composition suites pass, except
test_identity_topology.py::test_a_proven_recycle_is_not_unverifiable, which fails the same way on the base commit 15e3f14 without this change.Manual verification
Run end to end in a pod on Linux with kiro-cli 2.35.1: request, card, apply, live pickup in the running session, Undo (screenshots below). The pod run found the dashboard had no entry for the new kind, so Apply stayed disabled; the kind is now registered in
website/src/api/cards.tsandcards/cardRegistry.tswith its strings. KAS live pickup and macOS/Windows not run.Screenshots / video
Pod run on this head, Linux, kiro-cli 2.35.2. A Crew Mode (
kirocrew-conductor) session calledrequest_serverfortickets-demo, a server installed on the pod with no keys or login settings.The pending card. The title, "Adds" and "What it does" say in plain words what adding the server does. The old agent name sits on the same chip as the agent it names. "Each tool" reads "nothing is auto-approved; this agent's existing permissions still apply", and a new "Undo" row reads "remove it from this card any time". The server had not run yet, so "Its tools" shows its fallback:
After Add server (the conductor spec mounts
tickets-demo):After Undo (the record is empty, and the spec no longer mounts it):
Rows this pod could not show are pinned by tests: the not-live "Open chats" text (
test_the_card_says_every_open_chat_restarts_when_not_live), "Crew members", and "Already approved" (test_an_approval_the_agent_already_holds_is_named).Related Issues
Refs #25157 (part (b) of two; part (a) is #25172)
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license.