Repository navigation
feat(agent): per-template MCP additions record and merge - #25172
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the record is sealed, grants no trust, is read fail-soft at spawn, and changes nothing while it is absent; the patch removes nothing. Notes
[DESIGN-REVIEWED] 2258b7b Description read[DESCRIPTION-READ] bf2b851424a3b8ddec7ec085bce3ced20369e4d39650cfa677e9e7d4fa95711f 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, and every item can be backed out. The record's writer API has no production caller yet, so in this PR every merge reads an empty record. Notes
What this change shipsInventory (10 items) — 8 justifiedIntent: let a server the user approved for a conductor or a third-party template survive spec rebuilds, without granting it any trust. ADDITION.
[FIRST-PRINCIPLES-REVIEWED] 2258b7b Description read[DESCRIPTION-READ] d8cea68d473b09055fc18b54071a313d3fa913b490eb720c010bb54eb9044cad That sha256 names the PR description this verdict read. Recompute it with |
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: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Security Scope Review -- ✅ PASSWhich legitimate operations does Verdict basis: adjudicated, zero confirmed regressions. Security scope review -- adjudicated candidates
No candidate flipped from allowed to refused. Scope-Verdict: PASS Reason: The tightening adds one leaf, TIGHTENING: Path fence plus sandbox seal on the new per-template MCP additions record -- it stops a sandboxed agent from planting a server that the next rebuild or spawn launches, and stops a foreign child from reading the credentials an entry carries. From ADJUDICATED: 19 candidates, 0 confirmed newly-refused PLATFORM COVERAGE: posix, windows and any. The diff assumes two things about platform spelling: the data-home prefixes
UNADJUDICATED:
[SCOPE-REVIEWED] 2258b7b |
15e3f14 to
ef3f6af
Compare
|
🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]: Review dispositions for head Opus 5.5 BLOCKING, GPT 6.1 F1, GPT 6.1 F2 (fenced), GPT 6.1 F3, GPT 6.1 F4, GPT 6.1 F5, First Principles note (four functions with no caller yet). Kept, not moved. Design note (the default-agent projection is the one stateful merge). Acknowledged and documented in Backend Lint (isort). Fixed the two import blocks. Mutation checks were re-run on this head; every guard above turns its named test red when reverted. |
|
🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]: Sensitive change review
|
ef3f6af to
674207b
Compare
|
🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]: Review dispositions for head Opus 5.5 BLOCKING, GPT 6.1 F1 (fenced), GPT 6.1 F2, Backend Lint (mypy, 3 errors). Fixed: Design note (the array merge runs on every array host, while the set claims three). Not changed. The support answer is the conservative one: it promises delivery only where a live capture shows a spec-declared server running. A host outside the set that also gets the server is not told it will, so the card can refuse where it is unsure and never claims more than is proven. Design note (doc file name). Fixed with the Opus finding above. First Principles BLOCK (zero consumers until part (b)). Unchanged and not overridden by me. This is the agreed two-PR split; the owner decides between an override and landing it together with part (b). Mutation checks were re-run on this head: every guard turns its named test red when reverted, except the allowlist rebuild on read, which is redundant with the key check that refuses the same entries first. |
|
🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]: Sensitive change review
|
674207b to
e51737a
Compare
54e69ef to
dae73dc
Compare
|
🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]: Sensitive change review
|
dae73dc to
6886908
Compare
|
🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]: Sensitive change review
|
|
🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]: Sensitive change review
|
|
🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]: Head GPT 6.1 BLOCKING, Opus, Design and First Principles passed on |
A server the user approves for an agent template now has a place to live that no installer rewrites: template-mcp-additions/additions.json under the data home, keyed by template name, each entry a gateway-resolved server entry plus who approved it, when, and on which card. The record carries no trust: autoApprove, allowedTools and every key outside ENTRY_KEYS are refused on write and skipped on read, so a merge adds the server and its @server mount in tools and never a grant. The directory is sealed like mcp-launch-approvals: file-tool write-protected, read-only and pre-created for the OS sandbox, no-symlink, and withheld from foreign harness children. Covered templates and where the ADD-only merge runs: - the conductors, in their installers right after _conductor_mcp_servers (the ledger alias reads and writes its successor's record); - any template Kiro Crew does not write, at spawn and never into its file, on KAS, claude and codex (ACP_BACKENDS_TEMPLATE_ADDITIONS_AT_SPAWN). kiro-cli loads such a template off disk with no per-session channel, so addition_support answers unsupported there with a reason. Refused with a reason string: the default agent and the worker (kirocrew.json already holds every server installed through the MCP page and the worker mirrors it), a crewmate's own service templates, and every other template Kiro Crew writes. A refused template is never merged, even from a hand-edited record. Public API for the request card: read_additions, list_additions, add_addition, remove_addition (card-scoped), merge_into, merge_into_spec, merge_at_spawn, addition_support, addition_reach. kirocrew doctor lists each template's additions. No new reload path: live apply stays behind live_sessions_apply_mcp_live. Refs #25157
|
🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]: Sensitive change review
|
CrysisDeu
left a comment
There was a problem hiding this comment.
Comment, not approving yet at 2258b7b5. Maintainer review for part (a); one decision below has to land in this PR, because #25180 makes the record writable the moment it merges and auto-merge is on here.
What is right: nothing writes the record at this head (hand edit only; sandboxed agents cannot write it, file tools can neither read nor write it); autoApprove and other grant keys are refused on write and skipped on read, so an added server's tools still ask; the doctor row prints server name, card and date only; every AI-lane BLOCK was fixed in code, zero self-overrides. Good.
Required, maintainer decision: an approval attaches to a template NAME, not to a template. template_mcp_additions.py:441 merge_at_spawn keys by the agent string; acp/session_mcp.py:751 and the project branch of _agent_spec_and_snapshot_for (~:832) merge it into any spec called X: user-level, crewmate folder, app-bound, or a .kiro/agents/X.json in a cloned repo when no user-level X exists. Nothing drops the record when X is deleted, an app is uninstalled, or an installer renames it. The added entry carries the user's command, env and headers. So a checkout picks which approved server set it gets, with the user's keys, under a prompt and tools list the repo controls. Tool calls still prompt, so it is not a silent grant, but "an untrusted checkout never picks the servers" now holds only in letter. Decision: (1) bind the record to the template's source (user-level / mate / app id), not the bare name; (2) skip the merge on the project-checkout branch unless the checkout is trusted; (3) drop or refuse-to-merge the record when the named template's own source is gone (same bar as #20483 and the uninstall decision on #24698). Do this here, not in #25180.
Also before approve:
_check_server(:575): refuseKIROCREW_BIN_MCP_SERVERSnames (kirocrew-core,kirocrew-debug, ...) for templates that do not declare them; KAS projection and the launch rewriter treat those names specially (acp/kas_agents.py:686,rewriter_launch.py:322).agent_sdk/backends_mcp.py:505ACP_BACKENDS_TEMPLATE_ADDITIONS_AT_SPAWN = {kas, claude, codex}butsession_mcp.py:751merges for every mirrored host, so deepseek / opencode / goose / copilot get the server while the card will say "unsupported". Gate the merge on the set, or widen the set and say so.- Confirm in the body that the MCP launch-approval gate (
mcp_gateway/launch_approval.py:1401) runs for an added server on every merge path including the KAS wire, where KAS does the launch. remove_additiononly edits the record; conductor spec files keep the server until the next installer run and live sessions until reset. Part (b)'s Undo must trigger a conductor rebuild and say "applies to new sessions".
Nits: sandbox_leaves.py:703 says "not hidden" while :816 and paths_lists.py:411 hide the file; the agent detail / capabilities readouts do not show spawn-merged additions, only kirocrew doctor does; acp/kas_agents.py:131 strips plaintext env for non-managed servers, so an addition needing an API key may arrive on KAS without it (test it in part (b)).
Posted by code-reviewer (Kiro Crew member) on behalf of @CrysisDeu. Full report on file.
|
Holding 2258b7b for human review. This PR changes which MCP servers agent sessions launch, carrying the user's Open items on this head:
To clear: settle the maintainer's decision in this PR, gate the spawn merge on the backend set (or widen the set and document it), and get a human approval for the sensitive files. CI is green and auto-merge waits for the required approval. — crew-pr-reviewer (r134) |
chenmingwei23
left a comment
There was a problem hiding this comment.
Approved: lanes green, readiness: passed.
Problem / Motivation
Goal: Give the conductor templates and templates Kiro Crew does not write a record of user-approved MCP servers that lives outside their spec files and is merged into their sessions, so a server the user approves survives every rebuild.
A server cannot be added to a built-in template by any route today.
_conductor_mcp_serversrebuilds each conductor'smcpServersto exactlykirocrew-core,kirocrew-dashboardandkirocrew-workon every rebuild, the worker mirrors the default agent, and a third-party custom agent may be rewritten by its own installer. A server written into one of those spec files is wiped, or reads the same as a hand edit. This is part (a) of #25157: the record, the merge at every path a template's servers pass through, removal, and a doctor row. Part (b), thekirocrew-corerequest tool, gateway route and change card with Undo, builds on this module.Why it matters
Without a supported place to keep an approved server, an agent that lacks a capability either stops or works around the gap, for example by launching an MCP server's binary from the shell, which bypasses the per-tool gate, approvals and the audit trail. The request card in part (b) needs a store that keeps the grant across rebuilds, adds no trust, and can be undone.
Not a goal
kirocrew) and the worker (kirocrew-worker).kirocrew.jsonalready holds every server installed through the MCP page, and the worker mirrors it, so neither needs the record; it refuses both with a reason that sends the user to the MCP page (owner decision on this PR).addition_supportanswers unsupported there with a reason that part (b)'s card shows.live_sessions_apply_mcp_livegate.What changed (motivation → approach → change)
Goal → one record outside every spec, one ADD-only merge at each path a template's
mcpServerstakes → what was built:src/kiro_crew/template_mcp_additions.py(new). The record istemplate-mcp-additions/additions.jsonunder the data home: owner-only (0600file,0700directory), atomic writes, an in-process lock plus a cross-process advisory lock on a sidecar. Each entry is a gateway-resolved server entry (command/args/envorurl/headers,type,timeout) plusapproved_by,approved_atandcard_id. Public API for part (b):read_additions,list_additions,add_addition,remove_addition(withcard_id, removes only that card's approval),merge_into,merge_into_spec,merge_at_spawn,addition_support(template, backend),addition_reach(template).addition_support(template, backend): a conductor is supported on every backend that runs a spec's servers (agent_sdk.drivers.acp.backend_delivers_spec_servers: kiro-cli and KAS read the spec, a mirrored backend gets it in its array) and refused withNO_SPEC_SERVERS_REASONon pi (broker-only). Any other covered template needsACP_BACKENDS_TEMPLATE_ADDITIONS_AT_SPAWN.addition_reachanswers()for a refused template.autoApprove,allowedToolsand every key outsideENTRY_KEYSare refused on write and skipped on read. A merge adds the server and its@servermount intools, never anallowedToolsentry or anautoApprove, so its tools prompt until granted separately and POLICY ∩ PROFILE is unchanged.template-mcp-additionsis registered likemcp-launch-approvals: file-tool write-protected (_WRITE_PROTECTED_HOME_PATHS), read-only and pre-created for the OS sandbox (_CREW_READONLY_LEAVES,_CREW_PRECREATE_READONLY_DIR_LEAVES), no-symlink (_CREW_NOFOLLOW_READONLY_DIR_LEAVES), and withheld from foreign harness children (_CREW_CHILD_WITHHELD_LEAVES). Without the seal a sandboxed writer could record a server of its choosing.addition_supportreturns andadd_additionenforces: the default agent and the worker (DEFAULT_REASON), a crewmate's service templates (CREWMATE_REASON), and every other template Crew writes (BUILT_IN_REASON). A refused template is never merged, even from a hand-edited record.disabled/disabledTools, which then narrows the approved entry):conductor_agents._merge_template_additions, right after_conductor_mcp_servers(the deprecatedkirocrew-ledger-conductoralias reads and writes its successor's record);merge_at_spawnin every branch ofharness/kas.resolve_projected_specand the bound app-agent branch ofsession_extras(KAS wire), and insession_mcp._session_spec_and_snapshot_for(claude/codex array), never written to the file. Positive membership in a new capability set,ACP_BACKENDS_TEMPLATE_ADDITIONS_AT_SPAWN = {kas, claude, codex}, each with a live capture of a spec-declared server running; classified in the x-capture gate and as off-card.kirocrew doctorprints onemcp additions:row per template that has any (server, card, date). Silent otherwise; never an issue.src/kiro_crew/docs/agent-spec-fields.md(where each template is merged and what it reaches),docs/system-specs/modules/agent-host-contract.md§5 (per-harness row, including the kiro-cli gap),docs/architecture/mcp.md(new "Per-template MCP additions" section),docs/system-specs/modules/harness-parity.md(the new set under H6),docs/system-specs/modules/security.md(the sealed leaf and the no-trust rule).Backwards compatibility
Compatible: with no record on disk every path behaves exactly as on main; the merges add nothing. The default agent, the worker and their rebuild are untouched.
Removes nothing: the diff only adds a record, merge calls, a sealed leaf and a doctor row; no path, field, key or function is hidden, tightened or removed.
Tests
test/test_template_mcp_additions.py(50 tests):0600/0700modes, every trust key refused on write, malformed entries refused, a hand-editedautoApprovenever reaching a merge, ADD-only merge, card-scoped remove, an alias writing and removing its successor's record, an unreadable record never overwritten;add_addition, byaddition_reachand by the spawn merge even from a planted record; crewmate service templates and every other built-in template (the heartbeat included) the same;DEPRECATED_AGENT_SPECS,_MAIN_AGENT_NAME, the worker file),addition_reachchecked against a real install of every conductor and the worker, conductor support matched againstbackend_delivers_spec_serversfor every known backend and refused on pi, other templates needing a per-session channel;@serverintoolsand no grant; removed on the next install; another template's addition does not leak; a conductor left alone by the spawn merge;merge_at_spawnmerges a custom template and writes nothing; the array hosts' read and the KAS user-level, project-checkout and crewmate-folder reads all carry the addition and the spec file is unchanged;Mutation checks (each production guard replaced by its pre-change form, the suite above re-run):
addition_supportadd_additioncoverage check removedNot covered by a test: the bound app-agent branch in
KasHarness.session_extras(onemerge_at_spawncall, the same as the four tested branches).Also run green locally: the worker, conductor, governed-spec-tail, MCP rebuild, agent refactor contract/facade, backend cards, agent-sdk capabilities, host-contract parity, sandbox governance mask, doctor and session-MCP/KAS suites (about 3,000 tests), plus
check_harness_parity.py,check_comment_history.py,check_file_line_cap.py,check_agent_sdk_boundary.py,check_sync_io_in_async.pyandscripts/docs-lint.sh. Two local failures are host state and fail identically onorigin/main:test_is_kiro_cli_is_positive(a~/.mcp.jsonon this host trips the Copilot refusal) andtest_the_backend_denies_both_destinations.Manual verification
N/A for a live gateway: the record has no writer until part (b) lands, and every merge path is exercised by tests that run the real installers, the real rebuild and the real spawn reads. Not verified here: macOS and Windows (the lock uses the existing
platform_compat.file_lockand the seal uses the existing leaf lists, unchanged per platform), and a live KAS, claude or codex session carrying an addition (this rests on the existing live captures cited atACP_BACKENDS_TEMPLATE_ADDITIONS_AT_SPAWN).Related Issues
Consumer: #25180 (part (b)) is stacked on this branch and adds the production callers of
add_additionandremove_addition(the request card and its Undo). Merge order: #25172, then #25180.Refs #25157 (part (a) of two)
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributed under the project's Apache-2.0 license.