ARTICLE AD BOX
I am building a skeleton MCP server using Spring AI with the STDIO transport:
pom.xml
<properties> <java.version>21</java.version> <spring-ai-starter.version>1.1.4</spring-ai-starter.version> </properties> ... <dependency> <groupId>org.springframework.ai</groupId> <artifactId>spring-ai-starter-mcp-server</artifactId> <version>${spring-ai-starter.version}</version> </dependency>application.yml
spring: ai: mcp: server: stdio: true name: light-mcp version: 0.0.1 main: banner-mode: off web-application-type: noneComponent
@Tool(name = "get_random_number", description="Return a random number", returnDirect = true) public long getRandomNumber() { long newRandomLong = new Random(System.currentTimeMillis()).nextLong(); return newRandomLong; }Config
@Bean public ToolCallbackProvider getToolCallbacks(McpComponent lightMcpComponent) { return ToolCallbackProvider.from(List.of(ToolCallbacks.from(tMcpComponent))); }After starting the I see the tool is registered and input processed (getting an error message on invalid input):
java -jar target/mcp-server-.... ... o.s.a.m.s.c.a.McpServerAutoConfiguration : Registered tools: 1 ...When I send s valid JSON-RCP to the input, I cannot get any output back. Nor do I see the tool methods called.
{"jsonrpc":"2.0","id":2,"method":"tools/list"} {"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"get_random_number","arguments":{}}}This is sent to the input (stdin) after the server starts, but I see no output printed whatsoever. If I provide invalid method value, an error message is returned, so it looks like the input is somehow handled.
