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.
Follow-up to #24.
This PR fixes the following error when using `bin/console`:
```console
$ bin/console
/Users/koic/.rbenv/versions/3.4.4/lib/ruby/3.4.0/bundled_gems.rb:82:
in 'Kernel.require': cannot load such file -- model_context_protocol (LoadError)
from /Users/koic/.rbenv/versions/3.4.4/lib/ruby/3.4.0/bundled_gems.rb:82:
in 'block (2 levels) in Kernel#replace_require'
from bin/console:5:in '<main>'
```
Based on the following information, `rubocop-minitest` and `rubocop-rake` have been added
for development. Autocorrection has been applied for offenses detected by `rubocop-minitest`.
```console
$ bundle exec rake
(snip)
Running RuboCop...
Inspecting 40 files
........................................
40 files inspected, no offenses detected
Tip: Based on detected gems, the following RuboCop extension libraries might be helpful:
* rubocop-minitest (https://rubygems.org/gems/rubocop-minitest)
* rubocop-rake (https://rubygems.org/gems/rubocop-rake)
You can opt out of this message by adding the following to your config
(see https://docs.rubocop.org/rubocop/extensions.html#extension-suggestions for more options):
AllCops:
SuggestExtensions: false
```
If preserving the existing behavior is preferred, it is also possible to set `SuggestExtensions: false`.
When running `bundle exec rake` in the local environment, RuboCop is executed,
but it was not included in the CI workflow.
This PR enables RuboCop execution in the CI workflow. RuboCop performs static analysis
on the source code using Ruby 3.2, in accordance with the gemspec setting `spec.required_ruby_version = ">= 3.2.0"`:
6b49222edb/model_context_protocol.gemspec (L16)
In other words, it is not necessary to run RuboCop under every Ruby version from 3.2 to head,
so it is defined as a separate job from the test job.
This PR fixes incorrect capabilities handling for `completion/complete`.
As specified, the capability of `completion/complete` is `completions`, not `prompts`:
https://modelcontextprotocol.io/specification/2025-03-26/server/utilities/completion#capabilities
Note that in the Ruby SDK, `completion/complete`, like `logging/setLevel`, is not yet implemented.
Therefore, an empty implementation has been added to server.rb.
RubyGems may be used across a wide range of Ruby versions,
from the minimum supported version to development versions.
To allow local development with any Ruby version,
the Ruby version is not locked using a `.ruby-version` file.
This enables developers to work with their preferred Ruby version and
frees repository maintainers from the need to update `.ruby-version`.
Additionally, because testing against supported Ruby versions is performed
in CI before release, the version in `.ruby-version` is not important.
If there are many searches in the `$LOAD_PATH` in the user environment,
require will perform unnecessary searches that are not needed.
In contrast, `require_relative` is efficient because it uses a relative path.
JSON-RPC is handled by https://github.com/Shopify/json-rpc-handler,
so `ModelContextProtocol::JsonRPC` module seems to have been
unintentionally left behind in the following commit:
c5591be
The files under `model_context_protocol/json_rpc/*.rb` have already been removed.