@@ -2,8 +2,8 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
22import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js" ;
33import { z } from "zod/v3" ;
44
5- import type { ToolConfig , ToolModule } from "$ /shared/types.ts" ;
6- import { createCallToolErrorResponse , createCallToolTextResponse } from "$ /shared/utils.ts" ;
5+ import type { ToolConfig , ToolModule } from "../.. /shared/types.ts" ;
6+ import { createCallToolErrorResponse , createCallToolTextResponse } from "../.. /shared/utils.ts" ;
77
88const schema = z . object ( {
99 prompt : z . string ( ) . describe ( "The prompt to generate a poem for" ) ,
@@ -49,17 +49,19 @@ const callback = (mcp: McpServer) => async (args: any): Promise<CallToolResult>
4949 temperature : 0.7 ,
5050 } ) ;
5151
52- if ( response . content . type !== "text" ) {
52+ const content = Array . isArray ( response . content ) ? response . content [ 0 ] : response . content ;
53+
54+ if ( ! content || content . type !== "text" ) {
5355 return createCallToolErrorResponse ( {
5456 error : "No text response from sampling" ,
5557 prompt,
56- responseType : response . content . type ,
58+ responseType : content ? .type ?? "unknown" ,
5759 operation : "poem-generation" ,
5860 } ) ;
5961 }
6062
6163 return createCallToolTextResponse ( {
62- poem : response . content . text ,
64+ poem : content . text ,
6365 prompt,
6466 timestamp : new Date ( ) . toISOString ( ) ,
6567 } ) ;
0 commit comments