Repository navigation
fix(mcp): list an app's tools only while the app is enabled - #16127
Conversation
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Check that Watch
[DESIGN-REVIEWED] 461f5ac Description read[DESCRIPTION-READ] b597de6942378eebeb8511efff1e36c24d1d167c24bd37556157bae5d3b20b70 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 — ✅ 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: |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Check that hiding Not justified as shipped
What this change shipsInventory (6 items) — 5 justifiedIntent: stop a session from being offered app tools that can only be refused while their app is off. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] 461f5ac Description read[DESCRIPTION-READ] b627c907420f9347fc19ab254ae6e84706a836517863916ce363c13ca9e5604e That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Review detailsDisabling an app now makes any later transparent respawn of the shared FINDING — src/kiro_crew/mcp_tools/apps.py:306 — A session starts while an app is enabled, so it holds that app's tools, such as [OPUS-REVIEWED] 461f5ac Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
04c8253 to
24be193
Compare
24be193 to
465b71d
Compare
465b71d to
29c5a00
Compare
|
CI on |
|
Reviewed for merge triage, not approving from my side: it changes which MCP app tools are listed and therefore callable (an authorization surface: tools should vanish while an app is disabled). That needs a security owner's sign-off. CI is green. |
|
The commits since the hold (rounds 5 to 7) are rebases with no change of substance, so the code is the same one the hold was about. One correction to my earlier comment: this PR does not change whether a tool can be called. dispatch() and the handlers are untouched, a hidden tool still reaches its route, and the gateway's is_app_enabled check is still what refuses the call. What it does change is which tools kirocrew-core lists. It reads installed.json from inside the MCP server process, lists the tools if that read fails or runs on an event loop, and adds a new hook in build_tool_list(). Those choices about what gets exposed should still be confirmed by a security owner. @bolichen97 is still a requested reviewer and has not reviewed yet. Once that sign-off lands, I see no remaining blockers. CI readiness is passed and the branch is mergeable. |
|
Thanks, that correction matches the change: |
|
One more of the three choices, for the same review: |
kirocrew-core advertised the eight tools of Issue Radar, Dev Fleet and Ops Mission Control whatever the apps' state, while every route those tools call refuses with app_not_enabled when its app is disabled (#10742). A session with the apps off was told about tools that could only refuse, and paid each one's full schema in every request, since kiro-cli reads tools/list once per session and Crew's own servers are exempt from tool_search deferral. The apps domain now maps each tool to the installed app behind it (TOOL_APPS) and emits a descriptor only while that app is enabled, read through the same kiro_crew.apps.manager installed.json reader the routes use, so listing and call agree from one predicate. Hiding needs a definite False; an unreadable record lists, as the per-session policy filter does, because the once-per-session cache would make hiding on a transient fault permanent while a listed tool that refuses is not a hole. schemas() and HANDLERS keep declaring all eight, so the registry parity tests read the declaration; build_tool_list() reads a domain's advertised() in place of schemas() when it defines one. Fixes #16099
4711441 to
461f5ac
Compare
UX Review (Opus 5.5) — ⏭️ skippedRevision |
|
|
|
iamwhatever
left a comment
There was a problem hiding this comment.
This PR stops kirocrew-core from advertising the tools of a disabled built-in app (Issue Radar, Dev Fleet, Ops Mission Control, Design Tweak). Every call to those tools is refused by the app's gateway route anyway, so hiding them fixes the cause: the model being offered capabilities that can only refuse. I read the production diff (mcp_tools/__init__.py, mcp_tools/apps.py) and the tests. advertised() hides a tool only when app_enabled_state returns a readable False, and fails open on None or an exception. The names-only discovery path never reads enablement, and the route stays the enforcement point, so this is listing hygiene, not a security change. test_mcp_apps_tool_gate.py pins TOOL_APPS against each app's real name. Checks are green: the one PR Hygiene failure has a newer SUCCESS. All lanes PASS, and the Design and First Principles items and the Opus advisory have dispositions on this head. One non-blocking note: as Opus found, if an app is disabled and the shared backend later respawns, sessions that were shown that app's tools take one terminal "tools are stale — reconnect" error. The author's rebuttal is reasonable since that is daemon/replacement.py's stated contract, but a sentence on it in docs/architecture/mcp.md would help operators. — crew-pr-reviewer
Problem / Motivation
Goal:
kirocrew-coreadvertises the tools of Issue Radar, Dev Fleet and Ops Mission Control only while that app is enabled, so a session is never told about a tool whose every call the gateway refuses.With the Issue Radar, Dev Fleet and Ops Mission Control apps disabled,
tools/listonkirocrew-corestill carried all eight of their tools (issue_radar_record_investigation,issue_radar_crew_read,issue_radar_crew_record,pod_up,pod_down,pod_status,pod_ls,ops_mission_control_api). Each of those tools reaches a gateway route that refuses the call while its app is disabled (app_not_enabled, #10742), so the model was offered eight capabilities that could only refuse -- and, because kiro-cli readstools/listonce per session and Crew's own servers are exempt fromtool_searchdeferral, each one cost its full JSON schema in every request of every such session.Why it matters
Every session on an install with these apps off -- the default, since every builtin ships
defaultEnabled: false-- pays context for eight unusable tools in every request, and an agent that picks one gets a refusal it then reasons about or retries. The same install with Dev Fleet on must keep exactly the four pod tools, so the fix has to follow enablement per app rather than drop the domain.Not a goal
dispatch()and every handler are untouched, and the gateway route stays the enforcement point.tools/listfor the session's life, as it does for the computer-use tools and the per-session policy filter.kirocrew-coretool that belongs to no app.What changed (motivation → approach → change)
Root cause:
kiro_crew.mcp_tools.build_tool_list()concatenated every domain'sschemas()unconditionally, while the gateway routes those tools call decide enablement per request throughkiro_crew.apps.manager.is_app_enabled. The listing and the call must agree from ONE predicate, so the listing reads the sameinstalled.jsonthrough the same module the routes read; the MCP server process reads it directly, asmcp_computer._list_toolsalready reads the computer-use keystone. The per-sessionmanagedToolPolicyfilter was rejected as the seam: cached per session with no TTL, and itstools/callleg fails closed.src/kiro_crew/mcp_tools/apps.py:TOOL_APPSmaps each app tool to the installed app name its routes gate on, andadvertised()returnsschemas()minus the tools of every app whose tri-stateapp_enabled_stateis a definiteFalse. An unreadable record (None, or a read that raises) lists the tools: fail-open on listing, because the once-per-session cache would make hiding on a transient fault permanent, while a listed tool whose call the gateway refuses is not a hole.schemas()andHANDLERSkeep naming every tool whatever the enablement.src/kiro_crew/mcp_tools/__init__.py:build_tool_list()reads a domain'sadvertised()in place ofschemas()on the full build only. Main's refactor(mcp): names-only in-process tool read; drop the per-builder loop skips #18001 replaced the per-builderasyncio.get_running_loop()skips with a names-only build (build_tool_names(), what in-process discovery reads on the gateway loop); this PR's earlier running-loop guard was that skip written a third time and is gone -- the names-only path takesschemas()and never reads an app's enablement record, so a disabled app's tools still appear by name in the discovery inventory, under its "Declared" badge.apps-domain tool,design_tweak_update_thread, whose route (the app reverse proxy,handle_app_api_proxy) refuses a disabled Design Tweak with 403app_not_enabledon the same predicate; it is gated like the other three apps' tools (TOOL_APPS->design-tweak, pinned to the app's manifest name).docs/architecture/mcp.md(owning spec): the App bridges entry, the two-halves paragraph, and the section "An app's tools follow the app's enablement" recording the predicate, the fail-open rule, the mid-session caveat and the names-only rule.docs/system-specs/modules/app-kit-platform.md: one paragraph under section 7 pointing enablement readers at it.Backwards compatibility
Compatible: no tool is renamed or reshaped, and an enabled app lists exactly the tools it listed before. The only observable change is that a disabled or uninstalled app's tools are absent from
tools/list; a call to one of them was already refused by the gateway and still is, with the 403 body each app's routes produce (Dev Fleet and Design Tweakapp_not_enabled, Ops Mission Controlapp_disabled, Issue Radar no code). Enabling an app mid-session surfaces its tools at the next session, as the computer-use tools behave.Reader:
test/test_mcp_apps_tool_gate.pypins the listing to the route's predicate with realinstalled.jsonrecords (none installed, disabled, one enabled, all enabled, unreadable), the names-only build's zero enablement reads, the hidden tool'sdispatch()still reaching the route refusal, and everyTOOL_APPSvalue against the app's own name.Reader:
test/test_mcp_discovery.py::TestManagedToolsInProcessNamesOnly::test_core_names_are_correct_and_completeholds every app enabled while comparing the names-only build to the full build, the one state in which the two now legitimately differ.Tests
Red-first,
-n0:test/test_mcp_apps_tool_gate.pyfailed 8 of 10 before the fix on3d465a6066; on this head 16 pass.test/test_mcp_tool_registry.pyreads parity from the declaration (schemas()), sincebuild_tool_list()may legitimately omit a declared tool, andtest_a_domain_advertises_only_what_it_declarespinsadvertised()to a subset ofschemas().test/test_mcp_tool_titles.py,test/test_codex_session_mcp.py,test/test_issue_radar_crew_mcp_tools.pyandtest/test_issue_radar_investigation_tool.pyhold enablement open while enumeratingkirocrew-core. On this head: ten named suites, 778 passed-n0;mypy src/kiro_crewclean; black ratchet, isort, flake8, docs lint andcheck_comment_history.pypass; the full backend suite in one-n autoleg, 174401 passed, 76 failed, all 76 reproduced identically on a pristineorigin/maincheckout in files this diff does not touch.Edit log:
04c8253cf9initial;24be19330fcomment lines restated (Comment History Gate);465b71d428read guard, two-reader contract, refusal shapes;29c5a00be8running-loop guard (since removed);215c326e3f,3c7e9033d7,4711441ab5rebases;461f5acd38rebase, #18001 adaptation, #17622 tool gated.Manual verification
Round 1 drove the real stdio server (
python -m kiro_crew mcp-core,initialize+tools/list): no app installed lists none of the app tools;dev-fleetenabled lists exactly the four pod tools. No UI change.Screenshots / video
None: no visual change (backend listing only).
Related Issues
Fixes #16099
Pattern harvest
Rule candidate: review-prompt
Pattern: a server advertises a capability whose call path is gated elsewhere (an app enable, a keystone, a policy) without reading the same gate; listing and call must agree from one predicate.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement