Commit graph

255 commits

Author SHA1 Message Date
Koichi ITO
cb5e87581b Add validation to MCP::Configuration setters
I noticed through the existing tests that `MCP::Configuration#protocol_version=`
allows setting an arbitrary protocol version.

Since the official MCP Ruby SDK is an implementation of the MCP specification,
it should not support arbitrary protocol versions. This change adds validation
to the setter, consistent with `Configuration#initialize`.

The same validation has also been added to `MCP::Configuration#validate_tool_call_arguments=`.
2025-09-24 19:19:02 +09:00
Koichi ITO
e168292876
Merge pull request #139 from koic/remove_useless_block_argument
Remove unused block parameters
2025-09-21 13:09:20 +09:00
Koichi ITO
0c8937de34 Remove unused block parameters
There are some unused block variables. This change removes block parameters
that consist solely of unused block parameters.
Where `Hash#values` suffices instead of ignoring unused variables,
replace such code with `Hash#values`.
2025-09-20 14:45:08 +09:00
Koichi ITO
a17b23e1a4
Merge pull request #138 from koic/enable_dependabot
Enable Dependabot
2025-09-18 09:37:12 +09:00
Koichi ITO
30d2b0b22b Enable Dependabot
Configure Dependabot to automatically detect updates to the actions used in
GitHub Actions (e.g., `actions/checkout`) and create pull requests for them.

Based on experience, checking for updates on a weekly interval should work well.
2025-09-17 00:26:25 +09:00
Koichi ITO
d67609d43d
Merge pull request #137 from koic/remove_useless_magic_comment
Remove useless magic comment
2025-09-16 02:35:22 +09:00
Koichi ITO
b626425521 Remove useless magic comment
This PR removes useless magic comment.
2025-09-15 12:33:09 +09:00
Ateş Göral
70384c8362
Merge pull request #135 from modelcontextprotocol/ag/v0.3.0 v0.3.0
Release v0.3.0
2025-09-14 10:20:39 -04:00
Ates Goral
deebefd26f Release v0.3.0
🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-14 01:09:18 -04:00
Koichi ITO
bdd69956d5
Merge pull request #133 from codenamev/main
Add Tool output_schema support with comprehensive validation
2025-09-14 09:08:14 +09:00
Ateş Göral
cd4681351d
Merge branch 'main' into main 2025-09-13 17:11:23 -04:00
Ateş Göral
5c5f420f42
Merge pull request #122 from koic/add_validation_for_tool_annotation
Validate tool annotations value
2025-09-13 14:22:42 -04:00
Koichi ITO
dc28d696ec
Merge pull request #128 from koic/tweak_the_doc_of_transport_support_in_the_readme
[Docs] Tweak the doc of Transport Support in the README.md
2025-09-12 01:32:23 +09:00
Valentino Stoll
aad8e94530
Add Tool output_schema support with comprehensive validation
This commit implements optional JSON Schema validation for tool outputs according to the MCP specification:

- Add MCP::Tool::OutputSchema class mirroring InputSchema functionality
- Support output_schema in class definitions, Tool.define, and OutputSchema objects
- Include validate_result method for runtime validation
- Update MCP::Client::Tool to track output schemas
- Add comprehensive test coverage with 249 passing tests
- Update README with dedicated Tool Output Schemas section
- Follow MCP spec requirements for server/client validation
2025-09-11 11:12:27 -04:00
Koichi ITO
08048283e4 Validate tool annotations value
Tool annotations were introduced in the "2025-03-26" specification:

> Added comprehensive tool annotations for better describing tool behavior,
> like whether it is read-only or destructive (PR modelcontextprotocol/modelcontextprotocol#185)

https://modelcontextprotocol.io/specification/2025-03-26/changelog#major-changes

This means they are not supported in the "2024-11-05" specification,
so validation errors will be raised for `protocol_version: "2024-11-05"`.
2025-09-11 10:48:56 +09:00
Koichi ITO
3f2a4b3b21
Merge pull request #125 from koic/reduce_stdout_headge_in_example
Reduce stdout hedge in examples
2025-09-11 10:31:01 +09:00
Koichi ITO
dd5b318b11
Merge pull request #126 from koic/fix_errors_when_title_is_not_specified
Fix errors when `title` is not specified
2025-09-11 10:30:15 +09:00
Koichi ITO
0ab27063e7
Merge pull request #129 from koic/add_example_of_define_tool_and_define_protocol_to_read
[Doc] Add example of `define_tool` and `define_protocol`
2025-09-10 09:27:03 +09:00
Koichi ITO
97640ed626
Merge pull request #28 from jcat4/add-basic-http-client-support
Add basic http client support
2025-09-09 18:51:07 +09:00
Joey Cardosi
8b764428b1
Add basic HTTP client support with pluggable transports 2025-09-08 15:52:37 -05:00
Koichi ITO
eab21be94f
Merge pull request #130 from koic/reduce_any_p
Combine redundant `any?` calls
2025-09-08 07:37:50 +09:00
Koichi ITO
b9f1c58899 Combine redundant any? calls
Calling `parameters.any?` twice is redundant.
2025-09-07 10:04:18 +09:00
Koichi ITO
e5bb17eafb [Doc] Add example of define_tool and define_protocol
This PR adds example of `define_tool` and `define_protocol`.
2025-09-06 10:58:24 +09:00
Koichi ITO
cc16639cc8 [Docs] Tweak the doc of Transport Support in the README.md
Follow-up to #33.

The order of appearance of Stdio and Streamable HTTP follows the specification:
https://modelcontextprotocol.io/specification/2025-06-18/basic/transports
2025-09-04 11:22:43 +09:00
Koichi ITO
47d29e8014 Fix errors when title is not specified
Since the optional `title` becomes `title: null` when not provided, the following error occurs.
This occurs with Claude Code 1.0.100.

```console
[DEBUG] MCP server "example": Connection failed after 1591ms: [
  {
    "code": "invalid_type",
    "expected": "string",
    "received": "null",
    "path": [
      "serverInfo",
      "title"
    ],
    "message": "Expected string, received null"
  }
]
```

By adding `compact`, the `title` key will be removed if the optional `title` keyword argument is not specified.
2025-09-03 12:31:33 +09:00
Koichi ITO
03e35c73c3 Reduce stdout hedge in examples
This PR reduces redundant stdout in examples by replacing
multiple `puts` with a heredoc and by removing unnecessary `puts`.
2025-09-02 11:30:31 +09:00
Koichi ITO
eb0d9c0e6d
Merge pull request #121 from koic/document_mcp_resource_template
[Docs] Document `MCP::ResourceTemplate`
2025-08-31 17:49:42 +09:00
Koichi ITO
02b546dcda [Docs] Document MCP::ResourceTemplate
This PR documents `MCP::ResourceTemplate`.

Resolves #88.
2025-08-31 00:20:53 +09:00
Koichi ITO
b982074daa
Merge pull request #119 from koic/add_title_to_server_info
Add `title` to `serverInfo`
2025-08-30 02:01:53 +09:00
Koichi ITO
da471a21b6
Merge pull request #118 from koic/add_default_value_to_tool_annotation
Set default values for `ToolAnnotations` hints
2025-08-29 16:21:31 +09:00
Koichi ITO
e51c692e93
Merge pull request #120 from koic/add_tools_call_example_in_readme
[Docs] Add a `tools/call` example in README
2025-08-29 14:47:11 +09:00
Koichi ITO
ef56280518 Add title to serverInfo
Follow-up to #109.

`title` has also been added to `serverInfo` and `clientInfo` by
https://github.com/modelcontextprotocol/modelcontextprotocol/pull/663.

Since `clientInfo` is not treated as product code, support is implemented only in `serverInfo`.

See also https://modelcontextprotocol.io/specification/2025-06-18/schema#implementation.
2025-08-29 14:36:39 +09:00
Koichi ITO
da4fd6410e [Docs] Add a tools/call example in README
This PR adds a `tools/call` example to make it clear how to call a tool from
the tool list obtained via `tools/list`.

Closes #110.
2025-08-29 13:46:33 +09:00
Koichi ITO
cae30547d2 Set default values for ToolAnnotations hints
According to the specification, `destructive_hint`, `idempotent_hint`, `open_world_hint`,
and `read_only_hint` of `ToolAnnotations` are optional with default values:
https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations

This PR sets their default values in accordance with the specification.

Additionally, for readability, the hints have been reordered to follow the specification.
2025-08-28 01:13:57 +09:00
Koichi ITO
9486c63545
Merge pull request #117 from koic/extract_tool_annotations_tests
Extract `MCP::Tool::Annotations` unit tests
2025-08-27 14:57:48 +09:00
Koichi ITO
092aebf1a4 Extract MCP::Tool::Annotations unit tests
The tests related to `MCP::Tool::Annotations` will be extracted from the `MCP::ToolTest` test class
into a dedicated `MCP::Tool::AnnotationsTest` unit test class as a testing pair.

This improves test clarity, file level test independence, and file level execution speed.
It also ensures consistent placement as a testing pair under `MCP::Tool::*`:

```console
$ ls lib/mcp/tool/
annotations.rb  input_schema.rb  response.rb
$ ls test/mcp/tool/
annotations_test.rb  input_schema_test.rb  response_test.rb
```
2025-08-27 13:33:21 +09:00
Koichi ITO
aec8fb8b00
Merge pull request #116 from koic/tweak_assert_equal_argument_order_in_tests
Tweak `assert_equal` argument order in tests
2025-08-27 11:07:00 +09:00
Koichi ITO
ae5a41588e Tweak assert_equal argument order in tests
The argument order for `assert_equal` is expected, actual:
https://github.com/minitest/minitest/blob/v5.25.5/lib/minitest/assertions.rb#L214

This PR corrects the arguments that were reversed to the expected order.
It also enables `Minitest/LiteralAsActualArgument`, which can detect and
autocorrect some of these cases:
https://docs.rubocop.org/rubocop-minitest/0.38/cops_minitest.html#minitestliteralasactualargument
2025-08-27 01:43:55 +09:00
Koichi ITO
022b3ff640
Merge pull request #84 from planio-gmbh/fix/implement-notifications-initialized
implements the notifications/initialized method
2025-08-26 05:54:07 +09:00
Koichi ITO
f4228612a8
Merge pull request #115 from koic/tweak_list_of_instrumentation_in_the_readme
[Docs] Fix broken list rendering of Instrumentation in the README
2025-08-25 15:25:29 +09:00
Jens Kraemer
be5e7db2a6 implements the notifications/initialized method
- According to
  https://modelcontextprotocol.io/specification/2025-06-18/basic/lifecycle,
  "After successful initialization, the client MUST send an initialized
  notification to indicate it is ready to begin normal operations".
2025-08-25 13:44:21 +08:00
Koichi ITO
e3e67aac08 [Docs] Fix broken list rendering of Instrumentation in the README
This PR fixes the broken rendering of the following list:
https://github.com/modelcontextprotocol/ruby-sdk/tree/v0.2.0?tab=readme-ov-file#instrumentation
2025-08-25 10:45:22 +09:00
Koichi ITO
541bbe0859
Merge pull request #113 from koic/document_title_as_draft_and_restore_annotations_title
Document `title` as Draft and restore `annotations.title`
2025-08-24 01:23:19 +09:00
Koichi ITO
b4da129aa0 Document title as Draft and restore annotations.title
Follow-up to #109.

The introduction of `title` in #109 is still a draft and is not supported in the latest specification, `Version 2025-06-18 (latest)`.

In this PR, the README.md will be updated to mention this point and restore the references to the removed `annotations.title`.

This aims to inform users that, as of `Version 2025-06-18 (latest)`, the use of `annotations.title` is considered stable.

Additionally, separate validation for these parameters could be added.

Please refer to the following comment regarding `annotations.title` and `title`:
https://github.com/modelcontextprotocol/modelcontextprotocol/pull/663#issuecomment-2963519737
2025-08-23 00:12:12 +09:00
Topher Bullock
06bf90dd98
Merge pull request #97 from honzasterba/rubymine_test_runner_support
[test] minites-reporters do not work with RubyMine
2025-08-20 16:25:13 -04:00
Topher Bullock
62360338f4
Merge pull request #109 from jdnvn/main
Add title to tools, prompts and resources
2025-08-20 16:19:38 -04:00
Koichi ITO
002df2c774
Merge pull request #107 from pusewicz/response-keyword-boolean
Response error keyword argument
2025-08-20 18:26:17 +09:00
Jan Sterba
1895168115 [test] remove minitest-reporters
gem not compatible with rubymine test runner
2025-08-20 11:17:20 +02:00
Koichi ITO
f63f360a7b
Merge pull request #108 from koic/remove_redundant_parentheses
[Docs] Remove redundant parentheses
2025-08-19 00:25:56 +09:00
Piotr Usewicz
6689db2ca0
Nicer error API
Both the combination of positional argument and naming does not feel
like Ruby.

This change makes `is_error` argument a keyword argument called `error`.

Thanks to this, the usage is more self-explanatory:

```ruby
response = Response.new([], error: true)
```
2025-08-18 16:50:20 +02:00