This PR adds links to the following two badges:
1. RubyGems badge: A link to the `mcp` gem will be added. The repository name is `ruby-sdk`,
following the modelcontextprotocol org's naming convention. Since the repository name and
the gem name are different, the link will help make it clear which gem it refers to.
2. MIT license badge: This will link to the MIT license file in the repository.
NOTE: Separately from this PR, the copyright notice in the MIT license should probably be addressed.
It currently says `Copyright (c) 2025 TODO: Write your name`, so the TODO should be resolved:
https://github.com/modelcontextprotocol/ruby-sdk/blob/v0.1.0/LICENSE.txt#L3
Other language SDKs seem to list `Anthropic, PBC` as the copyright holder,
though I would defer that decision to someone more knowledgeable.
This PR suppresses the following backtrace of `Interrupt` (Ctrl+c) exception for stdio server:
## Before
```console
$ ./examples/stdio_server.rb
^C/Users/koic/src/github.com/modelcontextprotocol/ruby-sdk/lib/mcp/server/transports/stdio_transport.rb:20:
in 'IO#gets': Interrupt
from /Users/koic/src/github.com/modelcontextprotocol/ruby-sdk/lib/mcp/server/transports/stdio_transport.rb:20:
in 'MCP::Server::Transports::StdioTransport#open'
from ./examples/stdio_server.rb:95:in '<main>'
$ echo $?
130
```
## After
```console
$ ./examples/stdio_server.rb
^C
Exiting...
$ echo $?
130
```
This change should prevent unexpected backtrace from appearing when running the example:
https://github.com/modelcontextprotocol/ruby-sdk?tab=readme-ov-file#stdio-transport
`MCP::Resource` doesn't have `text` attribute:
https://github.com/modelcontextprotocol/ruby-sdk/blob/v0.1.0/lib/mcp/resource.rb#L8-L13
I've replaced it with attributes that it actually supports.
Also, the use of `text: "Hello, world!"` in the example of `server.resources_read_handler` implementation resulted in
an unexpected response the first time I worked with `Resource`. While it may not be the best (but better),
in my experience using Resources with Cline, `text: params[:uri]` served as a clearer response when interacting with an LLM,
making it easier to understand.
Refactor capabilities handling into MCP::Server::Capabilities to improve
code organization and separation of concerns. This provides a cleaner API
for configuring server capabilities including prompts, resources, tools,
completions, logging, and experimental features.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Follow-up to #27.
This PR fixes the following build error:
```console
$ bundle exec rake
/Users/koic/.rbenv/versions/3.5-dev/lib/ruby/3.5.0+1/bundled_gems.rb:59:in 'Kernel.require': cannot load such file -- mcp/transports/stdio (LoadError)
Did you mean? mcp/transports/stdio_transport_test
from /Users/koic/.rbenv/versions/3.5-dev/lib/ruby/3.5.0+1/bundled_gems.rb:59:in 'block (2 levels) in Kernel#replace_require'
from /Users/koic/src/github.com/modelcontextprotocol/ruby-sdk/test/mcp/transports/stdio_transport_test.rb:4:in '<top (required)>'
from /Users/koic/.rbenv/versions/3.5-dev/lib/ruby/3.5.0+1/bundled_gems.rb:59:in 'Kernel.require'
from /Users/koic/.rbenv/versions/3.5-dev/lib/ruby/3.5.0+1/bundled_gems.rb:59:in 'block (2 levels) in Kernel#replace_require'
from /Users/koic/.rbenv/versions/3.5-dev/lib/ruby/gems/3.5.0+1/gems/rake-13.3.0/lib/rake/rake_test_loader.rb:21:in 'block in <main>'
from /Users/koic/.rbenv/versions/3.5-dev/lib/ruby/gems/3.5.0+1/gems/rake-13.3.0/lib/rake/rake_test_loader.rb:6:in 'Array#select'
from /Users/koic/.rbenv/versions/3.5-dev/lib/ruby/gems/3.5.0+1/gems/rake-13.3.0/lib/rake/rake_test_loader.rb:6:in '<main>'
rake aborted!
Command failed with status (1)
/Users/koic/.rbenv/versions/3.5-dev/bin/bundle:25:in 'Kernel#load'
/Users/koic/.rbenv/versions/3.5-dev/bin/bundle:25:in '<main>'
Tasks: TOP => default => test
(See full trace by running task with --trace)
```
https://github.com/modelcontextprotocol/ruby-sdk/actions/runs/15428236624/job/43420346011
The following is stated in #27.
> Breaking Changes
> `MCP::Transports::StdioTransport` is now `MCP::Server::Transports::StdioTransport`
What is shown here is the new name `MCP::Server::Transports::StdioTransport`, not `MCP::Server::Transports::Stdio`.
Therefore, the file path has been updated from `lib/mcp/server/transports/stdio.rb` to `lib/mcp/server/transports/stdio_transport.rb` to
match the module name. If `MCP::Server::Transports::Stdio` is preferred instead, please let me know and I will open a separate PR.
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.