Files
HiveGrid-Wireframes/03 Quellen und Referenzen/hivegrid-cloud/apps/mcp/src/tool-result.ts
T
2026-07-08 16:15:37 +02:00

29 lines
591 B
TypeScript

import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
import { toToolError } from "./errors.js";
export function toolSuccess(structuredContent: Record<string, unknown>): CallToolResult {
return {
structuredContent,
content: [
{
type: "text",
text: JSON.stringify(structuredContent, null, 2),
},
],
};
}
export function toolFailure(error: unknown): CallToolResult {
const message = toToolError(error);
return {
isError: true,
content: [
{
type: "text",
text: message,
},
],
};
}