Skip to content

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

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

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

Conversation

@vnlebaoduy

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. Builds on #25180, now merged. This replaces #25802, which GitHub closed when the #25180 branch was deleted.

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.

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 requested review from a team and KiroCrewCaptain as code owners October 31, 2026 06:28
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention labels Oct 31, 2026
@vnlebaoduy

Copy link
Copy Markdown
Contributor Author

@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 main (head 310560401d), and its 17 workflows are waiting for approval. Thanks!

@buluoray

buluoray commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

🤖 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 kirocrew.json (the default spec is rebuilt on top of itself), a declined default rebuild did not put the record back, and per-tool grants the user had written were stripped. Review of #28720 is welcome. This PR can be closed once #28720 merges.

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 3, 2026
@vnlebaoduy

Copy link
Copy Markdown
Contributor Author

Thanks @buluoray for landing this in #28720 and for fixing the Undo, declined-rebuild and per-tool-grant gaps along the way. Closing as superseded by #28720.

@vnlebaoduy vnlebaoduy closed this Nov 3, 2026
@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Nov 3, 2026
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) merge conflict Branch has merge conflicts with its base — author must resolve before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

request_server: mount-only server requests from the default agent and the worker

2 participants