29 lines
591 B
TypeScript
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,
|
|
},
|
|
],
|
|
};
|
|
}
|