feat: pipe MCP annotations.title through to ClineAskUseMcpServer

Add annotations field to McpTool type to capture MCP tool metadata
(title, readOnlyHint, destructiveHint, etc). Pass annotations.title
as toolTitle in the ClineAskUseMcpServer payload so downstream
consumers (web UI) can display human-readable labels instead of
generic "Used MCP tool" text.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
daniel-lxs 2026-02-27 15:45:44 -05:00
parent 193053110b
commit 551d02f510
No known key found for this signature in database
GPG key ID: 21C74479048B3AA6
3 changed files with 16 additions and 2 deletions

View file

@ -73,6 +73,13 @@ export type McpTool = {
inputSchema?: object
alwaysAllow?: boolean
enabledForPrompt?: boolean
annotations?: {
title?: string
readOnlyHint?: boolean
destructiveHint?: boolean
idempotentHint?: boolean
openWorldHint?: boolean
}
}
export type McpResource = {

View file

@ -845,6 +845,7 @@ export interface ClineAskUseMcpServer {
serverName: string
type: "use_mcp_tool" | "access_mcp_resource"
toolName?: string
toolTitle?: string
arguments?: string
uri?: string
response?: string

View file

@ -56,6 +56,7 @@ export class UseMcpToolTool extends BaseTool<"use_mcp_tool"> {
type: "use_mcp_tool",
serverName,
toolName: resolvedToolName,
toolTitle: toolValidation.resolvedToolTitle,
arguments: params.arguments ? JSON.stringify(params.arguments) : undefined,
} satisfies ClineAskUseMcpServer)
@ -142,7 +143,7 @@ export class UseMcpToolTool extends BaseTool<"use_mcp_tool"> {
serverName: string,
toolName: string,
pushToolResult: (content: string) => void,
): Promise<{ isValid: boolean; availableTools?: string[]; resolvedToolName?: string }> {
): Promise<{ isValid: boolean; availableTools?: string[]; resolvedToolName?: string; resolvedToolTitle?: string }> {
try {
// Get the MCP hub to access server information
const provider = task.providerRef.deref()
@ -238,7 +239,12 @@ export class UseMcpToolTool extends BaseTool<"use_mcp_tool"> {
}
// Tool exists and is enabled - return the original tool name for use with the MCP server
return { isValid: true, availableTools: server.tools.map((t) => t.name), resolvedToolName: tool.name }
return {
isValid: true,
availableTools: server.tools.map((t) => t.name),
resolvedToolName: tool.name,
resolvedToolTitle: tool.annotations?.title,
}
} catch (error) {
// If there's an error during validation, log it but don't block the tool execution
// The actual tool call might still fail with a proper error