Repository navigation
feat(mcp): mount a default agent's requested server without grants - #26604
vnlebaoduy wants to merge 1 commit into
Conversation
A request_server card refused the default agent and the worker, because the MCP page's add also approves every tool of the server and a mid-chat card must not be a second path to that grant. Record a mount-only addition on the default template instead. The rebuild merges its entry into mcpServers and adds the @server ref to tools, writes no allowedTools grant, and keeps that disposition while the server is also on the MCP page. The worker mirrors the default spec, so one record reaches both. Fixes kirodotdev#25771
|
@KiroCrewCaptain could you approve the workflow runs for this fork PR? It replaces #25802, which GitHub closed when the #25180 branch was deleted. The change is rebased onto |
|
🤖 Kiro Crew Auto-Pipeline [operator: buluoray#ce473fca]: Thank you for this work. The issue owner is landing #25771 in #28720, which builds on this PR's mount-only disposition and credits you with a Co-authored-by trailer. While rebasing it onto current main we found and fixed three gaps: the card's Undo left the server mounted in |
Problem / Motivation
Goal: the default
kirocrewagent and thekirocrew-workercan get an MCP server fromrequest_servermid-chat, mounted with no tool approval.Both were refused
409 use_mcp_page: their servers come from the MCP page, and the MCP page's add also approves every tool of the server (sync_shared_server_refswrites@serverintoallowedTools). A card for "add this server" would therefore have granted more than it said. The result was that the agent with the widest reach — the default agent every chat starts on — could not ask for the one thing the feature exists for.Why it matters
A session running on the default agent is the most common place to discover a missing server. Refusing there leaves the MCP page as the only route, which is the full-grant route, and forces the user to leave the conversation to add it. A mount-only card closes the gap without widening trust: the server runs, every call still asks.
Not a goal
autoApproveorallowedTools, and the record refuses both.template.mcp_servercard already exists; this changes what it records for two templates.What changed (motivation → approach → change)
Symptom: a default-agent request answered
409 use_mcp_pageand raised no card.Cause: the handler refused every template in
DEFAULT_TEMPLATES, and the additions record refused them too, because a normal addition would be granted on the next rebuild.Change:
template_mcp_additionsgains amount_onlydisposition on an addition. The default agent accepts an addition only with it (and the worker accepts none: a worker record would never merge); a hand-edited default entry without the flag is skipped on read, so the record cannot become a grant path by accident.mount_only: true; the card's apply step carries it, and the owner-only step records it.spec_rebuildmerges the default template's recorded additions before resolving MCP servers, so the entry is resolved like any other.sync_shared_server_refsgains amount_onlyset and withholds the grant for those names through its existing governance-withhold path: the@serverref stays intoolsand is stripped fromallowedTools, so the server is mounted and every call asks.docs/architecture/mcp.md, the feature-map row and the record's module doc state the new shape.Backwards compatibility
Compatible:
mount_onlyis an optional field on a record entry; an existing record without it keeps its current meaning, and only the default template requires it (it previously accepted no additions at all, so no stored record changes meaning). A normal addition to the default is still refused, and the worker still records nothing. The MCP page,allowedToolsgrants, and every other template are unchanged. Removes nothing.Tests
test/test_template_server_request.py: akirocrewand akirocrew-workerrequest now raise a card withparams.mount_only, the apply step carries it, the record lands onkirocrewwithmount_only=True, and the worker is named in the card's reach. Existing conductor and third-party flows are unchanged.test/test_template_mcp_additions.py: a mount-only default addition round-trips,mount_only_namesreports it, reach includes the worker, and the merge mounts without granting; a default addition without the flag, a worker addition, and a hand-edited default entry are all refused or skipped.test/test_secret_uri_launch_paths.py:sync_shared_server_refs(mount_only=...)keeps@serverintools, removes it (and per-tool grants) fromallowedTools, and leaves ordinary servers granting as before.test/test_agent_mcp_merge.py: a fullinstall_agentrebuild writes the recorded server intokirocrew.jsonwith its@servermount and noallowedToolsentry.test/test_template_server_request.py+test_template_mcp_additions.py+test_agent_mcp_merge.py+test_secret_uri_launch_paths.pypass 168/168; the change-card suites pass 183/183 with one deselected (the inherited failure below).test_agent_install.py+test_worker_agent.py+test_mcp_hot_reload.pypass 215/215. black, isort, flake8, mypy on the changed modules andscripts/docs-lint.shpass.Proof: PROVEN test/test_template_server_request.py::test_a_default_or_worker_request_raises_a_mount_only_card, test/test_template_mcp_additions.py::test_a_default_mount_only_addition_round_trips_and_reaches_the_worker (head 3612a3d)
Manual verification
The card and the record are exercised end to end through the real routes and the real card engine in
test_template_server_request.py;test_agent_mcp_merge.pydrives the real installer and reads the emittedkirocrew.json. No UI component changed, so there is no screenshot.Related Issues
Fixes #25771. Builds on #25180, now merged. This replaces #25802, which GitHub closed when the #25180 branch was deleted.
Checklist
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.