Update the mcp demos to latest 0.6.0 version
This commit is contained in:
78
mcp.servlet-server.log
Normal file
78
mcp.servlet-server.log
Normal file
@@ -0,0 +1,78 @@
|
||||
2025-01-24T19:02:28.340+01:00 INFO 90451 --- [main] .s.a.m.s.s.s.McpServletServerApplication : Starting McpServletServerApplication v0.0.1-SNAPSHOT using Java 23.0.1 with PID 90451 (/Users/christiantzolov/Dev/projects/spring-ai-examples/model-context-protocol/mcp-servlet-server/target/mcp-servlet-server-0.0.1-SNAPSHOT.jar started by christiantzolov in /Users/christiantzolov/Dev/projects/spring-ai-examples)
|
||||
2025-01-24T19:02:28.342+01:00 INFO 90451 --- [main] .s.a.m.s.s.s.McpServletServerApplication : No active profile set, falling back to 1 default profile: "default"
|
||||
2025-01-24T19:02:28.753+01:00 INFO 90451 --- [main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port 8080 (http)
|
||||
2025-01-24T19:02:28.760+01:00 INFO 90451 --- [main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
|
||||
2025-01-24T19:02:28.760+01:00 INFO 90451 --- [main] o.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/10.1.33]
|
||||
2025-01-24T19:02:28.779+01:00 INFO 90451 --- [main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
|
||||
2025-01-24T19:02:28.779+01:00 INFO 90451 --- [main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 404 ms
|
||||
2025-01-24T19:02:29.106+01:00 INFO 90451 --- [pool-1-thread-1] o.s.ai.mcp.spec.DefaultMcpSession : Received request: JSONRPCRequest[jsonrpc=2.0, method=initialize, id=d4d5aeb5-0, params={protocolVersion=2024-11-05, capabilities={}, clientInfo={name=Spring AI MCP Client, version=1.0.0}}]
|
||||
2025-01-24T19:02:29.112+01:00 INFO 90451 --- [pool-1-thread-1] o.s.ai.mcp.server.McpAsyncServer : Client initialize request - Protocol: 2024-11-05, Capabilities: ClientCapabilities[experimental=null, roots=null, sampling=null], Info: Implementation[name=Spring AI MCP Client, version=1.0.0]
|
||||
2025-01-24T19:02:29.153+01:00 INFO 90451 --- [main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port 8080 (http) with context path '/'
|
||||
2025-01-24T19:02:29.161+01:00 INFO 90451 --- [main] .s.a.m.s.s.s.McpServletServerApplication : Started McpServletServerApplication in 1.034 seconds (process running for 1.272)
|
||||
2025-01-24T19:02:29.163+01:00 INFO 90451 --- [pool-1-thread-1] o.s.ai.mcp.spec.DefaultMcpSession : Received notification: JSONRPCNotification[jsonrpc=2.0, method=notifications/initialized, params=null]
|
||||
2025-01-24T19:02:29.164+01:00 INFO 90451 --- [pool-1-thread-1] o.s.ai.mcp.spec.DefaultMcpSession : Received request: JSONRPCRequest[jsonrpc=2.0, method=ping, id=d4d5aeb5-1, params=null]
|
||||
2025-01-24T19:02:29.167+01:00 INFO 90451 --- [pool-1-thread-1] o.s.ai.mcp.spec.DefaultMcpSession : Received request: JSONRPCRequest[jsonrpc=2.0, method=tools/list, id=d4d5aeb5-2, params={}]
|
||||
2025-01-24T19:02:29.177+01:00 INFO 90451 --- [pool-1-thread-1] o.s.ai.mcp.spec.DefaultMcpSession : Received request: JSONRPCRequest[jsonrpc=2.0, method=tools/call, id=d4d5aeb5-3, params={name=toUpperCase, arguments={input=accountName}}]
|
||||
2025-01-24T19:02:29.195+01:00 INFO 90451 --- [pool-1-thread-1] o.s.ai.mcp.spec.DefaultMcpSession : Received request: JSONRPCRequest[jsonrpc=2.0, method=tools/call, id=d4d5aeb5-4, params={name=getBooks, arguments={title=Spring Framework}}]
|
||||
2025-01-24T19:02:30.723+01:00 INFO 90451 --- [pool-1-thread-1] o.s.ai.mcp.spec.DefaultMcpSession : Received request: JSONRPCRequest[jsonrpc=2.0, method=resources/list, id=d4d5aeb5-5, params={}]
|
||||
2025-01-24T19:02:30.730+01:00 INFO 90451 --- [pool-1-thread-1] o.s.ai.mcp.spec.DefaultMcpSession : Received request: JSONRPCRequest[jsonrpc=2.0, method=resources/read, id=d4d5aeb5-6, params={uri=system://info}]
|
||||
2025-01-24T19:02:30.738+01:00 INFO 90451 --- [pool-1-thread-1] o.s.ai.mcp.spec.DefaultMcpSession : Received request: JSONRPCRequest[jsonrpc=2.0, method=prompts/list, id=d4d5aeb5-7, params={}]
|
||||
2025-01-24T19:02:30.744+01:00 INFO 90451 --- [pool-1-thread-1] o.s.ai.mcp.spec.DefaultMcpSession : Received request: JSONRPCRequest[jsonrpc=2.0, method=prompts/get, id=d4d5aeb5-8, params={name=greeting, arguments={name=Spring}}]
|
||||
2025-01-24T19:02:43.319+01:00 INFO 90643 --- [main] .s.a.m.s.s.s.McpServletServerApplication : Starting McpServletServerApplication using Java 17.0.12 with PID 90643 (/Users/christiantzolov/Dev/projects/spring-ai-examples/model-context-protocol/mcp-servlet-server/target/classes started by christiantzolov in /Users/christiantzolov/Dev/projects/spring-ai-examples)
|
||||
2025-01-24T19:02:43.320+01:00 INFO 90643 --- [main] .s.a.m.s.s.s.McpServletServerApplication : No active profile set, falling back to 1 default profile: "default"
|
||||
2025-01-24T19:02:43.653+01:00 INFO 90643 --- [main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port 8080 (http)
|
||||
2025-01-24T19:02:43.658+01:00 INFO 90643 --- [main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
|
||||
2025-01-24T19:02:43.659+01:00 INFO 90643 --- [main] o.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/10.1.33]
|
||||
2025-01-24T19:02:43.683+01:00 INFO 90643 --- [main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
|
||||
2025-01-24T19:02:43.683+01:00 INFO 90643 --- [main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 345 ms
|
||||
2025-01-24T19:02:44.003+01:00 INFO 90643 --- [main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port 8080 (http) with context path '/'
|
||||
2025-01-24T19:02:44.008+01:00 INFO 90643 --- [main] .s.a.m.s.s.s.McpServletServerApplication : Started McpServletServerApplication in 0.862 seconds (process running for 0.983)
|
||||
2025-01-24T19:02:47.492+01:00 INFO 90643 --- [http-nio-8080-exec-2] o.s.ai.mcp.spec.DefaultMcpSession : Received request: JSONRPCRequest[jsonrpc=2.0, method=initialize, id=7b98b98f-0, params={protocolVersion=2024-11-05, capabilities={}, clientInfo={name=Spring AI MCP Client, version=1.0.0}}]
|
||||
2025-01-24T19:02:47.496+01:00 INFO 90643 --- [http-nio-8080-exec-2] o.s.ai.mcp.server.McpAsyncServer : Client initialize request - Protocol: 2024-11-05, Capabilities: ClientCapabilities[experimental=null, roots=null, sampling=null], Info: Implementation[name=Spring AI MCP Client, version=1.0.0]
|
||||
2025-01-24T19:02:47.541+01:00 INFO 90643 --- [http-nio-8080-exec-3] o.s.ai.mcp.spec.DefaultMcpSession : Received notification: JSONRPCNotification[jsonrpc=2.0, method=notifications/initialized, params=null]
|
||||
2025-01-24T19:02:47.544+01:00 INFO 90643 --- [http-nio-8080-exec-4] o.s.ai.mcp.spec.DefaultMcpSession : Received request: JSONRPCRequest[jsonrpc=2.0, method=ping, id=7b98b98f-1, params=null]
|
||||
2025-01-24T19:02:47.547+01:00 INFO 90643 --- [http-nio-8080-exec-5] o.s.ai.mcp.spec.DefaultMcpSession : Received request: JSONRPCRequest[jsonrpc=2.0, method=tools/list, id=7b98b98f-2, params={}]
|
||||
2025-01-24T19:02:47.557+01:00 INFO 90643 --- [http-nio-8080-exec-6] o.s.ai.mcp.spec.DefaultMcpSession : Received request: JSONRPCRequest[jsonrpc=2.0, method=tools/call, id=7b98b98f-3, params={name=toUpperCase, arguments={input=accountName}}]
|
||||
2025-01-24T19:02:47.579+01:00 INFO 90643 --- [http-nio-8080-exec-7] o.s.ai.mcp.spec.DefaultMcpSession : Received request: JSONRPCRequest[jsonrpc=2.0, method=tools/call, id=7b98b98f-4, params={name=getBooks, arguments={title=Spring Framework}}]
|
||||
2025-01-24T19:02:49.611+01:00 INFO 90643 --- [http-nio-8080-exec-8] o.s.ai.mcp.spec.DefaultMcpSession : Received request: JSONRPCRequest[jsonrpc=2.0, method=resources/list, id=7b98b98f-5, params={}]
|
||||
2025-01-24T19:02:49.621+01:00 INFO 90643 --- [http-nio-8080-exec-9] o.s.ai.mcp.spec.DefaultMcpSession : Received request: JSONRPCRequest[jsonrpc=2.0, method=resources/read, id=7b98b98f-6, params={uri=system://info}]
|
||||
2025-01-24T19:02:49.630+01:00 INFO 90643 --- [http-nio-8080-exec-10] o.s.ai.mcp.spec.DefaultMcpSession : Received request: JSONRPCRequest[jsonrpc=2.0, method=prompts/list, id=7b98b98f-7, params={}]
|
||||
2025-01-24T19:02:49.637+01:00 INFO 90643 --- [http-nio-8080-exec-1] o.s.ai.mcp.spec.DefaultMcpSession : Received request: JSONRPCRequest[jsonrpc=2.0, method=prompts/get, id=7b98b98f-8, params={name=greeting, arguments={name=Spring}}]
|
||||
2025-01-24T19:02:52.594+01:00 ERROR 90643 --- [SpringApplicationShutdownHook] reactor.core.publisher.Operators : Operator called default onErrorDropped
|
||||
|
||||
reactor.core.Exceptions$ErrorCallbackNotImplemented: java.lang.IllegalStateException: The request associated with the AsyncContext has already completed processing.
|
||||
Caused by: java.lang.IllegalStateException: The request associated with the AsyncContext has already completed processing.
|
||||
at org.apache.catalina.core.AsyncContextImpl.check(AsyncContextImpl.java:529) ~[tomcat-embed-core-10.1.33.jar:10.1.33]
|
||||
at org.apache.catalina.core.AsyncContextImpl.complete(AsyncContextImpl.java:92) ~[tomcat-embed-core-10.1.33.jar:10.1.33]
|
||||
at org.springframework.ai.mcp.server.transport.HttpServletSseServerTransport.removeSession(HttpServletSseServerTransport.java:392) ~[mcp-0.6.0.jar:0.6.0]
|
||||
at java.base/java.util.concurrent.ConcurrentHashMap$ValuesView.forEach(ConcurrentHashMap.java:4780) ~[na:na]
|
||||
at org.springframework.ai.mcp.server.transport.HttpServletSseServerTransport.lambda$closeGracefully$4(HttpServletSseServerTransport.java:364) ~[mcp-0.6.0.jar:0.6.0]
|
||||
at reactor.core.publisher.MonoCreate.subscribe(MonoCreate.java:61) ~[reactor-core-3.6.12.jar:3.6.12]
|
||||
at reactor.core.publisher.Mono.subscribe(Mono.java:4576) ~[reactor-core-3.6.12.jar:3.6.12]
|
||||
at reactor.core.publisher.Mono.subscribeWith(Mono.java:4642) ~[reactor-core-3.6.12.jar:3.6.12]
|
||||
at reactor.core.publisher.Mono.subscribe(Mono.java:4403) ~[reactor-core-3.6.12.jar:3.6.12]
|
||||
at org.springframework.ai.mcp.spec.McpTransport.close(McpTransport.java:74) ~[mcp-0.6.0.jar:0.6.0]
|
||||
at org.springframework.ai.mcp.server.transport.HttpServletSseServerTransport.close(HttpServletSseServerTransport.java:336) ~[mcp-0.6.0.jar:0.6.0]
|
||||
at org.springframework.ai.mcp.spec.DefaultMcpSession.close(DefaultMcpSession.java:296) ~[mcp-0.6.0.jar:0.6.0]
|
||||
at org.springframework.ai.mcp.server.McpAsyncServer.close(McpAsyncServer.java:396) ~[mcp-0.6.0.jar:0.6.0]
|
||||
at org.springframework.ai.mcp.server.McpSyncServer.close(McpSyncServer.java:250) ~[mcp-0.6.0.jar:0.6.0]
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
|
||||
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na]
|
||||
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
|
||||
at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na]
|
||||
at org.springframework.beans.factory.support.DisposableBeanAdapter.invokeCustomDestroyMethod(DisposableBeanAdapter.java:316) ~[spring-beans-6.1.15.jar:6.1.15]
|
||||
at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:249) ~[spring-beans-6.1.15.jar:6.1.15]
|
||||
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:587) ~[spring-beans-6.1.15.jar:6.1.15]
|
||||
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:559) ~[spring-beans-6.1.15.jar:6.1.15]
|
||||
at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:1202) ~[spring-beans-6.1.15.jar:6.1.15]
|
||||
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:520) ~[spring-beans-6.1.15.jar:6.1.15]
|
||||
at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons(DefaultListableBeanFactory.java:1195) ~[spring-beans-6.1.15.jar:6.1.15]
|
||||
at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1195) ~[spring-context-6.1.15.jar:6.1.15]
|
||||
at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1156) ~[spring-context-6.1.15.jar:6.1.15]
|
||||
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.doClose(ServletWebServerApplicationContext.java:174) ~[spring-boot-3.3.6.jar:3.3.6]
|
||||
at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:1102) ~[spring-context-6.1.15.jar:6.1.15]
|
||||
at org.springframework.boot.SpringApplicationShutdownHook.closeAndWait(SpringApplicationShutdownHook.java:145) ~[spring-boot-3.3.6.jar:3.3.6]
|
||||
at java.base/java.lang.Iterable.forEach(Iterable.java:75) ~[na:na]
|
||||
at org.springframework.boot.SpringApplicationShutdownHook.run(SpringApplicationShutdownHook.java:114) ~[spring-boot-3.3.6.jar:3.3.6]
|
||||
at java.base/java.lang.Thread.run(Thread.java:842) ~[na:na]
|
||||
|
||||
62
mcp.webflux.log
Normal file
62
mcp.webflux.log
Normal file
@@ -0,0 +1,62 @@
|
||||
2025-01-24T12:29:43.836+01:00 INFO 49430 --- [main] o.s.a.m.s.server.McpServerApplication : Starting McpServerApplication v0.0.1-SNAPSHOT using Java 23.0.1 with PID 49430 (/Users/christiantzolov/Dev/projects/spring-ai-examples/model-context-protocol/mcp-webflux-server/target/mcp-webflux-server-0.0.1-SNAPSHOT.jar started by christiantzolov in /Users/christiantzolov/Dev/projects/spring-ai-examples)
|
||||
2025-01-24T12:29:43.837+01:00 INFO 49430 --- [main] o.s.a.m.s.server.McpServerApplication : No active profile set, falling back to 1 default profile: "default"
|
||||
2025-01-24T12:29:44.414+01:00 INFO 49430 --- [pool-1-thread-1] o.s.ai.mcp.spec.DefaultMcpSession : Received request: JSONRPCRequest[jsonrpc=2.0, method=initialize, id=9ad56cc6-0, params={protocolVersion=2024-11-05, capabilities={}, clientInfo={name=Spring AI MCP Client, version=1.0.0}}]
|
||||
2025-01-24T12:29:44.422+01:00 INFO 49430 --- [pool-1-thread-1] o.s.ai.mcp.server.McpAsyncServer : Client initialize request - Protocol: 2024-11-05, Capabilities: ClientCapabilities[experimental=null, roots=null, sampling=null], Info: Implementation[name=Spring AI MCP Client, version=1.0.0]
|
||||
2025-01-24T12:29:44.475+01:00 INFO 49430 --- [pool-1-thread-1] o.s.ai.mcp.spec.DefaultMcpSession : Received notification: JSONRPCNotification[jsonrpc=2.0, method=notifications/initialized, params=null]
|
||||
2025-01-24T12:29:44.475+01:00 INFO 49430 --- [pool-1-thread-1] o.s.ai.mcp.spec.DefaultMcpSession : Received request: JSONRPCRequest[jsonrpc=2.0, method=ping, id=9ad56cc6-1, params=null]
|
||||
2025-01-24T12:29:44.478+01:00 INFO 49430 --- [pool-1-thread-1] o.s.ai.mcp.spec.DefaultMcpSession : Received request: JSONRPCRequest[jsonrpc=2.0, method=tools/list, id=9ad56cc6-2, params={}]
|
||||
2025-01-24T12:29:44.490+01:00 INFO 49430 --- [pool-1-thread-1] o.s.ai.mcp.spec.DefaultMcpSession : Received request: JSONRPCRequest[jsonrpc=2.0, method=tools/call, id=9ad56cc6-3, params={name=toUpperCase, arguments={input=accountName}}]
|
||||
2025-01-24T12:29:44.515+01:00 INFO 49430 --- [pool-1-thread-1] o.s.ai.mcp.spec.DefaultMcpSession : Received request: JSONRPCRequest[jsonrpc=2.0, method=tools/call, id=9ad56cc6-4, params={name=getBooks, arguments={title=Spring Framework}}]
|
||||
2025-01-24T12:29:44.520+01:00 INFO 49430 --- [main] o.s.a.m.s.server.McpServerApplication : Started McpServerApplication in 0.91 seconds (process running for 1.157)
|
||||
2025-01-24T12:29:49.269+01:00 INFO 49430 --- [pool-1-thread-1] o.s.ai.mcp.spec.DefaultMcpSession : Received request: JSONRPCRequest[jsonrpc=2.0, method=resources/list, id=9ad56cc6-5, params={}]
|
||||
2025-01-24T12:29:49.276+01:00 INFO 49430 --- [pool-1-thread-1] o.s.ai.mcp.spec.DefaultMcpSession : Received request: JSONRPCRequest[jsonrpc=2.0, method=resources/read, id=9ad56cc6-6, params={uri=system://info}]
|
||||
2025-01-24T12:29:49.286+01:00 INFO 49430 --- [pool-1-thread-1] o.s.ai.mcp.spec.DefaultMcpSession : Received request: JSONRPCRequest[jsonrpc=2.0, method=prompts/list, id=9ad56cc6-7, params={}]
|
||||
2025-01-24T12:29:49.293+01:00 INFO 49430 --- [pool-1-thread-1] o.s.ai.mcp.spec.DefaultMcpSession : Received request: JSONRPCRequest[jsonrpc=2.0, method=prompts/get, id=9ad56cc6-8, params={name=greeting, arguments={name=Spring}}]
|
||||
2025-01-24T19:03:06.765+01:00 INFO 90957 --- [main] o.s.a.m.s.server.McpServerApplication : Starting McpServerApplication v0.0.1-SNAPSHOT using Java 23.0.1 with PID 90957 (/Users/christiantzolov/Dev/projects/spring-ai-examples/model-context-protocol/mcp-webflux-server/target/mcp-webflux-server-0.0.1-SNAPSHOT.jar started by christiantzolov in /Users/christiantzolov/Dev/projects/spring-ai-examples)
|
||||
2025-01-24T19:03:06.767+01:00 INFO 90957 --- [main] o.s.a.m.s.server.McpServerApplication : No active profile set, falling back to 1 default profile: "default"
|
||||
2025-01-24T19:03:07.174+01:00 INFO 91011 --- [main] o.s.a.m.s.server.McpServerApplication : Starting McpServerApplication v0.0.1-SNAPSHOT using Java 23.0.1 with PID 91011 (/Users/christiantzolov/Dev/projects/spring-ai-examples/model-context-protocol/mcp-webflux-server/target/mcp-webflux-server-0.0.1-SNAPSHOT.jar started by christiantzolov in /Users/christiantzolov/Dev/projects/spring-ai-examples)
|
||||
2025-01-24T19:03:07.176+01:00 INFO 91011 --- [main] o.s.a.m.s.server.McpServerApplication : No active profile set, falling back to 1 default profile: "default"
|
||||
2025-01-24T19:03:07.427+01:00 INFO 90957 --- [pool-3-thread-1] o.s.ai.mcp.spec.DefaultMcpSession : Received request: JSONRPCRequest[jsonrpc=2.0, method=initialize, id=9e0a3f40-0, params={protocolVersion=2024-11-05, capabilities={}, clientInfo={name=Spring AI MCP Client, version=1.0.0}}]
|
||||
2025-01-24T19:03:07.433+01:00 INFO 90957 --- [pool-3-thread-1] o.s.ai.mcp.server.McpAsyncServer : Client initialize request - Protocol: 2024-11-05, Capabilities: ClientCapabilities[experimental=null, roots=null, sampling=null], Info: Implementation[name=Spring AI MCP Client, version=1.0.0]
|
||||
2025-01-24T19:03:07.499+01:00 INFO 90957 --- [pool-3-thread-1] o.s.ai.mcp.spec.DefaultMcpSession : Received notification: JSONRPCNotification[jsonrpc=2.0, method=notifications/initialized, params=null]
|
||||
2025-01-24T19:03:07.500+01:00 INFO 90957 --- [pool-3-thread-1] o.s.ai.mcp.spec.DefaultMcpSession : Received request: JSONRPCRequest[jsonrpc=2.0, method=ping, id=9e0a3f40-1, params=null]
|
||||
2025-01-24T19:03:07.502+01:00 INFO 90957 --- [pool-3-thread-1] o.s.ai.mcp.spec.DefaultMcpSession : Received request: JSONRPCRequest[jsonrpc=2.0, method=tools/list, id=9e0a3f40-2, params={}]
|
||||
2025-01-24T19:03:07.517+01:00 INFO 90957 --- [pool-3-thread-1] o.s.ai.mcp.spec.DefaultMcpSession : Received request: JSONRPCRequest[jsonrpc=2.0, method=tools/call, id=9e0a3f40-3, params={name=toUpperCase, arguments={input=accountName}}]
|
||||
2025-01-24T19:03:07.540+01:00 INFO 90957 --- [pool-3-thread-1] o.s.ai.mcp.spec.DefaultMcpSession : Received request: JSONRPCRequest[jsonrpc=2.0, method=tools/call, id=9e0a3f40-4, params={name=getBooks, arguments={title=Spring Framework}}]
|
||||
2025-01-24T19:03:07.628+01:00 INFO 90957 --- [main] o.s.b.web.embedded.netty.NettyWebServer : Netty started on port 8080 (http)
|
||||
2025-01-24T19:03:07.635+01:00 INFO 90957 --- [main] o.s.a.m.s.server.McpServerApplication : Started McpServerApplication in 1.093 seconds (process running for 1.335)
|
||||
2025-01-24T19:03:07.841+01:00 INFO 91011 --- [pool-3-thread-1] o.s.ai.mcp.spec.DefaultMcpSession : Received request: JSONRPCRequest[jsonrpc=2.0, method=initialize, id=a7f036cf-0, params={protocolVersion=2024-11-05, capabilities={}, clientInfo={name=Spring AI MCP Client, version=1.0.0}}]
|
||||
2025-01-24T19:03:07.849+01:00 INFO 91011 --- [pool-3-thread-1] o.s.ai.mcp.server.McpAsyncServer : Client initialize request - Protocol: 2024-11-05, Capabilities: ClientCapabilities[experimental=null, roots=null, sampling=null], Info: Implementation[name=Spring AI MCP Client, version=1.0.0]
|
||||
2025-01-24T19:03:07.904+01:00 INFO 91011 --- [pool-3-thread-1] o.s.ai.mcp.spec.DefaultMcpSession : Received notification: JSONRPCNotification[jsonrpc=2.0, method=notifications/initialized, params=null]
|
||||
2025-01-24T19:03:07.905+01:00 INFO 91011 --- [pool-3-thread-1] o.s.ai.mcp.spec.DefaultMcpSession : Received request: JSONRPCRequest[jsonrpc=2.0, method=ping, id=a7f036cf-1, params=null]
|
||||
2025-01-24T19:03:07.907+01:00 INFO 91011 --- [pool-3-thread-1] o.s.ai.mcp.spec.DefaultMcpSession : Received request: JSONRPCRequest[jsonrpc=2.0, method=tools/list, id=a7f036cf-2, params={}]
|
||||
2025-01-24T19:03:07.920+01:00 INFO 91011 --- [pool-3-thread-1] o.s.ai.mcp.spec.DefaultMcpSession : Received request: JSONRPCRequest[jsonrpc=2.0, method=tools/call, id=a7f036cf-3, params={name=toUpperCase, arguments={input=accountName}}]
|
||||
2025-01-24T19:03:07.946+01:00 INFO 91011 --- [pool-3-thread-1] o.s.ai.mcp.spec.DefaultMcpSession : Received request: JSONRPCRequest[jsonrpc=2.0, method=tools/call, id=a7f036cf-4, params={name=getBooks, arguments={title=Spring Framework}}]
|
||||
2025-01-24T19:03:10.035+01:00 INFO 91011 --- [pool-3-thread-1] o.s.ai.mcp.spec.DefaultMcpSession : Received request: JSONRPCRequest[jsonrpc=2.0, method=resources/list, id=a7f036cf-5, params={}]
|
||||
2025-01-24T19:03:10.045+01:00 INFO 91011 --- [pool-3-thread-1] o.s.ai.mcp.spec.DefaultMcpSession : Received request: JSONRPCRequest[jsonrpc=2.0, method=resources/read, id=a7f036cf-6, params={uri=system://info}]
|
||||
2025-01-24T19:03:10.057+01:00 INFO 91011 --- [pool-3-thread-1] o.s.ai.mcp.spec.DefaultMcpSession : Received request: JSONRPCRequest[jsonrpc=2.0, method=prompts/list, id=a7f036cf-7, params={}]
|
||||
2025-01-24T19:03:10.064+01:00 INFO 91011 --- [pool-3-thread-1] o.s.ai.mcp.spec.DefaultMcpSession : Received request: JSONRPCRequest[jsonrpc=2.0, method=prompts/get, id=a7f036cf-8, params={name=greeting, arguments={name=Spring}}]
|
||||
2025-01-24T19:03:10.070+01:00 WARN 91011 --- [main] onfigReactiveWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Failed to start bean 'webServerStartStop'
|
||||
2025-01-24T19:03:10.074+01:00 INFO 91011 --- [main] .s.b.a.l.ConditionEvaluationReportLogger :
|
||||
|
||||
Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
|
||||
2025-01-24T19:03:10.083+01:00 ERROR 91011 --- [main] o.s.b.d.LoggingFailureAnalysisReporter :
|
||||
|
||||
***************************
|
||||
APPLICATION FAILED TO START
|
||||
***************************
|
||||
|
||||
Description:
|
||||
|
||||
Web server failed to start. Port 8080 was already in use.
|
||||
|
||||
Action:
|
||||
|
||||
Identify and stop the process that's listening on port 8080 or configure this application to listen on another port.
|
||||
|
||||
2025-01-24T19:03:10.173+01:00 INFO 91011 --- [parallel-1] o.s.a.m.s.t.StdioServerTransport : Graceful shutdown completed
|
||||
2025-01-24T19:03:10.180+01:00 INFO 91011 --- [parallel-2] o.s.a.m.s.t.StdioServerTransport : Graceful shutdown completed
|
||||
2025-01-24T19:03:10.191+01:00 INFO 90957 --- [pool-3-thread-1] o.s.ai.mcp.spec.DefaultMcpSession : Received request: JSONRPCRequest[jsonrpc=2.0, method=resources/list, id=9e0a3f40-5, params={}]
|
||||
2025-01-24T19:03:10.199+01:00 INFO 90957 --- [pool-3-thread-1] o.s.ai.mcp.spec.DefaultMcpSession : Received request: JSONRPCRequest[jsonrpc=2.0, method=resources/read, id=9e0a3f40-6, params={uri=system://info}]
|
||||
2025-01-24T19:03:10.208+01:00 INFO 90957 --- [pool-3-thread-1] o.s.ai.mcp.spec.DefaultMcpSession : Received request: JSONRPCRequest[jsonrpc=2.0, method=prompts/list, id=9e0a3f40-7, params={}]
|
||||
2025-01-24T19:03:10.214+01:00 INFO 90957 --- [pool-3-thread-1] o.s.ai.mcp.spec.DefaultMcpSession : Received request: JSONRPCRequest[jsonrpc=2.0, method=prompts/get, id=9e0a3f40-8, params={name=greeting, arguments={name=Spring}}]
|
||||
@@ -43,7 +43,7 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.experimental</groupId>
|
||||
<artifactId>spring-ai-mcp</artifactId>
|
||||
<version>0.5.1</version>
|
||||
<version>0.6.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
@@ -50,7 +50,7 @@ public class Application {
|
||||
.addEnvVar("BRAVE_API_KEY", System.getenv("BRAVE_API_KEY"))
|
||||
.build();
|
||||
|
||||
var mcpClient = McpClient.using(new StdioClientTransport(stdioParams)).sync();
|
||||
var mcpClient = McpClient.sync(new StdioClientTransport(stdioParams)).build();
|
||||
var init = mcpClient.initialize();
|
||||
System.out.println("MCP Initialized: " + init);
|
||||
return mcpClient;
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.experimental</groupId>
|
||||
<artifactId>spring-ai-mcp</artifactId>
|
||||
<version>0.5.1</version>
|
||||
<version>0.6.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
@@ -70,8 +70,8 @@ public class Application {
|
||||
.args("-y", "@modelcontextprotocol/server-filesystem", getDbPath())
|
||||
.build();
|
||||
|
||||
var mcpClient = McpClient.using(new StdioClientTransport(stdioParams))
|
||||
.requestTimeout(Duration.ofSeconds(10)).sync();
|
||||
var mcpClient = McpClient.sync(new StdioClientTransport(stdioParams))
|
||||
.requestTimeout(Duration.ofSeconds(10)).build();
|
||||
|
||||
var init = mcpClient.initialize();
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<description>Sample application demonstrating MCP Servlet server usage</description>
|
||||
|
||||
<properties>
|
||||
<spring-ai-mcp.version>0.5.1</spring-ai-mcp.version>
|
||||
<spring-ai-mcp.version>0.6.0</spring-ai-mcp.version>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
|
||||
@@ -27,7 +27,7 @@ public class ClientStdio {
|
||||
public static void main(String[] args) {
|
||||
|
||||
var stdioParams = ServerParameters.builder("java")
|
||||
.args("-Dtransport.mode=stdio", "-jar",
|
||||
.args("-Dtransport.mode=stdio", "-Dspring.main.web-application-type=none", "-jar",
|
||||
"model-context-protocol/mcp-servlet-server/target/mcp-servlet-server-0.0.1-SNAPSHOT.jar")
|
||||
.build();
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ public class SampleClient {
|
||||
|
||||
public void run() {
|
||||
|
||||
var client = McpClient.using(this.transport).sync();
|
||||
var client = McpClient.sync(this.transport).build();
|
||||
|
||||
client.initialize();
|
||||
|
||||
|
||||
@@ -8,11 +8,11 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.ai.mcp.server.McpAsyncServer;
|
||||
import org.springframework.ai.mcp.server.McpServer;
|
||||
import org.springframework.ai.mcp.server.McpServer.PromptRegistration;
|
||||
import org.springframework.ai.mcp.server.McpServer.ResourceRegistration;
|
||||
import org.springframework.ai.mcp.server.McpServer.ToolRegistration;
|
||||
import org.springframework.ai.mcp.server.McpServerFeatures.SyncPromptRegistration;
|
||||
import org.springframework.ai.mcp.server.McpServerFeatures.SyncResourceRegistration;
|
||||
import org.springframework.ai.mcp.server.McpServerFeatures.SyncToolRegistration;
|
||||
import org.springframework.ai.mcp.server.McpSyncServer;
|
||||
import org.springframework.ai.mcp.server.transport.HttpServletSseServerTransport;
|
||||
import org.springframework.ai.mcp.server.transport.StdioServerTransport;
|
||||
import org.springframework.ai.mcp.spec.McpSchema;
|
||||
@@ -60,7 +60,7 @@ public class McpServerConfig implements WebMvcConfigurer {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public McpAsyncServer mcpServer(ServerMcpTransport transport, OpenLibrary openLibrary) { // @formatter:off
|
||||
public McpSyncServer mcpServer(ServerMcpTransport transport, OpenLibrary openLibrary) { // @formatter:off
|
||||
|
||||
// Configure server capabilities with resource support
|
||||
var capabilities = McpSchema.ServerCapabilities.builder()
|
||||
@@ -71,24 +71,24 @@ public class McpServerConfig implements WebMvcConfigurer {
|
||||
.build();
|
||||
|
||||
// Create the server with both tool and resource capabilities
|
||||
var server = McpServer.using(transport)
|
||||
var server = McpServer.sync(transport)
|
||||
.serverInfo("MCP Demo Servlet Server", "1.0.0")
|
||||
.capabilities(capabilities)
|
||||
.resources(systemInfoResourceRegistration())
|
||||
.prompts(greetingPromptRegistration())
|
||||
.tools(
|
||||
ToolHelper.toToolRegistration(
|
||||
ToolHelper.toSyncToolRegistration(
|
||||
FunctionCallback.builder()
|
||||
.function("toUpperCase", (Function<ToUpperCaseInput, String>) s -> s.input().toUpperCase())
|
||||
.description("To upper case")
|
||||
.inputType(ToUpperCaseInput.class)
|
||||
.build()))
|
||||
.tools(openLibraryToolRegistrations(openLibrary))
|
||||
.async();
|
||||
.build();
|
||||
return server; // @formatter:on
|
||||
} // @formatter:on
|
||||
|
||||
public static List<ToolRegistration> openLibraryToolRegistrations(OpenLibrary openLibrary) {
|
||||
public static List<SyncToolRegistration> openLibraryToolRegistrations(OpenLibrary openLibrary) {
|
||||
|
||||
var books = FunctionCallback.builder()
|
||||
.method("getBooks", String.class)
|
||||
@@ -102,10 +102,10 @@ public class McpServerConfig implements WebMvcConfigurer {
|
||||
.targetObject(openLibrary)
|
||||
.build();
|
||||
|
||||
return ToolHelper.toToolRegistration(books, bookTitlesByAuthor);
|
||||
return ToolHelper.toSyncToolRegistration(books, bookTitlesByAuthor);
|
||||
}
|
||||
|
||||
private static ResourceRegistration systemInfoResourceRegistration() {
|
||||
private static SyncResourceRegistration systemInfoResourceRegistration() {
|
||||
|
||||
// Create a resource registration for system information
|
||||
var systemInfoResource = new McpSchema.Resource( // @formatter:off
|
||||
@@ -115,7 +115,7 @@ public class McpServerConfig implements WebMvcConfigurer {
|
||||
"application/json", null
|
||||
);
|
||||
|
||||
var resourceRegistration = new ResourceRegistration(systemInfoResource, (request) -> {
|
||||
var resourceRegistration = new SyncResourceRegistration(systemInfoResource, (request) -> {
|
||||
try {
|
||||
var systemInfo = Map.of(
|
||||
"javaVersion", System.getProperty("java.version"),
|
||||
@@ -138,12 +138,12 @@ public class McpServerConfig implements WebMvcConfigurer {
|
||||
return resourceRegistration;
|
||||
}
|
||||
|
||||
private static PromptRegistration greetingPromptRegistration() {
|
||||
private static SyncPromptRegistration greetingPromptRegistration() {
|
||||
|
||||
var prompt = new McpSchema.Prompt("greeting", "A friendly greeting prompt",
|
||||
List.of(new McpSchema.PromptArgument("name", "The name to greet", true)));
|
||||
|
||||
return new PromptRegistration(prompt, getPromptRequest -> {
|
||||
return new SyncPromptRegistration(prompt, getPromptRequest -> {
|
||||
|
||||
String nameArgument = (String) getPromptRequest.arguments().get("name");
|
||||
if (nameArgument == null) {
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<description>Sample Spring Boot application demonstrating MCP server usage</description>
|
||||
|
||||
<properties>
|
||||
<spring-ai-mcp.version>0.5.1</spring-ai-mcp.version>
|
||||
<spring-ai-mcp.version>0.6.0</spring-ai-mcp.version>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
|
||||
@@ -31,7 +31,7 @@ public class ClientStdio {
|
||||
System.out.println(new File(".").getAbsolutePath());
|
||||
|
||||
var stdioParams = ServerParameters.builder("java")
|
||||
.args("-Dtransport.mode=stdio", "-jar",
|
||||
.args("-Dtransport.mode=stdio", "-Dspring.main.web-application-type=none", "-jar",
|
||||
"model-context-protocol/mcp-webflux-server/target/mcp-webflux-server-0.0.1-SNAPSHOT.jar")
|
||||
.build();
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ public class SampleClient {
|
||||
|
||||
public void run() {
|
||||
|
||||
var client = McpClient.using(this.transport).sync();
|
||||
var client = McpClient.sync(this.transport).build();
|
||||
|
||||
client.initialize();
|
||||
|
||||
|
||||
@@ -7,6 +7,31 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
public class McpServerApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
// var stackThread = new Thread() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// try {
|
||||
// while (true) {
|
||||
// Thread.sleep(5000);
|
||||
// java.util.Collection<java.lang.StackTraceElement[]> a1 =
|
||||
// java.lang.Thread.getAllStackTraces()
|
||||
// .values();
|
||||
// for (java.lang.StackTraceElement[] a2 : a1) {
|
||||
// System.out.println("==========");
|
||||
// for (java.lang.StackTraceElement a3 : a2) {
|
||||
// System.out.println(a3.toString());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// } catch (InterruptedException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
// stackThread.setDaemon(false);
|
||||
// stackThread.start();
|
||||
|
||||
SpringApplication.run(McpServerApplication.class, args);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,17 +8,13 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.ai.mcp.server.McpAsyncServer;
|
||||
import org.springframework.ai.mcp.server.McpServer;
|
||||
import org.springframework.ai.mcp.server.McpServer.PromptRegistration;
|
||||
import org.springframework.ai.mcp.server.McpServer.ResourceRegistration;
|
||||
import org.springframework.ai.mcp.server.McpServer.ToolRegistration;
|
||||
import org.springframework.ai.mcp.server.McpServerFeatures;
|
||||
import org.springframework.ai.mcp.server.McpSyncServer;
|
||||
import org.springframework.ai.mcp.server.transport.StdioServerTransport;
|
||||
import org.springframework.ai.mcp.server.transport.WebFluxSseServerTransport;
|
||||
import org.springframework.ai.mcp.spec.McpSchema;
|
||||
import org.springframework.ai.mcp.spec.McpSchema.CallToolResult;
|
||||
import org.springframework.ai.mcp.spec.McpSchema.GetPromptResult;
|
||||
import org.springframework.ai.mcp.spec.McpSchema.LoggingMessageNotification;
|
||||
import org.springframework.ai.mcp.spec.McpSchema.PromptMessage;
|
||||
import org.springframework.ai.mcp.spec.McpSchema.Role;
|
||||
import org.springframework.ai.mcp.spec.McpSchema.TextContent;
|
||||
@@ -62,7 +58,7 @@ public class McpServerConfig {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public McpAsyncServer mcpServer(ServerMcpTransport transport, OpenLibrary openLibrary) { // @formatter:off
|
||||
public McpSyncServer mcpServer(ServerMcpTransport transport, OpenLibrary openLibrary) { // @formatter:off
|
||||
|
||||
// Configure server capabilities with resource support
|
||||
var capabilities = McpSchema.ServerCapabilities.builder()
|
||||
@@ -73,24 +69,24 @@ public class McpServerConfig {
|
||||
.build();
|
||||
|
||||
// Create the server with both tool and resource capabilities
|
||||
var server = McpServer.using(transport)
|
||||
McpSyncServer server = McpServer.sync(transport)
|
||||
.serverInfo("MCP Demo WebFlux Server", "1.0.0")
|
||||
.capabilities(capabilities)
|
||||
.resources(systemInfoResourceRegistration()) // Resources
|
||||
.prompts(greetingPromptRegistration()) // Prompts
|
||||
.tools(openLibraryToolRegistrations(openLibrary)) // Method based tools
|
||||
.tools(ToolHelper.toToolRegistration( // java.util.Function based tools
|
||||
.tools(ToolHelper.toSyncToolRegistration( // java.util.Function based tools
|
||||
FunctionCallback.builder()
|
||||
.function("toUpperCase", (Function<ToUpperCaseInput, String>) s -> s.input().toUpperCase())
|
||||
.description("To upper case")
|
||||
.inputType(ToUpperCaseInput.class)
|
||||
.build()))
|
||||
.async();
|
||||
.build();
|
||||
|
||||
return server; // @formatter:on
|
||||
} // @formatter:on
|
||||
|
||||
public static List<ToolRegistration> openLibraryToolRegistrations(OpenLibrary openLibrary) {
|
||||
public static List<McpServerFeatures.SyncToolRegistration> openLibraryToolRegistrations(OpenLibrary openLibrary) {
|
||||
|
||||
var books = FunctionCallback.builder()
|
||||
.method("getBooks", String.class)
|
||||
@@ -104,10 +100,10 @@ public class McpServerConfig {
|
||||
.targetObject(openLibrary)
|
||||
.build();
|
||||
|
||||
return ToolHelper.toToolRegistration(books, bookTitlesByAuthor);
|
||||
return ToolHelper.toSyncToolRegistration(books, bookTitlesByAuthor);
|
||||
}
|
||||
|
||||
private static ResourceRegistration systemInfoResourceRegistration() {
|
||||
private static McpServerFeatures.SyncResourceRegistration systemInfoResourceRegistration() {
|
||||
|
||||
// Create a resource registration for system information
|
||||
var systemInfoResource = new McpSchema.Resource( // @formatter:off
|
||||
@@ -117,7 +113,7 @@ public class McpServerConfig {
|
||||
"application/json", null
|
||||
);
|
||||
|
||||
var resourceRegistration = new ResourceRegistration(systemInfoResource, (request) -> {
|
||||
var resourceRegistration = new McpServerFeatures.SyncResourceRegistration(systemInfoResource, (request) -> {
|
||||
try {
|
||||
var systemInfo = Map.of(
|
||||
"javaVersion", System.getProperty("java.version"),
|
||||
@@ -140,12 +136,12 @@ public class McpServerConfig {
|
||||
return resourceRegistration;
|
||||
}
|
||||
|
||||
private static PromptRegistration greetingPromptRegistration() {
|
||||
private static McpServerFeatures.SyncPromptRegistration greetingPromptRegistration() {
|
||||
|
||||
var prompt = new McpSchema.Prompt("greeting", "A friendly greeting prompt",
|
||||
List.of(new McpSchema.PromptArgument("name", "The name to greet", true)));
|
||||
|
||||
return new PromptRegistration(prompt, getPromptRequest -> {
|
||||
return new McpServerFeatures.SyncPromptRegistration(prompt, getPromptRequest -> {
|
||||
|
||||
String nameArgument = (String) getPromptRequest.arguments().get("name");
|
||||
if (nameArgument == null) {
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<description>Sample Spring Boot application demonstrating MCP WebMvc server usage</description>
|
||||
|
||||
<properties>
|
||||
<spring-ai-mcp.version>0.5.1</spring-ai-mcp.version>
|
||||
<spring-ai-mcp.version>0.6.0</spring-ai-mcp.version>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
|
||||
@@ -27,7 +27,7 @@ public class ClientStdio {
|
||||
public static void main(String[] args) {
|
||||
|
||||
var stdioParams = ServerParameters.builder("java")
|
||||
.args("-Dtransport.mode=stdio", "-jar",
|
||||
.args("-Dtransport.mode=stdio", "-Dspring.main.web-application-type=none", "-jar",
|
||||
"model-context-protocol/mcp-webmvc-server/target/mcp-webmvc-server-0.0.1-SNAPSHOT.jar")
|
||||
.build();
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ public class SampleClient {
|
||||
|
||||
public void run() {
|
||||
|
||||
var client = McpClient.using(this.transport).sync();
|
||||
var client = McpClient.sync(this.transport).build();
|
||||
|
||||
client.initialize();
|
||||
|
||||
|
||||
@@ -8,17 +8,15 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.springframework.ai.mcp.server.McpAsyncServer;
|
||||
import org.springframework.ai.mcp.server.McpServer;
|
||||
import org.springframework.ai.mcp.server.McpServer.PromptRegistration;
|
||||
import org.springframework.ai.mcp.server.McpServer.ResourceRegistration;
|
||||
import org.springframework.ai.mcp.server.McpServer.ToolRegistration;
|
||||
import org.springframework.ai.mcp.server.McpServerFeatures.SyncPromptRegistration;
|
||||
import org.springframework.ai.mcp.server.McpServerFeatures.SyncResourceRegistration;
|
||||
import org.springframework.ai.mcp.server.McpServerFeatures.SyncToolRegistration;
|
||||
import org.springframework.ai.mcp.server.McpSyncServer;
|
||||
import org.springframework.ai.mcp.server.transport.StdioServerTransport;
|
||||
import org.springframework.ai.mcp.server.transport.WebMvcSseServerTransport;
|
||||
import org.springframework.ai.mcp.spec.McpSchema;
|
||||
import org.springframework.ai.mcp.spec.McpSchema.CallToolResult;
|
||||
import org.springframework.ai.mcp.spec.McpSchema.GetPromptResult;
|
||||
import org.springframework.ai.mcp.spec.McpSchema.LoggingMessageNotification;
|
||||
import org.springframework.ai.mcp.spec.McpSchema.PromptMessage;
|
||||
import org.springframework.ai.mcp.spec.McpSchema.Role;
|
||||
import org.springframework.ai.mcp.spec.McpSchema.TextContent;
|
||||
@@ -63,7 +61,7 @@ public class McpServerConfig implements WebMvcConfigurer {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public McpAsyncServer mcpServer(ServerMcpTransport transport, OpenLibrary openLibrary) { // @formatter:off
|
||||
public McpSyncServer mcpServer(ServerMcpTransport transport, OpenLibrary openLibrary) { // @formatter:off
|
||||
|
||||
// Configure server capabilities with resource support
|
||||
var capabilities = McpSchema.ServerCapabilities.builder()
|
||||
@@ -74,24 +72,24 @@ public class McpServerConfig implements WebMvcConfigurer {
|
||||
.build();
|
||||
|
||||
// Create the server with both tool and resource capabilities
|
||||
var server = McpServer.using(transport)
|
||||
var server = McpServer.sync(transport)
|
||||
.serverInfo("MCP Demo WebMVC Server", "1.0.0")
|
||||
.capabilities(capabilities)
|
||||
.resources(systemInfoResourceRegistration())
|
||||
.prompts(greetingPromptRegistration())
|
||||
.tools(
|
||||
ToolHelper.toToolRegistration(
|
||||
ToolHelper.toSyncToolRegistration(
|
||||
FunctionCallback.builder()
|
||||
.function("toUpperCase", (Function<ToUpperCaseInput, String>) s -> s.input().toUpperCase())
|
||||
.description("To upper case")
|
||||
.inputType(ToUpperCaseInput.class)
|
||||
.build()))
|
||||
.tools(openLibraryToolRegistrations(openLibrary))
|
||||
.async();
|
||||
.build();
|
||||
return server; // @formatter:on
|
||||
} // @formatter:on
|
||||
|
||||
public static List<ToolRegistration> openLibraryToolRegistrations(OpenLibrary openLibrary) {
|
||||
public static List<SyncToolRegistration> openLibraryToolRegistrations(OpenLibrary openLibrary) {
|
||||
|
||||
var books = FunctionCallback.builder()
|
||||
.method("getBooks", String.class)
|
||||
@@ -105,10 +103,10 @@ public class McpServerConfig implements WebMvcConfigurer {
|
||||
.targetObject(openLibrary)
|
||||
.build();
|
||||
|
||||
return ToolHelper.toToolRegistration(books, bookTitlesByAuthor);
|
||||
return ToolHelper.toSyncToolRegistration(books, bookTitlesByAuthor);
|
||||
}
|
||||
|
||||
private static ResourceRegistration systemInfoResourceRegistration() {
|
||||
private static SyncResourceRegistration systemInfoResourceRegistration() {
|
||||
|
||||
// Create a resource registration for system information
|
||||
var systemInfoResource = new McpSchema.Resource( // @formatter:off
|
||||
@@ -118,7 +116,7 @@ public class McpServerConfig implements WebMvcConfigurer {
|
||||
"application/json", null
|
||||
);
|
||||
|
||||
var resourceRegistration = new ResourceRegistration(systemInfoResource, (request) -> {
|
||||
var resourceRegistration = new SyncResourceRegistration(systemInfoResource, (request) -> {
|
||||
try {
|
||||
var systemInfo = Map.of(
|
||||
"javaVersion", System.getProperty("java.version"),
|
||||
@@ -141,12 +139,12 @@ public class McpServerConfig implements WebMvcConfigurer {
|
||||
return resourceRegistration;
|
||||
}
|
||||
|
||||
private static PromptRegistration greetingPromptRegistration() {
|
||||
private static SyncPromptRegistration greetingPromptRegistration() {
|
||||
|
||||
var prompt = new McpSchema.Prompt("greeting", "A friendly greeting prompt",
|
||||
List.of(new McpSchema.PromptArgument("name", "The name to greet", true)));
|
||||
|
||||
return new PromptRegistration(prompt, getPromptRequest -> {
|
||||
return new SyncPromptRegistration(prompt, getPromptRequest -> {
|
||||
|
||||
String nameArgument = (String) getPromptRequest.arguments().get("name");
|
||||
if (nameArgument == null) {
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.experimental</groupId>
|
||||
<artifactId>spring-ai-mcp</artifactId>
|
||||
<version>0.5.1</version>
|
||||
<version>0.6.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
@@ -80,8 +80,8 @@ public class Application {
|
||||
getDbPath())
|
||||
.build();
|
||||
|
||||
var mcpClient = McpClient.using(new StdioClientTransport(stdioParams))
|
||||
.requestTimeout(Duration.ofSeconds(10)).sync();
|
||||
var mcpClient = McpClient.sync(new StdioClientTransport(stdioParams))
|
||||
.requestTimeout(Duration.ofSeconds(10)).build();
|
||||
|
||||
var init = mcpClient.initialize();
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.experimental</groupId>
|
||||
<artifactId>spring-ai-mcp</artifactId>
|
||||
<version>0.5.1</version>
|
||||
<version>0.6.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
@@ -78,8 +78,8 @@ public class Application {
|
||||
getDbPath())
|
||||
.build();
|
||||
|
||||
var mcpClient = McpClient.using(new StdioClientTransport(stdioParams))
|
||||
.requestTimeout(Duration.ofSeconds(10)).sync();
|
||||
var mcpClient = McpClient.sync(new StdioClientTransport(stdioParams))
|
||||
.requestTimeout(Duration.ofSeconds(10)).build();
|
||||
|
||||
var init = mcpClient.initialize();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user