Replies: 1 comment
-
Hi.. You think this is related to #569? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Pre-submission Checklist
Question Category
Your Question
I'm using spring-boot-ai to understand how to create an MCP server. I have used the spring-boot-ai-example but they do not seem to work.
I have created a simple "Echo" tool. I do see it registered since I get the schema.
16:40:00.932 [main] INFO c.m.m.a.l.LogAnalyticsMcpServer - >>> Definition: DefaultToolDefinition[name=echo, description=Echoes input, inputSchema={ "$schema" : "https://json-schema.org/draft/2020-12/schema", "type" : "object", "properties" : { "arg0" : { "type" : "string", "description" : "Message to echo" } }, "required" : [ "arg0" ], "additionalProperties" : false }] .... 16:45:33.675 [main] INFO o.s.a.m.s.a.McpServerAutoConfiguration - Enable tools capabilities, notification: true 16:45:33.675 [main] INFO o.s.a.m.s.a.McpServerAutoConfiguration - Registered tools: 3 <--- more than one tool including "echo" are registered 16:45:33.676 [main] INFO o.s.a.m.s.a.McpServerAutoConfiguration - Enable resources capabilities, notification: true 16:45:33.678 [main] INFO o.s.a.m.s.a.McpServerAutoConfiguration - Enable prompts capabilities, notification: true 16:45:33.679 [main] INFO o.s.a.m.s.a.McpServerAutoConfiguration - Enable completions capabilities
Then when I trigger the initialized method, that seems to work ok but when I run tools/call or tools/init nothing happens
{"jsonrpc": "2.0","method":"initialize","params":{"protocolVersion":"2024-11-05","model": "gpt-4","tools": ["echo"],"capabilities": {}}, "id": 1} 16:40:16.138 [pool-5-thread-1] DEBUG i.m.s.t.StdioServerTransportProvider - Received JSON message: {"jsonrpc": "2.0","method":"initialize","params":{"protocolVersion":"2024-11-05","model": "gpt-4","tools": ["echo"],"capabilities": {}}, "id": 1} 16:40:16.138 [pool-5-thread-1] DEBUG i.m.spec.McpSchema - Received JSON message: {"jsonrpc": "2.0","method":"initialize","params":{"protocolVersion":"2024-11-05","model": "gpt-4","tools": ["echo"],"capabilities": {}}, "id": 1} 16:40:16.151 [pool-5-thread-1] DEBUG i.m.spec.McpServerSession - Received request: JSONRPCRequest[jsonrpc=2.0, method=initialize, id=1, params={protocolVersion=2024-11-05, model=gpt-4, tools=[echo], capabilities={}}] 16:40:16.163 [pool-5-thread-1] INFO i.m.server.McpAsyncServer - Client initialize request - Protocol: 2024-11-05, Capabilities: ClientCapabilities[experimental=null, roots=null, sampling=null], Info: null {"jsonrpc":"2.0","id":1,"result":{"protocolVersion":"2024-11-05","capabilities":{"completions":{},"logging":{},"prompts":{"listChanged":true},"resources":{"subscribe":false,"listChanged":true},"tools":{"listChanged":true}},"serverInfo":{"name":"log-analytics-s","version":"1.0.0"},"instructions":"This reactive server provides onprem log anaylitics tools and resources"}} {"jsonrpc": "2.0","method": "tools/call","params": {"name": "echo","arguments": {"arg0": "hello"}},"id": 3} 16:40:57.111 [pool-5-thread-1] DEBUG i.m.s.t.StdioServerTransportProvider - Received JSON message: {"jsonrpc": "2.0","method": "tools/call","params": {"name": "echo","arguments": {"arg0": "hello"}},"id": 3} 16:40:57.112 [pool-5-thread-1] DEBUG i.m.spec.McpSchema - Received JSON message: {"jsonrpc": "2.0","method": "tools/call","params": {"name": "echo","arguments": {"arg0": "hello"}},"id": 3} 16:40:57.112 [pool-5-thread-1] DEBUG i.m.spec.McpServerSession - Received request: JSONRPCRequest[jsonrpc=2.0, method=tools/call, id=3, params={name=echo, arguments={arg0=hello}}]
Then if I change McpServerSession.java handleIncomingRequest and I add "exchangeSink.tryEmitValue" before the flatMap:
if (exchangeSink.tryEmitValue(new McpAsyncServerExchange(this, clientCapabilities.get(), clientInfo.get())).isSuccess()) { logger.debug("Successfully emitted value to exchangeSink"); } else { logger.warn("Failed to emit value to exchangeSink"); } resultMono = this.exchangeSink.asMono().flatMap(exchange -> handler.handle(exchange, request.params()))
Then I do get an answer back. I do not understand what I miss or if something else is wrong or ...
The spring-ai-example code behaves the same ....
{"jsonrpc": "2.0","method":"initialize","params":{"protocolVersion":"2024-11-05","model": "gpt-4","tools": ["echo"],"capabilities": {}}, "id": 1} 16:45:41.224 [pool-5-thread-1] DEBUG i.m.s.t.StdioServerTransportProvider - Received JSON message: {"jsonrpc": "2.0","method":"initialize","params":{"protocolVersion":"2024-11-05","model": "gpt-4","tools": ["echo"],"capabilities": {}}, "id": 1} 16:45:41.225 [pool-5-thread-1] DEBUG i.m.spec.McpSchema - Received JSON message: {"jsonrpc": "2.0","method":"initialize","params":{"protocolVersion":"2024-11-05","model": "gpt-4","tools": ["echo"],"capabilities": {}}, "id": 1} 16:45:41.236 [pool-5-thread-1] DEBUG i.m.spec.McpServerSession - Received request: JSONRPCRequest[jsonrpc=2.0, method=initialize, id=1, params={protocolVersion=2024-11-05, model=gpt-4, tools=[echo], capabilities={}}] 16:45:41.247 [pool-5-thread-1] INFO i.m.server.McpAsyncServer - Client initialize request - Protocol: 2024-11-05, Capabilities: ClientCapabilities[experimental=null, roots=null, sampling=null], Info: null {"jsonrpc":"2.0","id":1,"result":{"protocolVersion":"2024-11-05","capabilities":{"completions":{},"logging":{},"prompts":{"listChanged":true},"resources":{"subscribe":false,"listChanged":true},"tools":{"listChanged":true}},"serverInfo":{"name":"log-analytics-s","version":"1.0.0"},"instructions":"This reactive server provides onprem log anaylitics tools and resources"}} {"jsonrpc": "2.0","method": "tools/call","params": {"name": "echo","arguments": {"arg0": "hello"}},"id": 3} 16:45:52.824 [pool-5-thread-1] DEBUG i.m.s.t.StdioServerTransportProvider - Received JSON message: {"jsonrpc": "2.0","method": "tools/call","params": {"name": "echo","arguments": {"arg0": "hello"}},"id": 3} 16:45:52.825 [pool-5-thread-1] DEBUG i.m.spec.McpSchema - Received JSON message: {"jsonrpc": "2.0","method": "tools/call","params": {"name": "echo","arguments": {"arg0": "hello"}},"id": 3} 16:45:52.825 [pool-5-thread-1] DEBUG i.m.spec.McpServerSession - Received request: JSONRPCRequest[jsonrpc=2.0, method=tools/call, id=3, params={name=echo, arguments={arg0=hello}}] 16:45:52.827 [pool-5-thread-1] DEBUG i.m.spec.McpServerSession - Successfully emitted value to exchangeSink 16:45:52.834 [boundedElastic-1] DEBUG o.s.a.tool.method.MethodToolCallback - Starting execution of tool: echo 16:45:52.836 [boundedElastic-1] INFO c.m.m.ai.loganalytics.test.EchoTool - Echo tool called with message: hello 16:45:52.836 [boundedElastic-1] DEBUG o.s.a.tool.method.MethodToolCallback - Successful execution of tool: echo **16:45:52.836 [boundedElastic-1] DEBUG o.s.a.t.e.DefaultToolCallResultConverter - Converting tool result to JSON. {"jsonrpc":"2.0","id":3,"result":{"content":[{"type":"text","text":"\"hello\""}],"isError":false}}**
Any help is appreciated! Thank you.
Beta Was this translation helpful? Give feedback.
All reactions