2828import io .modelcontextprotocol .client .McpAsyncClient ;
2929import io .modelcontextprotocol .client .McpSyncClient ;
3030import io .modelcontextprotocol .server .McpServerFeatures ;
31- import io .modelcontextprotocol .server .McpServerFeatures .AsyncToolSpecification ;
3231import io .modelcontextprotocol .server .McpStatelessServerFeatures ;
3332import io .modelcontextprotocol .server .McpSyncServerExchange ;
3433import io .modelcontextprotocol .spec .McpSchema ;
@@ -222,8 +221,10 @@ public static McpStatelessServerFeatures.SyncToolSpecification toStatelessSyncTo
222221
223222 var sharedSpec = toSharedSyncToolSpecification (toolCallback , mimeType );
224223
225- return new McpStatelessServerFeatures .SyncToolSpecification (sharedSpec .tool (),
226- (exchange , request ) -> sharedSpec .sharedHandler ().apply (exchange , request ));
224+ return McpStatelessServerFeatures .SyncToolSpecification .builder ()
225+ .tool (sharedSpec .tool ())
226+ .callHandler ((exchange , request ) -> sharedSpec .sharedHandler ().apply (exchange , request ))
227+ .build ();
227228 }
228229
229230 private static SharedSyncToolSpecification toSharedSyncToolSpecification (ToolCallback toolCallback ,
@@ -241,9 +242,9 @@ private static SharedSyncToolSpecification toSharedSyncToolSpecification(ToolCal
241242 String callResult = toolCallback .call (ModelOptionsUtils .toJsonString (request .arguments ()),
242243 new ToolContext (Map .of (TOOL_CONTEXT_MCP_EXCHANGE_KEY , exchangeOrContext )));
243244 if (mimeType != null && mimeType .toString ().startsWith ("image" )) {
244- return new McpSchema .CallToolResult (List
245- . of ( new McpSchema .ImageContent ( List . of ( Role . ASSISTANT ), null , callResult , mimeType . toString ())),
246- false );
245+ McpSchema . Annotations annotations = new McpSchema .Annotations (List . of ( Role . ASSISTANT ), null );
246+ return new McpSchema .CallToolResult (
247+ List . of ( new McpSchema . ImageContent ( annotations , callResult , mimeType . toString ())), false );
247248 }
248249 return new McpSchema .CallToolResult (List .of (new McpSchema .TextContent (callResult )), false );
249250 }
@@ -353,10 +354,13 @@ public static McpServerFeatures.AsyncToolSpecification toAsyncToolSpecification(
353354
354355 McpServerFeatures .SyncToolSpecification syncToolSpecification = toSyncToolSpecification (toolCallback , mimeType );
355356
356- return new AsyncToolSpecification (syncToolSpecification .tool (),
357- (exchange , map ) -> Mono
358- .fromCallable (() -> syncToolSpecification .call ().apply (new McpSyncServerExchange (exchange ), map ))
359- .subscribeOn (Schedulers .boundedElastic ()));
357+ return McpServerFeatures .AsyncToolSpecification .builder ()
358+ .tool (syncToolSpecification .tool ())
359+ .callHandler ((exchange , request ) -> Mono
360+ .fromCallable (
361+ () -> syncToolSpecification .callHandler ().apply (new McpSyncServerExchange (exchange ), request ))
362+ .subscribeOn (Schedulers .boundedElastic ()))
363+ .build ();
360364 }
361365
362366 public static McpStatelessServerFeatures .AsyncToolSpecification toStatelessAsyncToolSpecification (
0 commit comments