Skip to content

fix(kas): backport the KAS mcp.json parity fix to 0.12.1 (batch 38) - #32492

Merged
buluoray merged 1 commit into
release/0.12.0from
crew/slack/0.12.1-batch-38
Nov 7, 2026
Merged

buluoray merged 1 commit into
release/0.12.0from
crew/slack/0.12.1-batch-38

Conversation

@buluoray

@buluoray buluoray commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Changes which mcp.json servers a new KAS agent loads; needs Bolin's OK before merge. #30712 is a product decision Ray recorded on its own PR (#30712 (comment)). Two files were resolved by hand (listed under What changed).

Problem / Motivation

Goal: Bring #30712, the KAS mcp.json parity fix that merged on main after v0.12.0, onto release/0.12.0 as one commit in a PR of its own, so it can be reviewed and reverted apart from the other batches.

Why it matters

What a 0.12.0 user sees on KAS today kiro-cli
An agent with tools: ["*"] and no includeMcpJson: true starts every server in ~/.kiro/settings/mcp.json and the workspace .kiro/settings/mcp.json, so it runs tools its author never enabled. loads none of them
A glob disabledTools entry (write_*) on an mcp.json server switches nothing off. globs it
A server with no timeout gets 60 s to start, so a first-run npx/uvx server fails. 120 s
mcp.initTimeout and the useLegacyMcpJson spelling are ignored. honoured

Every kiro-cli user moving to KAS hits at least one of these.

Not a goal

  • No fix that is not already merged on main; nothing is changed only here.
  • No Kiro Cloud Sessions code: acp/harness/kas_cloud.py is not on this branch, so fix(kas): carry kiro-cli mcp.json settings onto the KAS agent block #30712's one-line change to it is dropped.
  • No version bump, no tag, no CHANGELOG.md change. Cutting v0.12.1-rc.N and the bare tag follow docs/build/release.md and stay with the maintainers.

What changed (motivation → approach → change)

The main squash commit was applied with cherry-pick -x onto release/0.12.0 @ b91dae3075 and committed with its cherry picked from trailer.

PR main commit release commit Pick
#30712 load only declared mcp.json servers on KAS; keep existing agent files 6f786d9b99 5f7a949b5a two files resolved by hand, one file dropped

What it does. New module acp/kas_settings_mcp.py: includeMcpJson and its alias useLegacyMcpJson both travel as includeMcpJson, and a missing key means false. When the agent does not opt in, each mcp.json server its block and its spec's mcpServers do not name goes into excludedTools as @server; Kiro Crew's own and the mandatory servers are kept. without_excluded_stubs drops the pooled stub of an excluded server in create_session / load_session. Glob disabledTools entries are carried as @server/<pattern>. A server without timeout gets 120 000 ms, or mcp.initTimeout when longer. New module acp/kas_mcp_json_legacy.py records, once, the agent files that already exist and state neither key; those keep KAS's earlier behaviour. The .amazonq legacy fallback was removed on main before merge, so it is not in this pick.

Prerequisites checked. #31671 (engine_features), #30952 (projected) and #31850 (the kas_permissions.py keys) are already on this branch (#31671 via batch 33, #32229). Nothing else is needed.

Hand-resolved hunks.

File Resolution
acp/harness/kas.py (imports) added stamp_settings_mcp only; the kas_tool_limits.with_switched_off_tools import beside it in the conflict context comes from a main commit not on this branch
acp/harness/kas.py (projection) added #30712's stamp_settings_mcp(...) call after build_kas_custom_agents; the with_switched_off_tools(...) call before it in the conflict context is left out for the same reason
acp/kas_agents.py (imports) added include_mcp_json only; the kas_skill_scope._skill_scope_summary import beside it is from a main commit not on this branch, which keeps _skill_scope_summary in the module
acp/harness/kas_cloud.py dropped: the file is not on this branch

Every other file has added and removed lines identical to the main commit. The commit is authored with the public identity the push guard requires and names its original authors in its message.

Other open batches. None are open against release/0.12.0.

builder-security checked: no bind, listener, route, auth mechanism or storage grant changes. The change only narrows which mcp.json servers a KAS agent starts, and log lines it adds sanitize file-derived names.

Backwards compatibility

Existing agent files keep today's behaviour. The first KAS session after this ships records, once, every agent file in ~/.kiro/agents that states neither includeMcpJson nor useLegacyMcpJson, in the data home (.migrations/kas_mcp_json_legacy_agents.json). Those agents keep loading the global and workspace mcp.json servers on KAS. Kiro Crew never edits the agent files.

Agent file On KAS after this PR
Already there, states no key keeps every mcp.json server (unchanged)
Says includeMcpJson: true keeps them (unchanged)
Says includeMcpJson: false only its own servers, as kiro-cli loads
Written after the list, states no key only its own servers, as kiro-cli loads
Default kirocrew agent, every Bot unchanged

Breaking, for the third and fourth rows only (owner decision linked above). The Kiro CLI harness is unchanged.

Reader: src/kiro_crew/acp/kas_settings_mcp.py:finish_settings_mcp -- entry: chat|cron|subagent -- adds @server only for names absent from the block and the spec's declared servers, never for an opted-in or listed agent; test_undeclared_servers_are_excluded_whole, test_spec_declared_and_crew_and_mandatory_names_are_kept, test_a_legacy_agent_keeps_them_and_its_pooled_stubs
Reader: src/kiro_crew/acp/runtime_session_create.py:create_session -- entry: chat|cron|subagent -- removes only session-level entries named in excluded_whole, before the roster is bound; test_an_excluded_mcp_json_stub_never_reaches_the_wire[new]
Reader: src/kiro_crew/acp/runtime_session_load.py:load_session -- entry: chat|cron|subagent -- the same on resume; test_an_excluded_mcp_json_stub_never_reaches_the_wire[load]

Tests

Proof: not provable -- other: a backport of a main commit whose proof ran on its own PR

  • CI does not run the backend suite on PRs into release/*, so the related set was run here: every touched test file plus every test_kas_*, test_acp_harness*, test_acp_runtime*, agent-spec, runtime-binding, worker-agent, member-dispatch and chat-turn test file: 126 files, one pytest process per batch of 20, -n 0. 5129 passed. 1 failed (test_acp_harness_contract.py::test_a_missing_self_served_binary_names_its_install_command[copilot]), and it fails the same way on a clean release/0.12.0 checkout with the same command (a host ~/.mcp.json).
  • flake8, isort and mypy (src/kiro_crew/acp) pass; docs-lint and the file line cap pass.

Manual verification

N/A - the fix was verified on its own main PR. The 0.12.1 RC soak is the end-to-end check.

Screenshots / video

Related Issues

Backport to the 0.12 line for 0.12.1 of #30712. The deferred symlinked-mcp.json finding is #32233.

Sibling sweep

Siblings: none -- the source PR carried its own sibling sweep; this PR only carries that fix.

Pattern harvest

Not generalizable: this PR only carries a fix already on main. The source PR has its own harvest.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.

…30712)

* fix(kas): carry kiro-cli mcp.json settings onto the KAS agent block

Undeclared mcp.json servers are excluded as @server unless the agent opts in,
glob disabledTools on reached file servers travel as @server/<pattern>, an
unset per-server timeout gets kiro-cli's 120 s (raised to mcp.initTimeout),
useLegacyMcpJson travels as includeMcpJson, and the workspace .amazonq/mcp.json
is merged under kiro-cli's fallback rule.

* fix(kas): load only declared mcp.json servers; keep existing agent files

kiro-cli loads the global and workspace mcp.json servers only for an
agent that sets includeMcpJson (or useLegacyMcpJson); KAS starts all of
them for tools: ["*"]. Each undeclared server now goes into
excludedTools as @server unless the agent opts in, judged from the
agent block plus the names its spec declares, and the runtime drops the
pooled stub of an excluded server before it binds the roster the
request, the session report and the unresolved-ref guard all read.
Kiro Crew's own and the mandatory servers are kept, and no session
notice is shown.

Agent files that already exist when the rule first runs, and state
neither key, keep KAS's own behaviour: the first KAS session records
them once in the data home. The files are never edited, because
kiro-cli reads the same directory.

---------

(cherry picked from commit 6f786d9)

Backport to 0.12.1: release has no kas_cloud.py (Kiro Cloud Sessions
from PR 25347 are not on release), so its one-line session_cwd
parameter is dropped. In harness/kas.py and kas_agents.py only this
change's own lines are added: the with_switched_off_tools import and
call and the _skill_scope_summary import in the conflict context come
from other main commits that are not on release and are left out.
Every other file applied unchanged.

Original authors: Joe Guo and Ray Xu (#30712).
@buluoray
buluoray requested review from a team and KiroCrewCaptain as code owners November 7, 2026 18:00
@buluoray
buluoray requested review from tim-finnigan and removed request for a team November 7, 2026 18:00
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 7, 2026
@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 5f7a949b5afe71d480c74dfcca5dfe3fe3024941 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 5f7a949b5afe71d480c74dfcca5dfe3fe3024941 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Faithful single-commit backport of a merged main fix with a recorded owner decision; all four session_extras overrides carry the new session_cwd kwarg, and existing agent files are protected by the one-time legacy list.

Notes

  • CI doesn't run the backend suite on release/*, so the local run of 126 files is the only proof for the two hand-resolved kas.py hunks. Re-run the KAS projection tests during the 0.12.1 RC soak, not just the end-to-end check.
  • The legacy list is recorded on the first KAS session, whatever agent that session runs. A user who adds an agent file after upgrading but before their first KAS session gets that file grandfathered in. The upstream PR accepted this, but say it in the release notes.

[DESIGN-REVIEWED] 5f7a949

Description read

[DESCRIPTION-READ] 1ecc2be694f00e3716dddffa1415de3037c2219faa781e8e3cb29f0d09c53236

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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 5f7a949b5afe71d480c74dfcca5dfe3fe3024941 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

This backports #30712, already on main, and declares every item. The one product-shape question is a note, not a block: the base spec already says KAS reads an absent includeMcpJson as false.

Notes

  • Item 1 — inherited: the PR changes what a new KAS agent loads by default ("Breaking, for the third and fourth rows only"). Its only decision record is a PR comment, not an accepted RFC or an /ai-review override first-principles on this head. It is not a BLOCK because base agent-spec-fields.md:514 already says KAS's "tool filter resolves an absent flag to false itself".
  • Item 6 — inherited: the PR rewrites the earlier comment in kas_agents.py, "kiro-cli reads an absent includeMcpJson as TRUE", to say the opposite. The only support is the doc's #[serde(default)] claim, and the description never mentions that the claim was reversed.

What this change ships

Inventory (8 items) — 6 justified

Intent: KAS users get the same mcp.json behaviour on KAS as on kiro-cli, carried onto the 0.12 release line. This is a FIX (a backport).

  1. A new KAS agent that states no key, or says false, no longer starts the global and workspace mcp.json servers it does not declare — inherited: the decision is recorded only in a PR comment
  2. Agent files that already exist and state neither key keep their old behaviour, through a one-time list in the data home — justified
  3. A glob disabledTools entry on an mcp.json server now switches tools off on KAS — justified
  4. A server with no timeout now gets 120 s to start, or mcp.initTimeout when that is longer — justified
  5. useLegacyMcpJson is now honoured on KAS — justified
  6. The comment and docs now say kiro-cli reads an absent includeMcpJson as false — inherited: reverses the earlier pin on the doc's word alone
  7. The pooled stub of an excluded server is dropped on new and resumed sessions — justified
  8. Workspace mcp.json is read from the session's own folder (new session_cwd parameter) — justified

[FIRST-PRINCIPLES-REVIEWED] 5f7a949

Description read

[DESCRIPTION-READ] ba6ce2c0efb99d13b2a34dcdbb7fad332af37ef16e9a5196c29c0e379f603e99

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings (all downgraded on adjudication)

GPT 6.1 flagged blocking issues on 5f7a949b5afe71d480c74dfcca5dfe3fe3024941; Opus 5.5 adjudication downgraded every one of them. Downgraded: the remedy each one needs is disproportionate to the harm it prevents. Adjudication downgraded all 1 blocking finding(s): the remedy each one requires is disproportionate to the harm it prevents.

This comment is updated in place on each push.

Review details

BLOCKING -- src/kiro_crew/acp/kas_mcp_json_legacy.py:120 -- Concurrent first sessions overwrite the one-time legacy snapshot

atomic_write(path, json.dumps({"agents": sorted(names)}, indent=2) + "\n")
Trigger: Two initial KAS sessions enter session_extras → threaded _build → legacy_mcp_json and both read an absent list. One publishes its snapshot; an agent file is added before the delayed session scans and overwrites it. Session admission happens after projection, so it does not serialize these writes.
Outcome: The later agent is permanently grandfathered despite having no opt-in: subsequent projections suppress its whole-server exclusions and retain undeclared pooled MCP servers.
Anchor: defect
Fix: Hold a shared file lock across the absent-check, scan, and publication; reread inside the lock so subsequent sessions reuse the first saved snapshot.

[BLOCK-MERGE-DOWNGRADED] 5f7a949
[GPT-REVIEWED] 5f7a949

Adjudication (Opus 5.5) — is blocking on each finding proportionate?

F1 is LOW harm. It needs three things at once: two KAS sessions both running their first-ever projection concurrently, both reading an absent list (src/kiro_crew/acp/kas_mcp_json_legacy.py:54-56), and a new agent file created inside the milliseconds between the two directory scans (:96-120). The only effect is that this one agent keeps the old KAS behaviour (kas_settings_mcp.py:174), which also applies to every pre-existing file and only starts the user's own mcp.json servers, so no governance ceiling is crossed. It can be undone: adding includeMcpJson/useLegacyMcpJson to the file overrides the list (kas_mcp_json_legacy.py:57-58).
The real fix is a cross-process file lock routed through platform_compat, plus a reread inside the lock, guarding a once-per-install race window. That mechanism outweighs a harm that rare and that easy to reverse.

[ADJUDICATION] 5f7a949b5afe71d480c74dfcca5dfe3fe3024941 total=1 uphold=0 downgrade=1
DOWNGRADE F1 src/kiro_crew/acp/kas_mcp_json_legacy.py:120 reason=disproportionate-remedy
[GPT-ADJUDICATED] 5f7a949b5afe71d480c74dfcca5dfe3fe3024941

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 5f7a949b5afe71d480c74dfcca5dfe3fe3024941 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 5f7a949b5afe71d480c74dfcca5dfe3fe3024941 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 5f7a949

Verdict parsed from the review's SHA-scoped output markers for commit 5f7a949b5afe71d480c74dfcca5dfe3fe3024941.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 5f7a949b5afe71d480c74dfcca5dfe3fe3024941 false-positive: <reason, 20 to 500 characters>

@buluoray

buluoray commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

span=bae5432b6c24
🤖 Kiro Crew Auto-Pipeline [operator: buluoray]:

  • Concurrent first sessions overwrite the one-time legacy snapshot

Rebutted (downgraded on adjudication), as on the source PR (#30712 (comment)): it needs two first-run KAS sessions to both see no list, and a new agent file saved in the window between their two directory scans, once per install.
The worst case lists one extra agent file, which keeps KAS's earlier behaviour (its user's own mcp.json servers) and follows either key once the file states one. This backport carries the main commit unchanged here; a lock would be new code on the release line only.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Nov 7, 2026
@buluoray
buluoray merged commit 44e6f44 into release/0.12.0 Nov 7, 2026
22 of 23 checks passed
@buluoray
buluoray deleted the crew/slack/0.12.1-batch-38 branch November 7, 2026 18:24
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant