Skip to content

Conversation

@koic
Copy link
Member

@koic koic commented Jun 3, 2025

Motivation and Context

The example code is located at ./examples/stdio_server.rb. Also, the content provided as input via stdio has been updated to avoid returning an error data. Using ping pong as an example, here's the difference:

Before

An error data is returned.

$ ./examples/stdio_server.rb
{"jsonrpc":"2.0","id":"1","result":"pong"}
{"jsonrpc":"2.0","id":null,"error":{"code":-32600,"message":"Invalid Request","data":"Method name must be a string and not start with \"rpc.\""}}

This error message is generated in the following location:
https://github.com/Shopify/json-rpc-handler/blob/v0.1.1/lib/json_rpc_handler.rb#L70

After

The expected result is returned without error data.

$ ./examples/stdio_server.rb
{"jsonrpc":"2.0","id":"1","method":"ping"}
{"jsonrpc":"2.0","id":"1","result":{}}

The other stdin example has been updated to use data that does not cause errors.
With this document update, users can verify the behavior of the MCP server via stdin without using an MCP client.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

The example code is located at `./examples/stdio_server.rb`.
Also, the content provided as input via stdio has been updated to avoid returning an error data.
Using ping pong as an example, here's the difference:

## Before

An error data is returned.

```console
$ ./examples/stdio_server.rb
{"jsonrpc":"2.0","id":"1","result":"pong"}
{"jsonrpc":"2.0","id":null,"error":{"code":-32600,"message":"Invalid Request","data":"Method name must be a string and not start with \"rpc.\""}}
```

This error message is generated in the following location:
https://github.com/Shopify/json-rpc-handler/blob/v0.1.1/lib/json_rpc_handler.rb#L70

## After

The expected result is returned without error data.

```console
$ ./examples/stdio_server.rb
{"jsonrpc":"2.0","id":"1","method":"ping"}
{"jsonrpc":"2.0","id":"1","result":{}}
```

The other stdin example has been updated to use data that does not cause errors.

With this document update, users can verify the behavior of the MCP server via stdin without using an MCP client.
@koic koic force-pushed the tweak_stdio_transport_example_code_in_the_readme branch from 31b9c68 to 6de5468 Compare June 3, 2025 14:41
@topherbullock topherbullock merged commit e901f94 into modelcontextprotocol:main Jun 3, 2025
5 checks passed
@koic koic deleted the tweak_stdio_transport_example_code_in_the_readme branch June 3, 2025 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants