Skip to content

feat(mcp): mount a default agent's requested server without grants - #25802

Closed
vnlebaoduy wants to merge 1 commit into
kirodotdev:feat/request-server-25157from
vnlebaoduy:feat/mount-only-server-requests
Closed

vnlebaoduy wants to merge 1 commit into
kirodotdev:feat/request-server-25157from
vnlebaoduy:feat/mount-only-server-requests

Conversation

@vnlebaoduy

@vnlebaoduy vnlebaoduy commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: the default kirocrew agent and the kirocrew-worker can get an MCP server from request_server mid-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_refs writes @server into allowedTools). 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

What changed (motivation → approach → change)

Symptom: a default-agent request answered 409 use_mcp_page and 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_additions gains a mount_only disposition 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.
  • The agent half maps a default or worker caller onto the default template and proposes the card with mount_only: true; the card's apply step carries it, and the owner-only step records it.
  • spec_rebuild merges the default template's recorded additions before resolving MCP servers, so the entry is resolved like any other. sync_shared_server_refs gains a mount_only set and withholds the grant for those names through its existing governance-withhold path: the @server ref stays in tools and is stripped from allowedTools, so the server is mounted and every call asks.
  • The record persists, so the disposition survives every rebuild, including one where the same server is also on the MCP page.
  • docs/architecture/mcp.md, the feature-map row and the record's module doc state the new shape.

Backwards compatibility

Compatible: mount_only is 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, allowedTools grants, and every other template are unchanged. Removes nothing.

Tests

  • test/test_template_server_request.py: a kirocrew and a kirocrew-worker request now raise a card with params.mount_only, the apply step carries it, the record lands on kirocrew with mount_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_names reports 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 @server in tools, removes it (and per-tool grants) from allowedTools, and leaves ordinary servers granting as before.
  • test/test_agent_mcp_merge.py: a full install_agent rebuild writes the recorded server into kirocrew.json with its @server mount and no allowedTools entry.

test/test_template_server_request.py + test_template_mcp_additions.py + test_agent_mcp_merge.py + test_secret_uri_launch_paths.py pass 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.py pass 215/215. black, isort, flake8, mypy on the changed modules and scripts/docs-lint.sh pass.

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.py drives the real installer and reads the emitted kirocrew.json. No UI component changed, so there is no screenshot.

Related Issues

Fixes #25771. Stacked on #25180 (feat/request-server-25157): merge #25180 first, then retarget this PR to main.

The base branch currently fails test/test_change_cards.py::test_every_hooked_route_is_a_real_registered_route: #25180 registers the two mcp-additions routes through app.router.add_route in a loop, while that test only matches add_delete("...") / add_post("..."). The failure is inherited, not introduced here; this diff does not touch route registration or that test.

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.

@vnlebaoduy
vnlebaoduy requested review from a team and KiroCrewCaptain as code owners October 29, 2026 15:39
@vnlebaoduy
vnlebaoduy requested review from dodgeblaster and removed request for a team October 29, 2026 15:39
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 29, 2026
@buluoray
buluoray force-pushed the feat/request-server-25157 branch from b405629 to cc3a9c3 Compare October 29, 2026 17:37
@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Oct 29, 2026
@buluoray
buluoray force-pushed the feat/request-server-25157 branch 7 times, most recently from b82bf00 to 82d3dc0 Compare October 30, 2026 01:43
@vnlebaoduy
vnlebaoduy force-pushed the feat/mount-only-server-requests branch from 3612a3d to 607c011 Compare October 30, 2026 02:17
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: checking Automated validation is still running merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: action required A blocking check or review needs attention labels Oct 30, 2026
@buluoray
buluoray force-pushed the feat/request-server-25157 branch from 82d3dc0 to d489c40 Compare October 30, 2026 02:41
@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Oct 30, 2026
@vnlebaoduy
vnlebaoduy force-pushed the feat/mount-only-server-requests branch from 607c011 to ce2958c Compare October 30, 2026 04:00
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Oct 30, 2026
@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Oct 30, 2026
@buluoray
buluoray force-pushed the feat/request-server-25157 branch from d489c40 to 4d0e594 Compare October 30, 2026 04:15
@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Oct 30, 2026
@buluoray
buluoray force-pushed the feat/request-server-25157 branch 2 times, most recently from b2dc484 to 6d643d5 Compare October 30, 2026 05:45
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
@vnlebaoduy
vnlebaoduy force-pushed the feat/mount-only-server-requests branch from ce2958c to 7ace0c7 Compare October 30, 2026 06:24
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Oct 30, 2026
@buluoray
buluoray deleted the branch kirodotdev:feat/request-server-25157 October 30, 2026 15:09
@buluoray buluoray closed this Oct 30, 2026
@github-actions github-actions Bot removed the readiness: checking Automated validation is still running label Oct 30, 2026
@vnlebaoduy

Copy link
Copy Markdown
Contributor Author

GitHub closed this PR when the #25180 branch was deleted, and it cannot be reopened. The same change, rebased onto main, continues in #26604.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants