spring.ai.mcp.client.toolcallback.enabled=true spring.ai.mcp.client.stdio.connections.server1.command=java spring.ai.mcp.client.stdio.connections.server1.args[0]=-jar spring.ai.mcp.client.stdio.connections.server1.args[1]=D:/01/mcp-server-demo/target/mcp-server-demo-0.0.1-SNAPSHOT.jar spring.ai.mcp.client.type=sync spring.mandatory-file-encoding=UTF-8
com.fasterxml.jackson.core.JsonParseException: Unexpected character ('-' (code 45)): Expected space separating root-level values
at [Source: REDACTED (StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION
disabled); line: 1, column: 5]
at com.fasterxml.jackson.core.JsonParser._constructReadException(JsonParser.java:2666)
at com.fasterxml.jackson.core.base.ParserMinimalBase._reportUnexpectedChar(ParserMinimalBase.java:742)
at com.fasterxml.jackson.core.base.ParserMinimalBase._reportMissingRootWS(ParserMinimalBase.java:660)
at com.fasterxml.jackson.core.json.ReaderBasedJsonParser._verifyRootSpace(ReaderBasedJsonParser.java:1800)
at com.fasterxml.jackson.core.json.ReaderBasedJsonParser._parseUnsignedNumber(ReaderBasedJsonParser.java:1396)
at com.fasterxml.jackson.core.json.ReaderBasedJsonParser.nextToken(ReaderBasedJsonParser.java:777)
at com.fasterxml.jackson.databind.ObjectMapper._initForReading(ObjectMapper.java:5058)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4961)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3887)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3870)
at io.modelcontextprotocol.spec.McpSchema.deserializeJsonRpcMessage(McpSchema.java:157)
at io.modelcontextprotocol.client.transport.StdioClientTransport.lambda$startInboundProcessing$6(StdioClientTransport.java:260)
Comment From: zwp88
jdk17 mcp server has packaged a jar file ,and using other clients is successful
Comment From: sunyuhan1998
Hi @zwp88 If so, can you provide the source code for your MCP Server?
Comment From: zwp88
我已经收到啦! 谢谢!
Comment From: adordly
我也有类似的问题,jdk换了17,21,16都不好使,用的是1.0.0-M6版本,mcp配置json文件如下:
Comment From: sunyuhan1998
我也有类似的问题,jdk换了17,21,16都不好使,用的是1.0.0-M6版本,mcp配置json文件如下:
Can you provide the source code for your MCP Server?
Comment From: sunyuhan1998
Hi @zwp88 @adordly , I've tried to reproduce your issue, and I believe the cause is that you haven't added the following configuration in your MCP server application.yaml:
spring:
main:
web-application-type: none
banner-mode: off
logging:
pattern:
console=:
Let me explain why this is necessary:
In stdio
mode, after the MCP client starts the MCP server JAR, it captures the standard output of that JAR for communication. However, during startup, Spring
typically prints some log messages—such as the banner or lines like "Starting xxx using Java 17.xx with PID xxx"—to the standard output. The MCP client captures these outputs and attempts to deserialize them, but they are not part of the actual communication protocol. This causes deserialization failures on the client side.
To resolve this, we simply need to suppress these irrelevant logs.
In fact, this is an issue with the MCP Java SDK, not with Spring AI itself. I think the MCP Java SDK can be improved further.