import type { ToolResponse } from "../schemas.js";
export interface ToolCallResult extends Record<string, unknown> {
readonly content: Array<{ type: "text"; text: string }>;
readonly isError?: boolean;
readonly structuredContent?: Record<string, unknown>;
}
/**
* Wrap tool data into MCP text content.
*/
export function successResponse<T>(payload: ToolResponse<T>): ToolCallResult {
return {
content: [{ type: "text", text: JSON.stringify(payload) }],
structuredContent: payload.data as Record<string, unknown>,
};
}
/**
* Wrap tool errors into MCP text content.
*/
export function errorResponse(message: string): ToolCallResult {
return {
content: [
{
type: "text",
text: JSON.stringify({
summary: message,
error: { message },
}),
},
],
isError: true,
};
}