Skip to content

feat: support MCP readOnlyHint annotation in plan mode (#1826)#1837

Merged
pomelo-nwu merged 1 commit intoQwenLM:mainfrom
echoVic:fix/mcp-readonly-hint-plan-mode
Feb 25, 2026
Merged

feat: support MCP readOnlyHint annotation in plan mode (#1826)#1837
pomelo-nwu merged 1 commit intoQwenLM:mainfrom
echoVic:fix/mcp-readonly-hint-plan-mode

Conversation

@echoVic
Copy link
Copy Markdown
Contributor

@echoVic echoVic commented Feb 14, 2026

Summary

MCP tools annotated with readOnlyHint: true are now allowed to execute in plan mode without being blocked.

Problem

Previously, all MCP tools were assigned Kind.Other and required user confirmation. In plan mode, any tool requiring confirmation is blocked with:

"Plan mode blocked a non-read-only tool call."

This means MCP tools that are explicitly marked as read-only (via the MCP readOnlyHint annotation) cannot be used in plan mode, even though they are safe to execute. Users cannot gather information from MCP sources while in plan mode.

Solution

  1. Fetch tool annotations — During MCP tool discovery, call mcpClient.listTools() to retrieve the raw tool list with annotations (which mcpToTool's functionDeclarations conversion does not preserve).
  2. Pass annotations through — Store McpToolAnnotations in both DiscoveredMCPTool and DiscoveredMCPToolInvocation.
  3. Set correct Kind — Tools with readOnlyHint: true get Kind.Read instead of Kind.Other.
  4. Skip confirmation — In shouldConfirmExecute(), tools with readOnlyHint: true return false (no confirmation needed), so plan mode does not block them.

Changes

  • packages/core/src/tools/mcp-tool.ts: Add McpToolAnnotations interface, accept annotations in constructors, use Kind.Read for read-only tools, skip confirmation for readOnlyHint: true
  • packages/core/src/tools/mcp-client.ts: Fetch annotations via mcpClient.listTools() during discovery, pass to DiscoveredMCPTool

Testing

  • MCP tools with readOnlyHint: true annotation now execute in plan mode without being blocked
  • MCP tools without annotations or with readOnlyHint: false behave as before (require confirmation, blocked in plan mode)
  • If listTools() fails, discovery proceeds gracefully without annotations (non-breaking)

Fixes #1826

MCP tools annotated with readOnlyHint: true are now allowed to execute
in plan mode without being blocked. Previously, all MCP tools were
assigned Kind.Other and required confirmation, causing plan mode to
block even read-only MCP tools.

Changes:
- Add McpToolAnnotations interface to mcp-tool.ts
- Fetch tool annotations via mcpClient.listTools() during discovery
- Pass annotations through to DiscoveredMCPTool and its invocation
- Set Kind.Read for tools with readOnlyHint: true (instead of Kind.Other)
- Skip confirmation for readOnlyHint: true tools in shouldConfirmExecute

Fixes QwenLM#1826
Copy link
Copy Markdown
Collaborator

@LaZzyMan LaZzyMan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@pomelo-nwu pomelo-nwu merged commit 44b8ff7 into QwenLM:main Feb 25, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support readOnlyHint MCP Annotation

3 participants