2020import java .util .List ;
2121import java .util .function .Consumer ;
2222import java .util .function .Function ;
23- import java .util .stream .Stream ;
2423
2524import io .modelcontextprotocol .server .McpAsyncServer ;
2625import io .modelcontextprotocol .server .McpServer ;
4140import reactor .core .publisher .Mono ;
4241
4342import org .springframework .ai .mcp .McpToolUtils ;
44- import org .springframework .ai .model .function .FunctionCallback ;
4543import org .springframework .ai .tool .ToolCallback ;
4644import org .springframework .ai .tool .ToolCallbackProvider ;
4745import org .springframework .beans .factory .ObjectProvider ;
@@ -161,7 +159,7 @@ public McpSyncServer mcpSyncServer(ServerMcpTransport transport,
161159 // Create the server with both tool and resource capabilities
162160 SyncSpec serverBuilder = McpServer .sync (transport ).serverInfo (serverInfo );
163161
164- List <SyncToolRegistration > toolResgistrations = new ArrayList <>(tools .stream ().flatMap (List ::stream ).toList ());
162+ List <SyncToolRegistration > toolRegistrations = new ArrayList <>(tools .stream ().flatMap (List ::stream ).toList ());
165163
166164 List <ToolCallback > providerToolCallbacks = toolCallbackProvider .stream ()
167165 .map (pr -> List .of (pr .getToolCallbacks ()))
@@ -170,28 +168,28 @@ public McpSyncServer mcpSyncServer(ServerMcpTransport transport,
170168 .map (fc -> (ToolCallback ) fc )
171169 .toList ();
172170
173- toolResgistrations .addAll (this .toSyncToolRegistration (providerToolCallbacks , serverProperties ));
171+ toolRegistrations .addAll (this .toSyncToolRegistration (providerToolCallbacks , serverProperties ));
174172
175- if (!CollectionUtils .isEmpty (toolResgistrations )) {
176- serverBuilder .tools (toolResgistrations );
173+ if (!CollectionUtils .isEmpty (toolRegistrations )) {
174+ serverBuilder .tools (toolRegistrations );
177175 capabilitiesBuilder .tools (serverProperties .isToolChangeNotification ());
178- logger .info ("Registered tools" + toolResgistrations .size () + " notification: "
176+ logger .info ("Registered tools" + toolRegistrations .size () + " notification: "
179177 + serverProperties .isToolChangeNotification ());
180178 }
181179
182- List <SyncResourceRegistration > resourceResgistrations = resources .stream ().flatMap (List ::stream ).toList ();
183- if (!CollectionUtils .isEmpty (resourceResgistrations )) {
184- serverBuilder .resources (resourceResgistrations );
180+ List <SyncResourceRegistration > resourceRegistrations = resources .stream ().flatMap (List ::stream ).toList ();
181+ if (!CollectionUtils .isEmpty (resourceRegistrations )) {
182+ serverBuilder .resources (resourceRegistrations );
185183 capabilitiesBuilder .resources (false , serverProperties .isResourceChangeNotification ());
186- logger .info ("Registered resources" + resourceResgistrations .size () + " notification: "
184+ logger .info ("Registered resources" + resourceRegistrations .size () + " notification: "
187185 + serverProperties .isResourceChangeNotification ());
188186 }
189187
190- List <SyncPromptRegistration > promptResgistrations = prompts .stream ().flatMap (List ::stream ).toList ();
191- if (!CollectionUtils .isEmpty (promptResgistrations )) {
192- serverBuilder .prompts (promptResgistrations );
188+ List <SyncPromptRegistration > promptRegistrations = prompts .stream ().flatMap (List ::stream ).toList ();
189+ if (!CollectionUtils .isEmpty (promptRegistrations )) {
190+ serverBuilder .prompts (promptRegistrations );
193191 capabilitiesBuilder .prompts (serverProperties .isPromptChangeNotification ());
194- logger .info ("Registered prompts" + promptResgistrations .size () + " notification: "
192+ logger .info ("Registered prompts" + promptRegistrations .size () + " notification: "
195193 + serverProperties .isPromptChangeNotification ());
196194 }
197195
@@ -238,38 +236,38 @@ public McpAsyncServer mcpAsyncServer(ServerMcpTransport transport,
238236 serverProperties .getVersion ());
239237
240238 // Create the server with both tool and resource capabilities
241- AsyncSpec serverBilder = McpServer .async (transport ).serverInfo (serverInfo );
239+ AsyncSpec serverBuilder = McpServer .async (transport ).serverInfo (serverInfo );
242240
243- List <AsyncToolRegistration > toolResgistrations = new ArrayList <>(tools .stream ().flatMap (List ::stream ).toList ());
241+ List <AsyncToolRegistration > toolRegistrations = new ArrayList <>(tools .stream ().flatMap (List ::stream ).toList ());
244242 List <ToolCallback > providerToolCallbacks = toolCallbackProvider .stream ()
245243 .map (pr -> List .of (pr .getToolCallbacks ()))
246244 .flatMap (List ::stream )
247245 .filter (fc -> fc instanceof ToolCallback )
248246 .map (fc -> (ToolCallback ) fc )
249247 .toList ();
250248
251- toolResgistrations .addAll (this .toAsyncToolRegistration (providerToolCallbacks , serverProperties ));
249+ toolRegistrations .addAll (this .toAsyncToolRegistration (providerToolCallbacks , serverProperties ));
252250
253- if (!CollectionUtils .isEmpty (toolResgistrations )) {
254- serverBilder .tools (toolResgistrations );
251+ if (!CollectionUtils .isEmpty (toolRegistrations )) {
252+ serverBuilder .tools (toolRegistrations );
255253 capabilitiesBuilder .tools (serverProperties .isToolChangeNotification ());
256- logger .info ("Registered tools" + toolResgistrations .size () + " notification: "
254+ logger .info ("Registered tools" + toolRegistrations .size () + " notification: "
257255 + serverProperties .isToolChangeNotification ());
258256 }
259257
260- List <AsyncResourceRegistration > resourceResgistrations = resources .stream ().flatMap (List ::stream ).toList ();
261- if (!CollectionUtils .isEmpty (resourceResgistrations )) {
262- serverBilder .resources (resourceResgistrations );
258+ List <AsyncResourceRegistration > resourceRegistrations = resources .stream ().flatMap (List ::stream ).toList ();
259+ if (!CollectionUtils .isEmpty (resourceRegistrations )) {
260+ serverBuilder .resources (resourceRegistrations );
263261 capabilitiesBuilder .resources (false , serverProperties .isResourceChangeNotification ());
264- logger .info ("Registered resources" + resourceResgistrations .size () + " notification: "
262+ logger .info ("Registered resources" + resourceRegistrations .size () + " notification: "
265263 + serverProperties .isResourceChangeNotification ());
266264 }
267265
268- List <AsyncPromptRegistration > promptResgistrations = prompts .stream ().flatMap (List ::stream ).toList ();
269- if (!CollectionUtils .isEmpty (promptResgistrations )) {
270- serverBilder .prompts (promptResgistrations );
266+ List <AsyncPromptRegistration > promptRegistrations = prompts .stream ().flatMap (List ::stream ).toList ();
267+ if (!CollectionUtils .isEmpty (promptRegistrations )) {
268+ serverBuilder .prompts (promptRegistrations );
271269 capabilitiesBuilder .prompts (serverProperties .isPromptChangeNotification ());
272- logger .info ("Registered prompts" + promptResgistrations .size () + " notification: "
270+ logger .info ("Registered prompts" + promptRegistrations .size () + " notification: "
273271 + serverProperties .isPromptChangeNotification ());
274272 }
275273
@@ -278,13 +276,13 @@ public McpAsyncServer mcpAsyncServer(ServerMcpTransport transport,
278276 consumer .accept (roots );
279277 return Mono .empty ();
280278 };
281- serverBilder .rootsChangeConsumer (asyncConsumer );
279+ serverBuilder .rootsChangeConsumer (asyncConsumer );
282280 logger .info ("Registered roots change consumer" );
283281 });
284282
285- serverBilder .capabilities (capabilitiesBuilder .build ());
283+ serverBuilder .capabilities (capabilitiesBuilder .build ());
286284
287- return serverBilder .build ();
285+ return serverBuilder .build ();
288286 }
289287
290288}
0 commit comments