Repository navigation
fix(identity): carry session identity to builtin app MCP servers - #19801
Conversation
A builtin app whose manifest runs the host CLI (mochi:mochi) was mounted by kiro-cli straight from the agent spec with no session token, so every tool call refused as identity_unattested for session mcp. kiro_control_plane_servers now re-declares a granted one after the managed servers, with the launch re-derived from the shipped manifest and pinned as registration pins it, so the token attach reaches it.
UX Review (Opus 5.5, fork) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Mochi was only checked on macOS through the direct spec mount. Someone should confirm that a default Linux or Windows install never sends What this change shipsInventory (6 items) — 5 justifiedIntent: let tools on builtin app MCP servers that run Kiro Crew's own code (Mochi) work from a dashboard chat instead of refusing every call. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] 2f55b88 Description read[DESCRIPTION-READ] 4edd1eff5cf4a3c5588a04bfc7bd0459fd717ba8deb43b10db4db00041699d5e That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Check that the gateway is right to give the session token to [DESIGN-REVIEWED] 2f55b88 Description read[DESCRIPTION-READ] df3f5930ec6e85b0c7f9b019a9385ed20f1257ede35b5e42b5a25eac1abbe26d 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 |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
The settings-unreadable return now names the builtin app servers among its withheld verdicts, and the host-CLI launch helper filters the same manifest enumeration builtin_app_mcp_servers() takes its keys from, so a launch can never name a server that set does not trust.
0ee1a83 to
2f55b88
Compare
buluoray
left a comment
There was a problem hiding this comment.
Verdict: APPROVE at 2f55b88a9c
What it fixes
On the Kiro backend, kiro-cli mounts mochi:mochi straight from the spec, so it starts without KIROCREW_STUB_SESSION_TOKEN and every Mochi tool call refuses as identity_unattested for session mcp. The pet never moves and its watchlist never runs. kiro_control_plane_servers now re-declares a granted builtin app server that runs Kiro Crew's own code, with the same per-session element the managed kirocrew-* servers get. Same class as #12476, fixed at the same seam.
What I verified
- Only Kiro Crew's own code gets the token.
builtin_app_host_cli_mcp_launches(apps/execution.py) admits a server only when a shipped, builtin-owned manifest declarescommand: "kirocrew"with stringargsand nourl. It reads the same enumeration asbuiltin_app_mcp_servers, so the two cannot disagree. A user app, a shadowing app and a builtin shipping its own binary get nothing. - The launch is never the spec's. It is re-derived from the manifest and pinned through
bridges._pin_host_cli_command, exactly as registration pins it. A pin that comes back as barekirocrewis skipped. A hand-editedmochi:mochicommand in the spec cannot obtain the element. - Env is owned the same way as the managed servers.
_managed_element_envsanitizes the spec env first, then the pin'sPYTHONPATH/KIROCREW_HOMEgo on top, so a spec cannot move the data home. - Restrictions still win. The app candidates go through the same
allow.grants,native_mount_withholding(mute,disabledTools, non-stdio) andexisting_nameschecks. Unreadable settings now name the app servers in the withheld verdict too. - Off the event loop. The only caller,
runtime._unpooled_control_planes, runs it underasyncio.to_thread, so the manifest reads do not block other sessions. test/test_app_mcp_session_identity.py: 11 passed in a detached worktree of this head (confirmed the worktree'skiro_crewwas loaded).- Mutations, one at a time, tree clean after:
- host-CLI filter removed →
test_only_host_cli_servers_of_builtin_owned_apps_are_launches - builtin-owned narrowing removed → the same test
- grant check on app servers removed →
test_an_ungranted_app_server_gets_no_element - pinned env not applied →
test_granted_builtin_app_server_gets_an_identity_element,test_spec_env_cannot_move_the_app_data_home
- host-CLI filter removed →
On the scope question (gatewayd)
Leaving gatewayd's pooled set at the managed servers is the right scope for this PR. mcp_gateway.stub_servers is empty by default, so on a default install no broker runs and Mochi goes through exactly the path this PR fixes. A pooled mochi:mochi only exists if an operator stubs it from MCP Management; in that case the session-side element is skipped (existing_names) and the call still has no attestation. That is an opt-in edge, and handing a pooled app backend a session token is a different trust question, so a follow-up issue is better than widening this one.
Blocking
None.
Non-blocking follow-ups
- The
command == "kirocrew"skip inbuiltin_app_identity_launches(an unpinned launch would resolvekirocrewthroughPATH) is not pinned: removing it leaves all 11 tests green. A test where_pin_host_cli_commandreturns the input unchanged would cover it. - The diff also black-formats untouched code in
apps/execution.pyand drops it fromblack-baseline.txt. That is allowed, but it makes the security-relevant lines harder to find; worth calling out in the description. - Please open a follow-up issue for a stubbed (pooled)
mochi:mochi, so that case is tracked rather than silently still failing.
Not verified
- I did not run a live gateway with Mochi; the end-to-end claim is the author's.
- I did not run the full suite or the pooled topology.
iamwhatever
left a comment
There was a problem hiding this comment.
This PR gives builtin app MCP servers that run Kiro Crew's own code (today mochi:mochi) the same per-session identity element that the managed kirocrew-* servers already get on the kiro backend. That fixes the root cause of #19798: the token attach only reached IDENTITY_BOUND_SERVERS, so a spec-mounted app server refused every call as unattested. I read session_mcp.py, the execution.py split and the new tests. Since this hands a session token to a process, I tried to break the narrowing. A user app that shadows a builtin name is dropped by builtin_owns_installed. A hand-edited mochi:mochi entry with a different command gets the manifest launch from _pin_host_cli_command instead. Spec env cannot move PYTHONPATH or KIROCREW_HOME (the pin wins the merge) and cannot inject loader or launcher-exec variables (_managed_element_env sanitizes them exactly as it does for kirocrew-core). An app that ships its own binary or a url server never qualifies, and an ungranted or disabledTools-restricted server gets no element. Pin or manifest failures fail soft, leaving today's behaviour. The pooled/stub path is declared out of scope, the 11 new tests fail on main, checks are green, and buluoray has already approved. — crew-pr-reviewer (deep re-check)
On the KAS backend every mochi:mochi tool refused as identity_unattestable. The kiro-cli path re-declares a builtin app server that runs Kiro Crew's own code with the signed session token (#19801), but KAS never reaches it, and the KAS hoist tokened only the managed kirocrew-* names, so the app server launched with no token. The KAS harness now resolves those app servers off the loop with the payload, and the hoist moves them to the session-level array, relaunched from the shipped manifest launch and stamped with the token. A server a settings file restricts, or every one when settings are unreadable, keeps its native declaration, the same verdict the kiro-cli mount reaches. The manifest's no-op disabled: false no longer keeps the entry out of the hoist. Fixes the KAS half of #19798.
On the KAS backend every mochi:mochi tool refused as identity_unattestable. The kiro-cli path re-declares a builtin app server that runs Kiro Crew's own code with the signed session token (#19801), but KAS never reaches it, and the KAS hoist tokened only the managed kirocrew-* names, so the app server launched with no token. The KAS harness now resolves those app servers off the loop with the payload, and the hoist moves them to the session-level array, relaunched from the shipped manifest launch and stamped with the token. A server a settings file restricts, or every one when settings are unreadable, keeps its native declaration, the same verdict the kiro-cli mount reaches. The manifest's no-op disabled: false no longer keeps the entry out of the hoist. Fixes the KAS half of #19798.
Problem / Motivation
Goal: Builtin app MCP servers that run Kiro Crew's own code, such as Mochi's
mochi:mochi, can serve tool calls from a dashboard chat instead of refusing every one.On the kiro backend, every tool on the
mochi:mochiserver refuses asidentity_unattested(on 0.8.0.9) oridentity_unattestable(onmain) for sessionmcp, whilekirocrew-coreandkirocrew-cronwork in the same chat. Mochi never moves, shows bubbles or runs its watchlist, and its background planner hangs onget_watchlist. Thekiro_crew app mcp mochiprocess carries noKIROCREW_STUB_SESSION_TOKEN, while itsmcp-coresibling under the samekiro-cli-chat acpprocess does. Full report in #19798.Why it matters
On the kiro backend's shared runtime, a user who enables Mochi gets a pet that never does anything, with no hint in the UI why. Mochi is the only shipped builtin with a host-CLI MCP server today, but any builtin that adds one serves through
mcp_shared.run_mcp_stdio_loopand would hit the same refusal.Not a goal
CONTROL_PLANE_BACKENDS) is unchanged: a pooled app server is still not handed the token.What changed (motivation → approach → change)
Symptom: app server tools refuse for session
mcp. Root cause: the per-session identity elementsession_mcp.kiro_control_plane_serversbuilds covers onlyIDENTITY_BOUND_SERVERS, which derives fromKIROCREW_BIN_MCP_SERVERS. A builtin app server reaches the spec throughbridges._own_mcp_serversand kiro-cli launches it straight from there, so the token attach inruntime._own_stub_sessionnever reaches it. This is the gap #12476 closed for the opt-in Crew servers, left open for app servers.Change, following the same pattern:
apps.execution.builtin_app_host_cli_mcp_launches()lists the servers a shipped, builtin-owned manifest declares ascommand: "kirocrew"with stringargsand nourl, with their shipped args. It filters_builtin_app_mcp_server_configs(), the one manifest enumerationbuiltin_app_mcp_servers()now takes its keys from, so every launch is by construction a server that set already trusts.session_mcp.builtin_app_identity_launches()pins each one withbridges._pin_host_cli_command, the same pin registration applies, so the launch is the gateway's own interpreter and never the spec's.kiro_control_plane_serversnow re-declares a granted app server after the managed servers, under the same rules: the spec'stoolsgrant,native_mount_withholding, skipping a name a broker stub already carries, and replacing a hand-edited launch with the derived one.PYTHONPATHandKIROCREW_HOMEcome from the pin, over anything the spec declares.docs/architecture/mcp.mddocuments the extra population and that gatewayd's set stays the managed servers.apps/execution.pyis now black-clean, so its line is pruned from.github/black-baseline.txt.Backwards compatibility
Compatible: the change only adds a per-session element for a granted builtin app server that today is mounted from the spec and refuses every call. Managed servers keep their elements in the same order.
Removes nothing: the diff adds an element and a helper, and removes no path, record, key or function.
Tests
test/test_app_mcp_session_identity.py:PYTHONPATH/KIROCREW_HOMEPYTHONPATHdisabledToolsrestriction keeps the element out and reports it as withheldAll 11 fail on
main. The existing identity suites (test_session_token_identity.py,test_native_skill_projection_sources.py,test_mcp_gateway_stub_session_token.py,test_member_panel_mount.py) pass unchanged.Manual verification
On an isolated dev gateway built from this branch (its own
KIROCREW_HOME,KIRO_HOMEand port, macOS arm64), with Mochi enabled, a dashboard chat with themochiagent was asked to callget_watchlist:kiro_crew app mcp mochiprocess carriesKIROCREW_STUB_SESSION_TOKENand the call returns{"watchlist": {"version": 1, "items": []}}session_mcp.pyreverted: the call fails withidentity_unattestable: session mcp resolved only from a source the gateway cannot attestMount path: with the default configuration, both on that dev gateway and on a stock 0.8.0.9 desktop install,
kiro_crew app mcp mochiis spawned directly by the chat'skiro-cli-chat acpprocess from the agent spec, not through a broker stub or gatewayd's pool. That is the path this change fixes. A pooled or stubbed app server would still get no token, and that path is left for a follow-up, since gatewayd would need the same manifest re-derivation on its side.The desktop pet window itself was not exercised.
Related Issues
Fixes #19798
Pattern harvest
Rule candidate: review-prompt
Pattern: a new server that serves through
mcp_shared.run_mcp_stdio_loopmust be in a set that receives the per-session token on every mount path, or every call refuses.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
I agree that this contribution is made under the project's Apache-2.0 license.