Skip to content

fix(tools): don't trust readOnlyHint in isReadOnly for unloaded MCP tools - #2057

Merged
will-lamerton merged 1 commit into
mainfrom
fix/mcp-unloaded-readonly-hint
Nov 11, 2026
Merged

will-lamerton merged 1 commit into
mainfrom
fix/mcp-unloaded-readonly-hint

Conversation

@will-lamerton

Copy link
Copy Markdown
Member

Description

ToolManager.isReadOnly() decides two things: whether ACP takes a checkpoint before a call (acp-timeline.ts) and whether calls can run in parallel (tool-executor.tsx). For an on-demand MCP tool whose schema wasn't loaded yet, it fell back to the catalog entry. That entry's readOnly is the server's own readOnlyHint, so:

  • this contradicted the invariant in MCPClient.getToolEntries and in docs/configuration/mcp-configuration.md, which say the hint "never suppresses a checkpoint before the call, and never promotes the tool into a parallel batch"
  • the answer flipped on load: true while unloaded, then false once loaded, because the registry entry has no readOnly flag

How reachable it is: on current main, the conversation, plain and ACP loops reject a call to an unregistered tool before they reach isReadOnly, so I couldn't trigger this end to end today. It's a latent trap: any path that hydrates on call (getToolHandler and getToolEntry already do) would let a server's hint skip a checkpoint. The fix is one line, so I've put it up rather than leave it.

Fix: isReadOnly reads only the registry entry. The catalog still shows [read-only] to the model, and plan-mode filtering still reads the hint from the client's tool mapping, as before.

Split out of the discovery-reconnect fix (#2052) because it's a separate concern.

Type of Change

  • Bug fix

Changeset

No changeset: nothing a user can observe changes today (see above).

Testing

New test in source/tools/tool-manager.spec.ts. It uses a fake client through the createMCPClient() seam, with tools annotated readOnly: true and mcpDiscovery: "always":

  • the catalog keeps the hint
  • isReadOnly is false before loading and after loading
  • the built-in read_file is still read-only

It fails on main ("an unloaded tool must not be read-only on the server hint alone") and passes with the fix. tsc --noEmit and biome are clean. AVA passes for source/tools/**, source/hooks/chat-handler/** and source/acp (982 tests).

🤖 Generated with Claude Code

@github-actions github-actions Bot added the area:tools Tool implementations and tool-calling label Nov 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

No changeset found

This PR does not add a changeset, so it will not appear in the changelog or trigger a release.

If the change is user-facing, add one:

pnpm changeset

Pick a bump (patch / minor / major) and write the changelog entry in our usual voice ("Added X... Thanks to @you. Closes #123."), then commit the generated .changeset/*.md file.

If this PR is docs-only or a chore that needs no release note, you can ignore this — or run pnpm changeset --empty to record that intentionally.

@github-actions

Copy link
Copy Markdown
Contributor

nc-review could not produce a verdict this run (agent exit 1). This is a problem with the review agent, not with your pull request. A maintainer can retry with /re-review.

…ools

ToolManager.isReadOnly fell back to the catalog entry for an on-demand
MCP tool whose schema wasn't loaded, and that entry's readOnly is the
server's own readOnlyHint. isReadOnly decides checkpoint capture and
parallel batching, which the hint must not influence. The same tool was
also not read-only once loaded, so the answer flipped on load. Read only
the registry entry.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@will-lamerton
will-lamerton force-pushed the fix/mcp-unloaded-readonly-hint branch from 05834f4 to 05afc2e Compare November 11, 2026 15:03
@will-lamerton
will-lamerton merged commit e4accb3 into main Nov 11, 2026
16 of 17 checks passed
@will-lamerton
will-lamerton deleted the fix/mcp-unloaded-readonly-hint branch November 11, 2026 15:04
jay23606 added a commit to jay23606/nanocoder that referenced this pull request Nov 12, 2026
…ools (Nano-Collective#2057)

ToolManager.isReadOnly fell back to the catalog entry for an on-demand
MCP tool whose schema wasn't loaded, and that entry's readOnly is the
server's own readOnlyHint. isReadOnly decides checkpoint capture and
parallel batching, which the hint must not influence. The same tool was
also not read-only once loaded, so the answer flipped on load. Read only
the registry entry.

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
diyaavirmani added a commit to diyaavirmani/nanocoder that referenced this pull request Nov 16, 2026
Conflicts with on-demand MCP discovery (Nano-Collective#1651, Nano-Collective#2052, Nano-Collective#2057):
- tool-manager.ts: kept discovery, the catalog and outage recovery, with
  this branch's registration rule on every path. A name a built-in,
  custom or skill tool has is skipped from the catalog too, so
  load_tool_schema can't offer the MCP schema for it, and loadMcpTool
  won't claim it. Tools loaded on demand are tracked, so an outage or a
  disconnect removes them and never the built-in.
- daemon/entry.ts, plain/initialize.ts: pass upstream's tune config and
  keep the skipped-tools warning.
- Specs: kept both sides; setGlobalMessageQueue moved to
  @/components/message-queue (Nano-Collective#2155), and the custom-tools stand-in
  client now maps its tool, which initializeMCP reads.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:tools Tool implementations and tool-calling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant