Parameters
- data: unknown
Optionaloptions: StructuredResponseOptions
Returns {
_meta?: {
"io.modelcontextprotocol/related-task"?: { taskId: string };
progressToken?: string | number;
[key: string]: unknown;
};
content: (
| {
_meta?: { [key: string]: unknown };
annotations?: {
audience?: ("user" | "assistant")[];
lastModified?: string;
priority?: number;
};
text: string;
type: "text";
}
| {
_meta?: { [key: string]: unknown };
annotations?: {
audience?: ("user" | "assistant")[];
lastModified?: string;
priority?: number;
};
data: string;
mimeType: string;
type: "image";
}
| {
_meta?: { [key: string]: unknown };
annotations?: {
audience?: ("user" | "assistant")[];
lastModified?: string;
priority?: number;
};
data: string;
mimeType: string;
type: "audio";
}
| {
_meta?: { [key: string]: unknown };
annotations?: {
audience?: ("user" | "assistant")[];
lastModified?: string;
priority?: number;
};
description?: string;
icons?: {
mimeType?: string;
sizes?: string[];
src: string;
theme?: "light"
| "dark";
}[];
mimeType?: string;
name: string;
size?: number;
title?: string;
type: "resource_link";
uri: string;
}
| {
_meta?: { [key: string]: unknown };
annotations?: {
audience?: ("user" | "assistant")[];
lastModified?: string;
priority?: number;
};
resource: | {
_meta?: { [key: string]: unknown };
mimeType?: string;
text: string;
uri: string;
}
| {
_meta?: { [key: string]: unknown };
blob: string;
mimeType?: string;
uri: string;
};
type: "resource";
}
)[];
isError?: boolean;
structuredContent?: { [key: string]: unknown };
[key: string]: unknown;
}
A CallToolResult with both structuredContent and a TextContent block
Create a spec-compliant structured response for tools that declare an
outputschema.Per MCP 2025-06-18 ("Structured Content"), tools that return
structuredContentSHOULD also serialize the same payload into aTextContentblock for backwards compatibility with clients that do not yet readoutputSchema/structuredContent. Modern clients preferstructuredContentfor typed access while theTextContentblock stays available for display-oriented rendering and legacy consumers.By default the helper serializes
dataas pretty-printed JSON into theTextContentblock — a safe, schema-faithful fallback. Pass StructuredResponseOptions.text | options.text to override theTextContentwith a human-readable rendering (Markdown, ASCII table, etc.). ThestructuredContentpayload remains the single source of truth in either case.For tools without an output schema (state-change confirmations, free-form messages), use text instead.