Skip to content

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

Merged
buluoray merged 2 commits into
mainfrom
fix/kas-n6-mcp-projection
Nov 7, 2026
Merged

buluoray merged 2 commits into
mainfrom
fix/kas-n6-mcp-projection

Conversation

@iamwhatever

@iamwhatever iamwhatever commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A kiro-cli agent run on the KAS backend gets the same MCP servers, tool limits and start budget it gets on kiro-cli.

On KAS today:

  • An agent with tools: ["*"] and no includeMcpJson: true starts every server in ~/.kiro/settings/mcp.json and the workspace .kiro/settings/mcp.json. kiro-cli loads none of them.
  • A glob disabledTools entry (write_*) on an mcp.json server switches nothing off, because KAS matches those names exactly.
  • A server with no timeout gets 60 s to start, where kiro-cli gives 120 s, so a first-run npx/uvx server fails.
  • kiro-cli's mcp.initTimeout and the useLegacyMcpJson spelling are ignored.

Why it matters

Every kiro-cli user moving to KAS hits at least one of these. The first one runs tools the agent's author never enabled. The second leaves on tools they meant to switch off. The timeout one makes slow servers fail with no clear cause.

Not a goal

  • Changing KAS (kiro-agent) code. Every fix is in Crew's KAS adapter.
  • MCP OAuth fields (tracked separately).
  • chat.defaultModel from cli.json (a different batch).
  • Brace {a,b} and bracket [...] globs in disabledTools: KAS's excludedTools matches * and ? only, and globs are not expanded by hand here.
  • Crew's own capability readers (agent_capabilities.py, the materializers), which still assume an absent includeMcpJson is true. They pin false on every spec they write, so no behaviour changes there.

What changed (motivation → approach → change)

KAS reads the same mcp.json files kiro-cli does but decides from them differently, so the fix re-states kiro-cli's decisions in fields KAS already honours. The new module acp/kas_settings_mcp.py holds all of it.

  • Opt-in flag. includeMcpJson and its alias useLegacyMcpJson both travel as includeMcpJson. A missing key means false: kiro-cli declares it #[serde(default, alias = "includeMcpJson")] use_legacy_mcp_json: bool, and loads mcp.json servers only behind if use_legacy_mcp_json.
  • Undeclared servers. When the agent does not opt in, each mcp.json server that neither its block nor its spec's own mcpServers names goes into excludedTools as @server (excluded_whole). The harness stamps the spec's names as declared before projection, because a declared server can reach KAS in the session-level array instead of the block. Kiro Crew's own servers and the ASBX_KIRO_MANDATORY_MCPS servers are never excluded. No notice is shown.
  • Pooled stubs. The gateway also pools the settings files' own servers into the session-level array. without_excluded_stubs drops the stub of an excluded server; create_session and load_session call it before they bind the one roster the request, the session report and the unresolved-ref guard all read.
  • Existing agent files. acp/kas_mcp_json_legacy.py keeps KAS's own behaviour for agent files that already exist when the rule first runs (see Backwards compatibility).
  • Glob disabledTools. A file server KAS still starts that the agent does not declare, pooled stubs included, has its glob entries carried as @server/<pattern>, which KAS globs.
  • Unreadable workspace file. When the workspace mcp.json cannot be read, the global file's servers are still named, so its exclusions stand.
  • Timeout. Every server left in the agent block without timeout gets 120 000 ms, or mcp.initTimeout when that is longer (capped at KAS's 600 000). timeoutMs is mapped to timeout.

Where it runs: the file reads happen in the KAS harness's existing projection thread, beside the session's own directory. The harness stamps the result on the active entry under a new Crew-only key. attach_kas_custom_agents applies the stamp against the final mcpServers array and strips the key. The session-new and session-load paths gain one step, the pooled-stub filter above. The session directory reaches the harness through one new optional session_cwd argument on the existing _kas_custom_agents / session_extras seam, which the other harnesses ignore. cli.json is read through the same credential-gated reader as mcp.json.

Docs: src/kiro_crew/docs/agent-spec-fields.md and src/kiro_crew/docs/coming-from-kiro-cli.md state kiro-cli's real default for a missing includeMcpJson, the KAS exclusion, and that existing agent files keep their servers.

Known limit, in a shortcut: comment: a server hoisted into the session-level array (every user server on session/load) keeps KAS's 60 s, because KAS's session-level element has no timeout slot.

Backwards compatibility

Existing agent files keep today's behaviour. The first KAS session after this ships, whichever agent it runs, records, once, every agent file in ~/.kiro/agents that states neither includeMcpJson nor useLegacyMcpJson. Those agents keep loading the global and workspace mcp.json servers on KAS, as they do today. The list lives in the data home (.migrations/kas_mcp_json_legacy_agents.json). It is never rebuilt, and the agent files are never edited, because Kiro CLI reads the same directory and an added key would change what Kiro CLI loads.

Agent file On KAS after this PR
Already there, states no key keeps every mcp.json server (unchanged)
Already there, later says includeMcpJson: false only its own servers
Says includeMcpJson: true keeps them (unchanged)
Says includeMcpJson: false only its own servers, as Kiro CLI does
Written after the list, states no key only its own servers, as Kiro CLI does
Default kirocrew agent, every Bot unchanged: Kiro Crew copies the user's servers into their own mcpServers

Breaking, for the third and fourth rows only. The release note: "On the default harness, a new agent file that does not set includeMcpJson: true loads only the MCP servers it lists, as on Kiro CLI. Agent files you already have keep loading your mcp.json servers."

The list keys an entry by the file's name and its declared name, not by inode or creation time. An editor that saves by writing a new file and renaming it gives the file a new inode on every save, so an identity key would drop a file its user only edited. The cost: a file deleted and recreated under the same name stays on the list. A listed file that later states either key follows that key, so an explicit false turns the servers off. An unreadable or invalid agent file is skipped when the list is recorded. A directory that cannot be listed records nothing, so a later session tries again. An unreadable or malformed list keeps nobody and is not rebuilt. Project .kiro/agents files are not listed, and a checkout's spec is never kept by a listed name: KAS never honours includeMcpJson from a checkout's spec (PROJECT_SPEC_HONOURED_KEYS).

The Kiro CLI wire is unchanged (the wire-parity goldens pass). Writer sweep on main: every agent spec Kiro Crew writes pins includeMcpJson: false (agent.py, agent_materialization/service_agents.py, agent_materialization/auto_approve.py) and carries its servers in its own block.

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

  • test/test_kas_settings_mcp.py (new): the alias; undeclared servers excluded whole with the flag absent or false; spec-declared, Kiro Crew and mandatory servers kept; a pooled stub is not a declaration and is dropped, but keeps its workspace glob disabledTools; an unreadable workspace file keeps the global exclusions; an opted-in or listed agent keeps them and gets their glob disabledTools; workspace-over-global precedence; timeout default / alias / mcp.initTimeout floor and cap; the envelope applying and stripping the stamp.
  • test/test_kas_mcp_json_legacy.py (new): a file without the key is listed by file name and declared name; a file stating either key is not; a listed file that later states the key follows it; a session on an opted-out agent still records the list; the list is recorded once and a later file is not listed; a bad agent file is skipped; a directory that cannot be listed records nothing; a malformed list keeps nobody and is not rebuilt.
  • test/test_acp_runtime.py::test_an_excluded_mcp_json_stub_never_reaches_the_wire[new|load]: the excluded stub is not in the request.
  • Mutations, each reddens its test: no whole-server exclusion; session-array names counted as declared; stamped declared ignored; the stub filter removed on create or load, or dropping nothing; the harness not passing declared or the legacy flag; the list ignoring the key at record time or in the current spec, recorded only after the opt-in check, an unreadable workspace file emptying every exclusion, session-array names counted as declared for globs, reading a failed listing as empty, keeping a checkout's spec, rebuilt every session, failing on bad JSON, rebuilt when malformed, or dropping declared names.
  • test/test_kas_withheld_credentials_notice.py::test_mcp_json_servers_the_spec_does_not_list_add_no_notice: the session notice names no mcp.json server.
  • test/test_kas_settings_mcp.py::TestIncludeMcpJsonDefault: pins that a spec without includeMcpJson does not forward it and is read as not opted in, and that Crew's spec writer pins false.
  • test/test_acp_harness_contract.py: the harness reads the session's directory, not the runtime's; stamps the spec's declared server names; lists a spec without the key, not one that states it, and not a checkout's spec of a listed name.
  • test_acp_runtime.py, test_acp_runtime_load_session.py, test_acp_harness_wire_parity.py, test_kas_agents_mcp_servers.py, test_kas_env_launch_resume.py, test_worker_agent_load_bracket.py: doubles and expectations updated for the new argument and the stamp. test_runtime_bindings.py: the pinned _kas_custom_agents signature digest is updated for session_cwd.

Proof: not provable -- other: a changed test file (test_acp_harness_contract.py) has a copilot test that is red on this host before and after the change, so prove.py reports BASELINE_RED; test_kas_settings_mcp.py imports the new module and fails without it.

Manual verification

N/A — unit coverage; the KAS field behaviour cited above was read from the KAS source at 041fe9ba, not exercised against a live engine.

Related Issues

Fixes #30625

#31533 (the exclusion and the existing-file list) was merged into this branch, so this PR carries both parts and is reviewed as one.

Sibling sweep

Swept: git grep -nE "includeMcpJson|disabledTools|timeout" -- src/kiro_crew/acp/
Sibling: src/kiro_crew/acp/kas_tool_limits.py -- not affected -- already carries agent-declared servers' disabledTools (#29495); this PR covers the mcp.json-file servers
Sibling: src/kiro_crew/mcp_gateway/rewriter_spec.py -- not affected -- builds the pooled stubs for kiro-cli too, which reads includeMcpJson itself; the KAS runtime drops the excluded ones
Sibling: src/kiro_crew/agent_capabilities.py -- not affected -- reads the flag for capability reporting on specs Crew pins false; listed under Not a goal

Pattern harvest

Not generalizable: each gap is a specific kiro-cli setting KAS reads differently; the shared fix is the adapter module itself.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title
  • 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

@iamwhatever
iamwhatever requested review from a team and KiroCrewCaptain as code owners November 5, 2026 19:17
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 5, 2026
@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision a83dd57c709dd267e3df3e73c2fbe8bf050a5dc4 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 5, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ human override accepted

@buluoray overrode this lane for a83dd57c709dd267e3df3e73c2fbe8bf050a5dc4 via /ai-review override (this commit only).

@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks: the agent files that already exist are recorded once and keep their servers, new agent files follow kiro-cli's opt-in rule, and reverting the PR just leaves the recorded list unread.

Notes

  • agent_capabilities.py still treats a missing includeMcpJson as true, but KAS now treats it as false. Two readers now disagree on what a missing key means. Pick one definition (kas_settings_mcp.include_mcp_json) and have both read it in a follow-up, before a third reader copies either one.
  • The list is recorded at the first KAS session, not at upgrade. A user who stays on the kiro-cli harness for a while and switches later will also have the agent files written in that gap kept on the old behaviour. That errs toward keeping servers, which is the safe side, but the release note should say the cut-off is "first KAS session".

[DESIGN-REVIEWED] a83dd57

Description read

[DESCRIPTION-READ] 4dd782d2604f8fa4677d9951a6213d8ee65df54f0d913a8f912c3241655085fd

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 5, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] a83dd57

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

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

@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of a83dd57c709dd267e3df3e73c2fbe8bf050a5dc4 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] a83dd57

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

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 5, 2026
@iamwhatever
iamwhatever force-pushed the fix/kas-n6-mcp-projection branch from 9c2b798 to 3b46d82 Compare November 5, 2026 20:40
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 5, 2026
@iamwhatever
iamwhatever force-pushed the fix/kas-n6-mcp-projection branch from 3b46d82 to 4cd2510 Compare November 5, 2026 21:37
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 5, 2026

@buluoray buluoray left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Kiro Crew Auto-Pipeline [operator: buluoray]:

Thanks for this. Bringing KAS in line with kiro-cli is the right direction, and three of the four changes are clear wins: glob disabledTools entries now take effect, servers get kiro-cli's 120 s start budget, and mcp.initTimeout / the .amazonq/mcp.json fallback are honoured.

Requesting changes on one part: undeclared mcp.json servers are now excluded without telling the user.

Today on KAS, an agent with tools: ["*"] and no includeMcpJson starts every mcp.json server. After this change those servers go into excludedTools as @server and never start. That matches kiro-cli, but every KAS user who relies on those servers today loses them on upgrade, and nothing in the session says why. To them it looks like an MCP server silently broke.

Either of these would resolve it:

  1. Keep the exclusion, and add a one-line session notice that names the servers that were not started and points to where to turn them on (the agent's includeMcpJson, or declaring the server). It should be a pointer to a UI place, not a command to run.
  2. Split the exclusion into its own PR and land the other three changes now, so they can ship without the behaviour change.

A smaller point to settle while you're here: the PR relies on kiro-cli reading a missing includeMcpJson as false, while Crew's own readers (client_mcp_array.py, auto_approve.py, fork_refresh.py, agent_capabilities.py) assume true. The description says they pin false on every spec they write, so behaviour does not change there. A test that pins the projected default for a spec without the key would keep the two from drifting.

Checks on this head: the targeted tests pass (852 passed, 1 failure that also fails on main on this host), and every new guard turns a named test red when broken.

@buluoray

buluoray commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

🤖 Kiro Crew Auto-Pipeline [operator: buluoray]:

A correction to option 1 in my review above: please drop the session-notice idea. Users should not have to understand includeMcpJson or mcp.json to keep their tools working. The change should simply not take servers away from anyone who has them today. Either of these does that:

  1. Split the undeclared-server exclusion out, and land the glob disabledTools, the 120 s start budget and the mcp.initTimeout / .amazonq/mcp.json changes now.
  2. Keep the exclusion, but migrate once on upgrade: agents that currently run on KAS with mcp.json servers keep them (for example, by recording the opt-in for them), and only agents created after the change follow kiro-cli's default.

Either way, nothing a user relies on today should disappear on upgrade.

@buluoray

buluoray commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

🤖 Kiro Crew Auto-Pipeline [operator: buluoray]:

Updating my earlier suggestions after looking closer. I am withdrawing the migration option: Crew should not rewrite agent files it did not author.

Some facts that change the picture:

  • Every agent spec Crew writes already pins includeMcpJson: false (agent.py:1407, agent_materialization/service_agents.py, auto_approve.py, agent_parts/spec_rebuild.py). So the undeclared-server exclusion only reaches agent files Crew did not write: hand-written ones, or ones another tool installed for kiro-cli.
  • For those files, the exclusion restores what they had on kiro-cli before KAS became the default backend, and it keeps tools their authors never enabled from loading. So I agree with the direction.
  • It is still a behaviour change for anyone who started relying on those servers on KAS, so it should not ship in a patch release.

Proposed path:

  1. Split the undeclared-server exclusion into its own PR against main, with a release-note line, to go out in the next minor release.
  2. Keep this PR to the other three changes (glob disabledTools, the 120 s start budget, mcp.initTimeout and the .amazonq/mcp.json fallback). Those are clear fixes we would like to take into the 0.12 patch line once merged.

Happy to re-review as soon as the split lands.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: passed Eligible automated validation passed for the current revision labels Nov 5, 2026
@iamwhatever
iamwhatever force-pushed the fix/kas-n6-mcp-projection branch from 4cd2510 to 7b2f71b Compare November 6, 2026 07:40
@iamwhatever

Copy link
Copy Markdown
Contributor Author

@buluoray Thanks. Addressed on head 7b2f71b (rebased onto main f5340cc), taking your option 1.

Undeclared mcp.json servers. The exclusion stays. A new KAS chat now shows one notice line naming each server that was not started, with where to turn it on: Customize → Connections → MCP Servers for an agent Crew manages (Crew re-pins includeMcpJson: false on those, so that flag alone would not stick), or includeMcpJson: true in a hand-edited agent file. It is a pointer, not a command. A server the spec declares, or one switched off in mcp.json, is still excluded but not named, since the line's cause would be wrong for it. The KAS harness builds the line in session_extras (kas_settings_mcp.not_started_notice), on the same row as the withheld-credentials notice, so the Kiro CLI construction path is unchanged.

includeMcpJson default. test_kas_settings_mcp.py::TestIncludeMcpJsonDefault pins both halves: a spec without the key is not forwarded and is read as not opted in, and Crew's spec writer (govern_spec) pins false, so the true default in client_mcp_array.py / auto_approve.py / fork_refresh.py / agent_capabilities.py never meets the projection. The readers' own default is tracked in #30822.

Also from local review: entries merged from a workspace .amazonq/mcp.json now lose their autoApprove, so a repository file cannot pre-approve tools past Crew's gate.

Tests: TestNotStartedNotice, test_the_payload_names_the_mcp_json_servers_kas_is_told_not_to_start, test_a_merged_entry_loses_its_auto_approve; each fails without its change. Local GPT and Opus reviews pass on this head.

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Human judgment recorded

@buluoray recorded a owner-decision release (class owner-decision) for the first-principles AI finding on 957890b23e8d4e2647d5f73481cab48fef3e96a1.

maintainer accepts that new KAS agent files without includeMcpJson load only their own servers, as on Kiro CLI; existing files are kept by a one-time list. Decision: #30712 (comment)

This decision applies only to this commit. A new push requires a new judgment.

@github-actions github-actions Bot added merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 7, 2026
@buluoray
buluoray force-pushed the fix/kas-n6-mcp-projection branch from 957890b to 28a066e Compare November 7, 2026 06:46
@buluoray

buluoray commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

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

  • Pooled global servers shadow the legacy workspace fallback

Rebutted (downgraded on adjudication): it needs an opted-in agent with no <cwd>/.kiro, a pooled global server, and a legacy <cwd>/.amazonq/mcp.json entry of the same name with a different command, all at once.
The session then runs the user's own global server instead of the legacy workspace copy of it; nothing outside the user's configuration is exposed and no exclusion is lost.
Making the legacy file outrank a pooled stub would mean un-pooling that server for this one fallback; kept as is.

@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Nov 7, 2026
@buluoray

buluoray commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

/ai-review override first-principles 28a066e owner-decision: maintainer accepts that new KAS agent files without includeMcpJson load only their own servers, as on Kiro CLI; existing files are kept by a one-time list. Decision: #30712 (comment)

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Human judgment recorded

@buluoray recorded a owner-decision release (class owner-decision) for the first-principles AI finding on 28a066eaa8a5e3d146184bf9e98dbf2013fab37b.

maintainer accepts that new KAS agent files without includeMcpJson load only their own servers, as on Kiro CLI; existing files are kept by a one-time list. Decision: #30712 (comment)

This decision applies only to this commit. A new push requires a new judgment.

@buluoray

buluoray commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

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

  • Legacy workspace settings bypass the checkout MCP trust boundary

fixed in 10691f0: with_legacy_mcp_json merges <cwd>/.amazonq/mcp.json only when session_mcp._project_mcp_trusted(work_dir) allows a checkout to choose MCP servers; that verdict is False, so a repository's file is never merged and the user-level agent's own servers stand.
This is the same refusal a checkout agent spec's servers already get, so the legacy fallback no longer launches repository commands.
Test: test_an_untrusted_checkout_is_never_merged; removing the gate turns it red. builder-security checked: the change only removes what is launched.

@buluoray

buluoray commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

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

  • A refused mcp.json turns the new exclusion off instead of on

accepted-and-deferred to #32233: a symlinked settings file is refused by the no-follow reader, so its servers are not named and the session falls back to today's KAS behaviour; no session gets more than it does before this PR.
The fixes (a link-following names-only read, or refusing the session) touch the deliberate no-follow read or break symlinked dotfiles, so they get their own change; #32233 carries both options, an owner and a due date.

@buluoray

buluoray commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

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

  • Checkout-controlled server names can forge gateway log entries

fixed in 6992790: without_excluded_stubs now logs sanitize_sink_text(name, NAME_CAP) from mcp_session_report, the same cleaner the MCP status report uses for server names, so a name carrying a newline or control character collapses onto one bounded line.
Same class, same fix: the two agent file %s ... lines in kas_mcp_json_legacy.py now sanitize the agent file name and the read error (ERROR_CAP). The other log calls in both modules print only paths the crew builds itself or fixed text.
Tests: test_a_dropped_stub_name_cannot_forge_a_log_line, test_an_agent_file_name_cannot_forge_a_log_line, test_a_read_error_cannot_forge_a_log_line; reverting any one of the four sanitizer calls turns one red. builder-security checked: the change only narrows what reaches a log line.

@buluoray

buluoray commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

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

  • Newline-bearing filenames fail on Windows

fixed in 9c5f9d7: test_an_agent_file_name_cannot_forge_a_log_line no longer creates files. It fakes iter_agent_spec_files_strict and read_agent_spec_strict, so the newline-bearing names are plain Path values and the test runs the same on Windows and POSIX.
Reverting either file-name sanitizer in kas_mcp_json_legacy.py still turns it red. No other test in this diff writes a file whose name carries a control character.

@buluoray

buluoray commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

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

  • Docs say a Kiro CLI agent without includeMcpJson loads no mcp.json servers

fixed in f9467e5 by option 2 (scope the wording to KAS). coming-from-kiro-cli.md again says a custom agent on the Kiro CLI harness loads ~/.kiro/settings/mcp.json unless it sets "includeMcpJson": false, and states the new rule for the default harness only.
agent-spec-fields.md: the field row and the kiro-cli column now say kiro-cli itself reads an absent flag as false, but Crew's rewriter still pools the global mcp.json servers unless the spec states false. The Kiro CLI code path is unchanged on purpose: rewriter_spec._rewrite_single_spec and agent_capabilities._materialize are shared beyond KAS, and this PR only changes KAS.

@buluoray

buluoray commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

/ai-review override first-principles f9467e5 owner-decision: maintainer accepts that new KAS agent files without includeMcpJson load only their own servers, matching kiro-cli's own default for an absent flag; existing files are kept by a one-time list. Decision: #30712 (comment)

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Human judgment recorded

@buluoray recorded a owner-decision release (class owner-decision) for the first-principles AI finding on f9467e562785f473ee7616fcd1b9daa4d3294cbd.

maintainer accepts that new KAS agent files without includeMcpJson load only their own servers, matching kiro-cli's own default for an absent flag; existing files are kept by a one-time list. Decision: #30712 (comment)

This decision applies only to this commit. A new push requires a new judgment.

bolichen97
bolichen97 previously approved these changes Nov 7, 2026

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving at f9467e5. A kiro-cli agent run on KAS now gets the MCP servers, tool limits and start budget its mcp.json files give it on kiro-cli. includeMcpJson (or its alias useLegacyMcpJson) goes on the KAS agent block, a glob disabledTools entry is carried as @server/<pattern> so KAS applies it, and timeoutMs is read as an alias. Existing agent files that set neither key are recorded once and keep KAS's own behavior, so no running agent loses a server it starts today. No regex or glob matching is added on Crew's side, and all checks pass.

Joe Guo and others added 2 commits November 7, 2026 16:23
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.
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.
@buluoray

buluoray commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

/ai-review override first-principles a83dd57 owner-decision: maintainer accepts that new KAS agent files without includeMcpJson load only their own servers, matching kiro-cli's own default for an absent flag; existing files are kept by a one-time list. Decision: #30712 (comment)

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Human judgment recorded

@buluoray recorded a owner-decision release (class owner-decision) for the first-principles AI finding on a83dd57c709dd267e3df3e73c2fbe8bf050a5dc4.

maintainer accepts that new KAS agent files without includeMcpJson load only their own servers, matching kiro-cli's own default for an absent flag; existing files are kept by a one-time list. Decision: #30712 (comment)

This decision applies only to this commit. A new push requires a new judgment.

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.

KAS: kiro-cli mcp.json settings (undeclared servers, glob disabledTools, 120 s timeout, legacy spellings) are not carried

4 participants