Repository navigation
fix(kas): exclude the mcp.json servers under KIRO_HOME too - #36145
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the fix is additive, scoped to KAS exclusion naming, and leaves the dashboard-owned Notes
[DESIGN-REVIEWED] 7fe490a Description read[DESCRIPTION-READ] 810e703a7badae5ec19ecf51ec5b9b710ab98bbf5d933c65a81d57f73a239a24 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. The fix works at the mechanism level, and the description names the deeper cause ( What this change shipsInventory (6 items) — 6 justifiedIntent: when
[FIRST-PRINCIPLES-REVIEWED] 7fe490a Description read[DESCRIPTION-READ] 8cb92a46abd8687929fc97632baaf5c6bbf48a6e49c1b6b7cadfbf5a1bc9b0f2 That sha256 names the PR description this verdict read. Recompute it with |
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: |
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: |
04949b4 to
b9d0704
Compare
|
span=657c0b2e43d0
|
On KAS an agent that does not opt in to mcp.json loads only the servers it declares: Kiro Crew names every mcp.json server and tells KAS to leave the undeclared ones out. Kiro Crew's global path is ~/.kiro/settings/mcp.json and does not follow KIRO_HOME, while KAS reads its global file under KIRO_HOME. With KIRO_HOME set to another folder, as in every Dev Fleet pod, the servers of that file were never named, so a folder agent got them. The settings stamp now also names the servers of $KIRO_HOME/settings/mcp.json when that is another file. It is read only to add exclusions and to carry disabledTools. A file that cannot be read adds one notice line and the session still starts. With KIRO_HOME unset nothing changes. Closes #36144
b9d0704 to
7fe490a
Compare
|
span=0a950f28cea2
|
bolichen97
left a comment
There was a problem hiding this comment.
I read the whole diff on this head, and all checks are green.
- This applies main's existing rule to a path it missed. On main, a KAS agent that has not opted in is told to exclude the servers of the global
mcp.json. But Crew reads that file atagent._KIRO_MCP_JSON, which does not followKIRO_HOME, while KAS reads$KIRO_HOME/settings/mcp.json. WithKIRO_HOMEset elsewhere, the servers only KAS's file names slipped past the exclusion. Naming them closes that gap. It adds no rule of its own, so it is not added strictness. KIRO_HOMEunset, or set to Crew's own folder, reads only Crew's file, exactly as on main, and both cases have a test. An opted-in agent keeps the servers and gets theirdisabledToolsglobs, as it already does for Crew's file.- For a server both files name, the
disabledToolsof both are kept and neither lifts the other's. So a tool the dashboard turned off in Crew's file stays off. Muting follows theKIRO_HOMEentry, the one KAS starts the server from. - Failures stay non-fatal, matching main's pattern. An unreadable Kiro-home file adds one notice line and names nothing, and the session still starts. An unresolvable Crew path does not hide the Kiro-home exclusions (the looping-symlink test).
- No regex. The spec text matches the code.
Approving. Auto-merge is already armed by its holder, so I leave it as is.
|
Post-merge note from the review of head 7fe490a, which finished after this merged. The items below now apply to main, so a follow-up PR would fix them.
Optional:
|
On KAS an agent that does not opt in to mcp.json loads only the servers it declares: Kiro Crew names every mcp.json server and tells KAS to leave the undeclared ones out. Kiro Crew's global path is ~/.kiro/settings/mcp.json and does not follow KIRO_HOME, while KAS reads its global file under KIRO_HOME. With KIRO_HOME set to another folder, as in every Dev Fleet pod, the servers of that file were never named, so a folder agent got them. The settings stamp now also names the servers of $KIRO_HOME/settings/mcp.json when that is another file. It is read only to add exclusions and to carry disabledTools. A file that cannot be read adds one notice line and the session still starts. With KIRO_HOME unset nothing changes. Closes #36144 (cherry picked from commit 19f781c)
Problem / Motivation
Goal: On KAS, an agent that does not opt in to
mcp.jsonno longer gets the global MCP servers whenKIRO_HOMEis not~/.kiro.On KAS an agent that does not opt in to
mcp.jsonshould load only the servers it declares (#31533). Kiro Crew names everymcp.jsonserver and tells KAS to leave the undeclared ones out.Kiro Crew builds its global path as
Path.home() / ".kiro" / "settings" / "mcp.json"(agent._KIRO_MCP_JSON), which does not followKIRO_HOME. KAS reads its global file underKIRO_HOME. When the two differ, Kiro Crew never sees the servers of$KIRO_HOME/settings/mcp.json, sends no exclusion for them, and KAS starts them. A folder agent, which can never opt in, then lists tools from a server that nobody enabled for it.Why it matters
Every Dev Fleet pod runs this way: a pod keeps the real
HOMEand setsKIRO_HOMEto<pod home>/kiro. So does a user who setsKIRO_HOMEby hand. For them the rule from #31533 does not hold for the global file, and an agent from a cloned folder reaches global servers.Not a goal
mcp.jsonfollowKIRO_HOME(the spec rebuild, the dashboard's MCP editor, discovery). Non-default-home instances should consume only agent specs their own rebuild wrote (private KIRO_HOME agents dir) #12986 tracks that.~/.kiro/settings/mcp.json, and that reading stays as it is.mcp.jsonservers (fix(kas): carry kiro-cli mcp.json settings onto the KAS agent block #30712).What changed (motivation → approach → change)
Symptom: in a pod, the folder agent
probe-proj(tools: ["*"], noincludeMcpJson) listedtool::probejson::probe_pingfrom the pod'skiro/settings/mcp.json. A server in the workspace's ownmcp.jsonwas left out as it should be.Cause:
kas_settings_mcp._file_serverstakes the global names fromsession_mcp.native_settings_sources, which readsagent._KIRO_MCP_JSON. UnderKIRO_HOMEthat is not the file that KAS reads, soexcluded_wholehas no name to exclude.Change:
_file_serversnow also names the servers of$KIRO_HOME/settings/mcp.jsonwhenKIRO_HOMEis set and that file is not Kiro Crew's own global file (_kiro_home_servers). The order follows KAS: Kiro Crew's global file, then theKIRO_HOMEfile, then the workspace file.The new read only adds names. It can add an
@serverexclusion or carry a server's globdisabledTools; it cannot lift an exclusion or a restriction that main applies today. I did not pointagent._KIRO_MCP_JSONitself atKIRO_HOME: that constant also feeds the restrictions that the dashboard writes to~/.kiro, and moving it would drop them underKIRO_HOME.Security note (read against the builder-security skill): the PR adds no listener, route, bind, auth or storage change. It narrows what a KAS session loads. One choice to state: when the
KIRO_HOMEfile exists but cannot be read, the session still starts, one notice line names the file, and its servers are not excluded. That is what main does for that file in every case today, and a session that refuses to start was ruled out.Backwards compatibility
Compatible: with
KIRO_HOMEunset, or set to Kiro Crew's own~/.kiro, the stamp is the same as on main. WithKIRO_HOMEset to another folder, a not-opted-in agent stops getting the servers of$KIRO_HOME/settings/mcp.json, which #31533 already meant. An agent that opts in, and an agent file on the #30712 list, keep them.Reader: src/kiro_crew/acp/kas_settings_mcp.py:excluded_whole -- chat -- reads
fileServersas before; an opted-in or listed agent still gets an empty set (test_an_opted_in_agent_keeps_it_and_gets_its_glob_disabled_tools)Reader: src/kiro_crew/acp/kas_settings_mcp.py:without_excluded_stubs -- chat -- drops pooled stubs by the same names; a
KIRO_HOME-only server has no pooled stub, so nothing more is droppedReader: src/kiro_crew/acp/kas_subagent_targets.py:stamp_settings_mcp -- subagent -- sub-agent targets take the same stamp and get the same added names
Tests
test/test_kas_settings_mcp_kiro_home.py(new, 8 tests):KIRO_HOMEfile is excluded;disabledTools;KIRO_HOMEentry wins over Kiro Crew's global entry and loses to the workspace entry;KIRO_HOMEunset only Kiro Crew's global file is read;KIRO_HOMEthat is Kiro Crew's own folder is read once;KIRO_HOMEfile adds one notice line and the stamp is still built;session_extrasandattach_kas_custom_agents, sendsexcludedTools: ["@homeonly"]withKIRO_HOMEset and no exclusion without it.Five of them fail on main; the three that pin today's behaviour pass both ways.
Proof: PROVEN test/test_kas_settings_mcp_kiro_home.py::test_a_server_only_in_the_kiro_home_file_is_excluded, test/test_kas_settings_mcp_kiro_home.py::test_the_kiro_home_entry_wins_over_crews_global_and_loses_to_the_workspace, test/test_kas_settings_mcp_kiro_home.py::test_a_folder_agents_kas_session_carries_the_exclusion[True] (head 04949b4)
Also run on the head: the 15 test files that mention this code plus
test_flake_pattern_ratchet.py(1,100 passed, 2 skipped, 1 failed). The one failure istest_acp_harness_contract.py::test_a_missing_self_served_binary_names_its_install_command[copilot]; it reads a.mcp.jsonin this machine's home folder and fails the same way in a worktree without this change.Manual verification
In an isolated pod on this branch (KAS, a real model turn):
probejsonin<pod home>/kiro/settings/mcp.json; folder agentprobe-projwithtools: ["*"].probe-proj, asked to list its tools whose name contains "probe": it answeredNO-PROBE-TOOLand said that it has a shell tool. The session started normally.Before the change the same steps listed
tool::probejson::probe_ping.The pod's frontend bundle was copied from another worktree, because
npm run buildfails on main until #36124 merges. This PR changes no frontend file.Related Issues
Closes #36144
Sibling sweep
Swept: git grep -nE 'Path.home()[^#]*.kiro' -- src/kiro_crew, and git grep -n "_KIRO_MCP_JSON" -- src/kiro_crew
Sibling: src/kiro_crew/acp/kas_settings_mcp.py -- changed here --
_file_serversnames theKIRO_HOMEfile's servers for exclusionSibling: src/kiro_crew/acp/session_mcp.py:1462 -- tracked in #12986 --
native_settings_sourcesand_global_settingsread restrictions fromagent._KIRO_MCP_JSON; the dashboard writes them there, so moving the read alone would drop themSibling: src/kiro_crew/agent.py:589 -- tracked in #12986 -- the constant itself; many readers and the test floor pin it
Sibling: src/kiro_crew/agent_materialization/mcp_sources.py:432 -- tracked in #12986 -- copies global servers into the specs Kiro Crew writes; those specs pin
includeMcpJson: false, so KAS does not add its own file to themSibling: src/kiro_crew/dashboard/handlers/mcp_config_files.py:62 -- tracked in #12986 -- the dashboard's editor of the global file
Sibling: src/kiro_crew/mcp_discovery_server_info.py:66 -- tracked in #12986 -- names the scope of a discovered server
Sibling: src/kiro_crew/apps/bridges_mcp.py:117 -- tracked in #12986 -- an app bridge's read of the shared file
Sibling: src/kiro_crew/apps/bridges_agents.py:91 -- tracked in #12986 -- an app bridge's read of the shared file
The
cli.jsonread formcp.initTimeout(kas_settings_mcp._init_timeout_ms) uses the same folder; it sets a timeout only and is not changed. ThePath.home()paths for skills, hooks, prompts and steering are other files and are not part of this sweep.Pattern harvest
Rule candidate: review-prompt
Pattern: a path under
~/.kirobuilt fromPath.home()where the engine reads the same file underKIRO_HOMEChecklist
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; see the Licensing section of CONTRIBUTING.md.