Skip to content

MCP Server with STDIO protocol fails to load @MCPTool annotated methods #4451

@ilayaperumalg

Description

@ilayaperumalg

From @sivaprasadreddy:

I have created a simple MCP Server with STDIO protocol. Its working fine with @tool and registering a List bean. But when I use @mcptool and test it from MCPInspector, it is throwing the following error:

STDIO transport: command=/Users/siva/.local/share/mise/installs/java/temurin-24.0.1+9/bin/java, args=-jar,/Users/siva/Siva/Projects/My/sivalabs-mcp/sivalabs-mcp-server-stdio/target/sivalabs-mcp-server-stdio-0.0.1.jar
Created client transport
Created server transport
Received POST message for sessionId 080fda54-4f11-4279-8d52-ae23fc5e4937
Error from MCP server: SyntaxError: Expected property name or '}' in JSON at position 1 (line 1 column 2)
    at JSON.parse (<anonymous>)
    at deserializeMessage (file:///Users/siva/.npm/_npx/9eac9498388ae25e/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js:26:44)
    at ReadBuffer.readMessage (file:///Users/siva/.npm/_npx/9eac9498388ae25e/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js:19:16)
    at StdioClientTransport.processReadBuffer (file:///Users/siva/.npm/_npx/9eac9498388ae25e/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js:141:50)
    at Socket.<anonymous> (file:///Users/siva/.npm/_npx/9eac9498388ae25e/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js:103:22)
    at Socket.emit (node:events:518:28)
    at addChunk (node:internal/streams/readable:561:12)
    at readableAddChunkPushByteMode (node:internal/streams/readable:512:3)
    at Readable.push (node:internal/streams/readable:392:5)
    at Pipe.onStreamRead (node:internal/stream_base_commons:189:23)

I tried the weather sample from spring-ai-examples and it is also throwing the same error.

Here is a reproducer example: https://github.com/sivaprasadreddy/sivalabs-mcp/tree/ai-1.1.0-SNAPSHOT

Checkout the branch ai-1.1.0-SNAPSHOT
cd sivalabs-mcp-server-stdio
mvn clean package
npx @modelcontextprotocol/inspector@latest
Transport Type: STDIO
Command: java
Arguments: -jar /sivalabs-mcp/sivalabs-mcp-server-stdio/target/sivalabs-mcp-server-stdio-0.0.1.jar

NOTE: https://github.com/mcptool support working fine with webmvc support (sse, streamable, stateless).

Metadata

Metadata

Assignees

No one assigned

    Labels

    MCPbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions