Skip to content

MCP Server using STDIO - Attempting to user JSON RPC from Windows command line with partial success #3972

@jayhamilton

Description

@jayhamilton

Bug description
Created an MCP server. Added it to VSCode. The server is recognized and the 3 tools defined appear and work. On occasion, the 1 defined resource may appear in one of the VSCode windows but more times than not, selecting the resource results in a VS Code window showing an indeterminate progress bar until I restart VSCode.

What I would like to do is test the MCP server using JSON RPC. Here are the commands I sent using PowerShell and the results. It seems the only successful command that works is the initialization command. Not sure if the way I am attempting to test this is valid. resource or tool list command will return an error if the syntax is wrong, but will not display information when it is correct

echo '{"jsonrpc":"2.0", "id":1, "method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{"roots":{"listChanged":true}, "sampling":{}}, "clientInfo":{"name":"test-client","version":"1.0.0"}}}' | java -jar mcp-server-0.0.1-SNAPSHOT.jar
:::::::::{"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":"sds-mcp-server","version":"1.0.0"}}}
:
echo '{"jsonrpc":"2.0", "id":1, "method":"list/tools","params":{}}' | java -jar mcp-server-0.0.1-SNAPSHOT.jar
::::::::{"jsonrpc":"2.0","id":1,"error":{"code":-32601,"message":"Method not found: list/tools"}}
:
echo '{"jsonrpc":"2.0", "id":1, "method":"tools/list","params":{}}' | java -jar mcp-server-0.0.1-SNAPSHOT.jar
:::::::::
echo '{"jsonrpc":"2.0", "id":1, "method":"tools/resources","params":{}}' | java -jar mcp-server-0.0.1-SNAPSHOT.jar
::::::::{"jsonrpc":"2.0","id":1,"error":{"code":-32601,"message":"Method not found: tools/resources"}}
:
echo '{"jsonrpc":"2.0", "id":1, "method":"list/resources","params":{}}' | java -jar mcp-server-0.0.1-SNAPSHOT.jar
::::::::{"jsonrpc":"2.0","id":1,"error":{"code":-32601,"message":"Method not found: list/resources"}}
:
echo '{"jsonrpc":"2.0", "id":1, "method":"resources/list","params":{}}' | java -jar mcp-server-0.0.1-SNAPSHOT.jar
:::::::::

Environment
Windows 11
properties file
spring.application.name=mcp-server

spring.ai.mcp.server.type=SYNC
spring.ai.mcp.server.name=my-mcp-server
spring.ai.mcp.server.version=1.0.0

spring.ai.mcp.server.stdio=true
spring.main.web-application-type=none
spring.main.banner-mode=off
logging.pattern.console=:
logging.file.name=./log/mcp-server.log

Steps to reproduce
Build the MCP server with a few tools and a resource
Run JSON RPC commands from the command line

Expected behavior
Could be developer error here

Minimal Complete Reproducible example
Example above

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions