Commit graph

80 commits

Author SHA1 Message Date
Koichi ITO
ced9481194 [Doc] Fix a typo 2025-06-05 11:19:31 +09:00
Ateş Göral
a601558a21
Merge pull request #40 from koic/fix_build_error
Fix build error
2025-06-03 22:58:13 -04:00
Koichi ITO
70680fce88 Fix build error
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.
2025-06-04 11:48:25 +09:00
Topher Bullock
e901f94a3d
Merge pull request #37 from koic/tweak_stdio_transport_example_code_in_the_readme
[Doc] Tweak stdio transport example code in the README
2025-06-03 17:28:53 -04:00
Topher Bullock
dcc31ca6fd
Merge pull request #27 from jcat4/refactor-for-client-support
Refactor in preparation for client support
2025-06-03 17:27:54 -04:00
Koichi ITO
6de5468c8b [Doc] Tweak stdio transport example code in the README
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.
2025-06-03 23:41:13 +09:00
Ateş Göral
08abc3e17b
Merge pull request #36 from koic/remove_unused_config_from_dot_rubocop
Remove unused config from .rubocop.yml
2025-06-01 13:23:20 -04:00
Koichi ITO
4db222f659 Remove unused config from .rubocop.yml
Follow-up to #24.

lib/mcp-ruby.rb was removed in https://github.com/modelcontextprotocol/ruby-sdk/pull/24.
2025-06-02 01:44:42 +09:00
Ateş Göral
8d88156d71
Merge pull request #34 from koic/make_some_optional_kwargs_in_resource
Make `description` and `mime_type` optional keyword arguments in `Resource`
2025-05-31 13:34:25 -04:00
Ateş Göral
0f3384e5aa
Merge pull request #35 from koic/rename_directory_from_model_context_protocol_to_mcp
Rename test directory from `model_context_protocol` to `mcp`
2025-05-31 13:33:18 -04:00
Koichi ITO
f33fe309b4 Rename test directory from model_context_protocol to mcp
Follow-up to #24.

The directory structure of the product code and test code is expected to match.
2025-06-01 02:13:28 +09:00
Joey Cardosi
0fbd229ae3
sort imports 2025-05-30 20:01:31 -04:00
Joey Cardosi
5cc3d9d526
stop using shared dir 2025-05-30 14:33:22 -04:00
Topher Bullock
7ad1e904eb
Merge pull request #32 from modelcontextprotocol/release-0.1.0 v0.1.0
Release 0.1.0
2025-05-30 14:19:47 -04:00
Topher Bullock
542e3766f3 release 0.1.0 2025-05-30 13:53:16 -04:00
Topher Bullock
e98b5f12c1
Merge pull request #31 from modelcontextprotocol/add-release-workflow
add release workflow for publishing to RubyGems
2025-05-30 13:30:43 -04:00
Koichi ITO
eb1c93909b Make description and mime_type optional keyword arguments in Resource
This change is related to #29.

According to the specification, both `description` and `mimeType` of Resource are optional:
https://modelcontextprotocol.io/specification/2025-03-26/server/resources#resource

Therefore, it makes sense to treat them as optional keyword arguments,
similar to how this is done in `ResourceTemplate`:
https://github.com/modelcontextprotocol/ruby-sdk/blob/0b49c3/lib/mcp/resource_template.rb#L8

As additional context, the TypeScript SDK also treats them as optional.
https://github.com/modelcontextprotocol/typescript-sdk/blob/1.12.1/src/types.ts#L438-L466
2025-05-31 01:24:23 +09:00
Joey Cardosi
3c8ff5a547
fix + cleanup stdio 2025-05-30 12:17:09 -04:00
Joey Cardosi
d80b13736e
just redo all of it from scratch 2025-05-30 12:15:11 -04:00
Topher Bullock
5db96f0b5c document release process 2025-05-30 11:42:50 -04:00
Topher Bullock
2dd9e96b98 add release workflow for publishing to RubyGems 2025-05-30 08:59:52 -04:00
Ateş Göral
0b49c3f711
Merge pull request #26 from koic/suppress_rubocop_info
Enable RuboCop Minitest and RuboCop Rake for development
2025-05-30 00:27:06 -04:00
Ateş Göral
a32b7d2499
Merge pull request #25 from koic/enable_rubocop_on_ci
Enable RuboCop on CI
2025-05-30 00:25:03 -04:00
Ateş Göral
8db094d300
Merge pull request #29 from koic/suppress_redundant_attributes_in_resources
Suppress redundant attributes in Resources
2025-05-30 00:22:24 -04:00
Ateş Göral
5ae86796c9
Merge pull request #30 from koic/fix_an_error_when_using_bin_console]
Fix an error when using `bin/console`
2025-05-30 00:21:40 -04:00
Koichi ITO
9a7b4a8465 Fix an error when using bin/console
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>'
```
2025-05-30 11:26:35 +09:00
Koichi ITO
2f354a872a Suppress redundant attributes in Resources
According to the specification, the following attributes are optional,
so using `compact` ensures consistency.

- `description`: Optional description
- `mimeType`: Optional MIME type
- `size`: Optional size in bytes

https://modelcontextprotocol.io/specification/2025-03-26/server/resources#resource
2025-05-30 10:41:18 +09:00
Topher Bullock
91219d30b7
Merge pull request #24 from modelcontextprotocol/update-gemspec
Update gemspec to reflect `mcp` naming
2025-05-29 17:45:45 -04:00
Topher Bullock
bf07d4a02c update README and cursor rule 2025-05-29 17:11:45 -04:00
Topher Bullock
9d2447b351 rename lib/{model_context_protocol => mcp} 2025-05-29 17:11:40 -04:00
Topher Bullock
a09f4786b4 update entrypoint 2025-05-29 17:11:33 -04:00
Topher Bullock
d48de195f6 update gemspec 2025-05-29 17:11:30 -04:00
Koichi ITO
a169bbd2ba Enable RuboCop Minitest and RuboCop Rake for development
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`.
2025-05-28 11:19:32 +09:00
Koichi ITO
3477406afe Enable RuboCop on CI
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.
2025-05-28 01:32:23 +09:00
Ateş Göral
6b49222edb
Merge pull request #22 from koic/fix_incorrect_capabilities_handling_for_completion_complete
Fix incorrect capabilities handling for `completion/complete`
2025-05-26 20:01:57 -04:00
Ateş Göral
1ba438feec
Merge pull request #21 from koic/remove_duplicate_require_relative
Remove redundant `require_relative`
2025-05-26 20:01:21 -04:00
Ateş Göral
34fa53c305
Merge pull request #10 from chrisbutcher/fix-sorbet-runtime-compatibility
Support Sorbet typed tools
2025-05-26 20:01:05 -04:00
Koichi ITO
d3dcde2460 Fix incorrect capabilities handling for completion/complete
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.
2025-05-26 17:37:13 +09:00
Koichi ITO
2a9926b51b Remove redundant require_relative
This PR removes a redundant require statement that is already present in the `server.rb`:
89ef9d8/lib/model_context_protocol/server.rb (L5)
2025-05-24 16:06:26 +09:00
Ateş Göral
89ef9d89e5
Merge pull request #18 from koic/remove_dot_ruby_version
Remove .ruby-version for development
2025-05-24 00:39:23 -04:00
Ateş Göral
6435de2f39
Merge pull request #17 from koic/fix_syntax_error_in_examples_of_the_readme
[Doc] Fix invalid syntax in README examples
2025-05-24 00:38:37 -04:00
Ateş Göral
a202b62b1f
Merge pull request #19 from koic/remove_unused_constant
Remove unused constant
2025-05-24 00:36:51 -04:00
Ateş Göral
097f979a30
Merge pull request #20 from koic/fix_a_typo
Fix a typo
2025-05-24 00:35:59 -04:00
Koichi ITO
8f64324f6c Fix a typo
The method that overrides `Methods::RESOURCES_READ` is named `resources_read_handler`,
not `read_resource_handler`:
18f3e87/lib/model_context_protocol/server.rb (L97-L99)
2025-05-24 01:02:04 +09:00
Koichi ITO
9bcb3bf15b Remove unused constant
This PR removes an unused constant that is not referenced anywhere
and was likely left over during development.
2025-05-24 00:53:05 +09:00
Koichi ITO
92ef9e4b63 Remove .ruby-version for development
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.
2025-05-23 15:44:17 +09:00
Koichi ITO
e526009b52 [Doc] Fix invalid syntax in README examples
This PR corrects invalid syntax in the README examples.
Additionally, all lambda blocks using `->` have been consistently
formatted with `{}`.
2025-05-23 15:39:59 +09:00
Topher Bullock
18f3e8761e
Merge pull request #8 from kfischer-okarin/auto-determine-capabilities
Auto determine capabilities
2025-05-21 14:23:11 -04:00
Topher Bullock
049bac648d
Merge pull request #16 from koic/use_require_relative
Use `require_relative`
2025-05-21 14:22:44 -04:00
Topher Bullock
4b84f93375
Merge pull request #15 from koic/remove_useless_mcp_json_rpc_module
Remove useless `ModelContextProtocol::JsonRPC` module
2025-05-21 14:13:10 -04:00