fix: update McpToolCallResponse type for SDK v1.26.0 compatibility

- Add resource_link content type variant to McpToolCallResponse union
- Add optional annotations, _meta fields on all content item types
- Add optional structuredContent field at top level
- Handle resource_link content in UseMcpToolTool.processToolContent()

Resolves TS2322 error where SDK CallToolResultSchema (with new
resource_link type) was not assignable to McpToolCallResponse.
This commit is contained in:
Roo Code 2026-02-13 04:20:40 +00:00
parent e3d1c2b0ce
commit ae21b0b387
2 changed files with 37 additions and 0 deletions

View file

@ -99,22 +99,48 @@ export type McpResourceResponse = {
}>
}
/**
* Annotations that can be attached to content items in MCP tool call responses.
* Used to indicate audience targeting, priority, and modification timestamps.
*/
export type McpContentAnnotations = {
audience?: Array<"user" | "assistant">
priority?: number
lastModified?: string
}
export type McpToolCallResponse = {
_meta?: Record<string, any> // eslint-disable-line @typescript-eslint/no-explicit-any
content: Array<
| {
type: "text"
text: string
annotations?: McpContentAnnotations
_meta?: Record<string, unknown>
}
| {
type: "image"
data: string
mimeType: string
annotations?: McpContentAnnotations
_meta?: Record<string, unknown>
}
| {
type: "audio"
data: string
mimeType: string
annotations?: McpContentAnnotations
_meta?: Record<string, unknown>
}
| {
type: "resource_link"
uri: string
name: string
description?: string
mimeType?: string
title?: string
annotations?: McpContentAnnotations
_meta?: Record<string, unknown>
}
| {
type: "resource"
@ -123,9 +149,13 @@ export type McpToolCallResponse = {
mimeType?: string
text?: string
blob?: string
_meta?: Record<string, unknown>
}
annotations?: McpContentAnnotations
_meta?: Record<string, unknown>
}
>
structuredContent?: Record<string, unknown>
isError?: boolean
}

View file

@ -271,6 +271,13 @@ export class UseMcpToolTool extends BaseTool<"use_mcp_tool"> {
const { blob: _, ...rest } = item.resource
return JSON.stringify(rest, null, 2)
}
if (item.type === "resource_link") {
const { uri, name, description, mimeType } = item
const parts: Record<string, string> = { uri, name }
if (description) parts.description = description
if (mimeType) parts.mimeType = mimeType
return JSON.stringify(parts, null, 2)
}
if (item.type === "image") {
// Handle image content (MCP image content has mimeType and data properties)
if (item.mimeType && item.data) {