feat: support MCP readOnlyHint annotation in plan mode (#1826)#1837
Merged
pomelo-nwu merged 1 commit intoQwenLM:mainfrom Feb 25, 2026
Merged
feat: support MCP readOnlyHint annotation in plan mode (#1826)#1837pomelo-nwu merged 1 commit intoQwenLM:mainfrom
pomelo-nwu merged 1 commit intoQwenLM:mainfrom
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MCP tools annotated with
readOnlyHint: trueare now allowed to execute in plan mode without being blocked.Problem
Previously, all MCP tools were assigned
Kind.Otherand required user confirmation. In plan mode, any tool requiring confirmation is blocked with:This means MCP tools that are explicitly marked as read-only (via the MCP
readOnlyHintannotation) 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
mcpClient.listTools()to retrieve the raw tool list with annotations (whichmcpToTool'sfunctionDeclarationsconversion does not preserve).McpToolAnnotationsin bothDiscoveredMCPToolandDiscoveredMCPToolInvocation.readOnlyHint: truegetKind.Readinstead ofKind.Other.shouldConfirmExecute(), tools withreadOnlyHint: truereturnfalse(no confirmation needed), so plan mode does not block them.Changes
packages/core/src/tools/mcp-tool.ts: AddMcpToolAnnotationsinterface, accept annotations in constructors, useKind.Readfor read-only tools, skip confirmation forreadOnlyHint: truepackages/core/src/tools/mcp-client.ts: Fetch annotations viamcpClient.listTools()during discovery, pass toDiscoveredMCPToolTesting
readOnlyHint: trueannotation now execute in plan mode without being blockedreadOnlyHint: falsebehave as before (require confirmation, blocked in plan mode)listTools()fails, discovery proceeds gracefully without annotations (non-breaking)Fixes #1826