Commit graph

381 commits

Author SHA1 Message Date
Koichi ITO
05c0119e53 Fix Resource::Embedded not setting @resource in initialize
The `initialize` method was missing the assignment of `@resource`,
causing the resource method to always return `nil` and `to_h` to return
an incorrect hash with an empty resource value.

Added comprehensive tests to verify the fix and prevent regression.
2026-01-26 11:37:33 +09:00
Koichi ITO
3addc525df
Merge pull request #218 from chattermill/add-tool-arguments-to-instrumentation
Add Tool Arguments to Instrumentation Data
2026-01-23 01:11:28 +09:00
Mikhail Dubov
7412197e52 feat: add tool_arguments to instrumentation data
Include the tool arguments in instrumentation callback data when
tools/call is invoked. This allows consumers to track which arguments
were passed to each tool call for analytics and debugging purposes.
2026-01-21 17:18:28 +00:00
Koichi ITO
830913be5a
Merge pull request #214 from koic/add_explicit_permissions_to_ci_workflow
Add explicit permissions to CI workflow
2026-01-21 02:12:47 +09:00
Koichi ITO
ade3d1fa80
Merge pull request #216 from koic/release_0_6_0 v0.6.0
Release 0.6.0
2026-01-16 15:31:38 +09:00
Koichi ITO
c4fd83debf Release 0.6.0
This would have been 0.5.1 release with only the fix from #212, but it has been released as 0.6.0
because it also includes the license change in #213.
2026-01-16 14:58:48 +09:00
Koichi ITO
7bef102224
Merge pull request #212 from koic/omit_icons_from_response_when_empty_or_nil
Omit `icons` from responses when empty or nil
2026-01-15 08:53:14 +09:00
Koichi ITO
27e5dc9c80
Merge pull request #213 from modelcontextprotocol/chore/apache-2.0-license
chore: update licensing to Apache 2.0 for new contributions
2026-01-14 01:04:45 +09:00
Adam Jones
685a4913d4
chore: update licensing to Apache 2.0 for new contributions 2026-01-12 22:49:19 +00:00
Koichi ITO
e484029d53 Add explicit permissions to CI workflow
Set minimal `contents: read` permission following the principle of least privilege.
This prevents using overly permissive repository defaults.
2026-01-13 03:06:05 +09:00
Koichi ITO
bd416c7a5f Omit icons from responses when empty or nil
Previously, the `icons` parameter was always included in responses (as an empty array)
even when not configured. This differs from the response representation in MCP Ruby SDK 0.4.0.

Since `icons` is optional, it should be omitted from responses when unused to reduce
unnecessary context window usage.
https://modelcontextprotocol.io/specification/2025-11-25/schema#implementation

This fix applies to `Tool#to_h`, `Prompt#to_h`, `Resource#to_h`, `ResourceTemplate#to_h`,
and `Server#server_info`.

It doesn't seem critical, but if there are no other issues, it would be good to cut 0.5.1 bugfix release soon.
2026-01-12 09:46:45 +09:00
Koichi ITO
fd1d7a61ec
Merge pull request #211 from koic/release_0_5_0 v0.5.0
Release 0.5.0
2026-01-11 12:27:34 +09:00
Koichi ITO
7a21bbd14b Release 0.5.0
Many new features and fixes have been added, and it seems like a good time to cut a release.
This release enables the following user feedback to be addressed:

* https://github.com/modelcontextprotocol/ruby-sdk/issues/99#issuecomment-3667416303
* https://github.com/modelcontextprotocol/ruby-sdk/pull/206#issuecomment-3717086100

For now, the features completed so far can be included in this release,
and subsequent feature proposals can continue to be incorporated into future releases.
2026-01-11 03:37:34 +09:00
Koichi ITO
6b18ca41be
Merge pull request #209 from koic/avoid_redos_in_ruby_3_1_and_earlier
Fix ReDoS vulnerability in `StringUtils#underscore`
2026-01-10 01:16:27 +09:00
Koichi ITO
248b4d2dad Fix ReDoS vulnerability in StringUtils#underscore
## Summary

Replace regex patterns with lookahead/lookbehind assertions to prevent
catastrophic backtracking on Ruby 3.1 and earlier.

This issue only affects Ruby 3.1 and earlier. Since it does not occur on Ruby 3.2+,
it is not an issue in the current stable release (0.4.0), which does not include #206.

## Regression Testing

Ensure the regex patterns complete within 1 second for a 50,000-character input
that would otherwise trigger superlinear backtracking.
2026-01-09 01:14:52 +09:00
Koichi ITO
b92dbe4c28
Merge pull request #207 from keisku/add-Accept-header-validation
Add Accept header validation
2026-01-08 02:49:19 +09:00
Keisuke Umegaki
ab8f53c5b7
Add Accept header validation
- Set Accept header to request JSON or SSE responses
- Validate response Content-Type and raise error for non-JSON responses
- Add Accept header to test fixtures
- Use explicit hash syntax for Ruby 2.7 compatibility
2026-01-07 14:55:19 +09:00
Koichi ITO
05fb98c3bb
Merge pull request #206 from koic/support_for_ruby_2_7_to_3_1
Support Ruby 2.7 - Ruby 3.1
2026-01-07 11:13:05 +09:00
Keisuke Umegaki
6f86acc161
fix dev style (#208) 2026-01-06 01:00:31 -05:00
Koichi ITO
aa8bbad491 Support Ruby 2.7 - Ruby 3.1
## Summary

Unlike applications, libraries provide value by remaining usable for a broad range of users,
even when that means supporting older Ruby versions beyond Ruby's own EOL timeline.

I maintain RuboCop, a Ruby linter. Because linters need to work across the ecosystem,
they often need to keep compatibility with older Ruby versions to some extent.

The trade-off is that the MCP Ruby SDK must remain compatible with Ruby 2.7.
However, given the ecosystem impact, supporting Ruby 2.7 is still worthwhile.

For example, bundled gems such as `csv` (Ruby >= 2.5), `bigdecimal` (Ruby >= 2.5), `json` (Ruby >= 2.7),
and `language_server-protocol` (Ruby >= 2.5) tend to keep compatibility with older Ruby versions.

Unlike dropping support, which imposes restrictions on users,
this change broadens compatibility and does not introduce breaking changes.

## Development Note

`rubocop-shopify` (2.18) supports Ruby 3.1+, and this PR does not change that.
Since RuboCop can configure the runtime Ruby version and the target Ruby version for analysis independently,
CI continues to run RuboCop on Ruby 4.0, while analyzing code with `TargetRubyVersion: 2.7`.

When setting `TargetRubyVersion: 2.7`, several RuboCop offenses were resolved.

Additionally, Sorbet-related libraries support Ruby 3.0+. Since these are not dependencies of the MCP Ruby SDK itself,
they are versioned and tested in the development Gemfile.
2026-01-06 10:38:56 +09:00
Koichi ITO
4968d9cffc
Merge pull request #204 from koic/make_tool_names_stricter
Make tool names stricter
2026-01-04 06:58:20 +09:00
Koichi ITO
ab4f0807d4
Merge pull request #205 from koic/add_icons
Support `icons` parameter
2026-01-03 01:46:43 +09:00
Koichi ITO
d1038c9f90
Merge pull request #203 from koic/remove_redundant_descriptions_in_agents_md
[Doc] Remove redundant descriptions in AGENTS.md
2026-01-02 01:18:00 +09:00
Koichi ITO
3bc1c2c407
Merge pull request #194 from koic/show_exception_messages_for_tool_call_error
Show exception messages for tool call errors
2026-01-01 07:09:15 +09:00
Koichi ITO
b29d522d27 Show exception messages for tool call errors
Claude Code sometimes only shows `Error: MCP error -32603: Internal error`
when an unexpected exception occurs during a tool call.

This change broadens the exception handling scope so the server can surface
the exception message more often, making failures easier to diagnose.
2025-12-31 19:38:14 +09:00
Koichi ITO
ca934456de
Merge pull request #189 from koic/update_specification_url_to_latest
[Docs] Update specification URL to `latest`
2025-12-31 08:11:20 +09:00
Koichi ITO
028c5f3291 Support icons parameter
This PR adds support for the optional `icons` parameter in prompt, resource,
resource template, and server info.

The specifications for `icons` are as follows.
https://modelcontextprotocol.io/specification/2025-11-25/schema#icon

Resolves https://github.com/modelcontextprotocol/ruby-sdk/issues/127.
2025-12-30 05:35:22 +09:00
Koichi ITO
84ff1fcba1 Make tool names stricter
Follow-up to https://github.com/modelcontextprotocol/ruby-sdk/pull/199#issuecomment-3659688807

Tool names are now validated to comply with the specification.
https://modelcontextprotocol.io/specification/2025-11-25/server/tools#tool-names

Since the tool name is optional, `nil` value is treated as "not specified" and is ignored without validation.
2025-12-29 01:19:39 +09:00
Koichi ITO
5aef96773e [Doc] Remove redundant descriptions in AGENTS.md
The "Component definition patterns" section has been removed because it overlaps with
"Three Ways to Define Components" in AGENTS.md:
d745ccde/AGENTS.md (key-patterns)

This helps make the system prompt more concise.
2025-12-28 16:24:58 +09:00
Koichi ITO
d745ccdedc
Merge pull request #202 from koic/ci_against_ruby_4_0
Add Ruby 4.0 to CI
2025-12-27 00:35:36 +09:00
Koichi ITO
3f4400f3b3 Add Ruby 4.0 to CI
Ruby 4.0.0 has been released, so this PR adds Ruby 4.0 to CI.
https://www.ruby-lang.org/en/news/2025/12/25/ruby-4-0-0-released/

To prevent the CI label from showing "CI / Test Ruby 4" instead of
"CI / Test Ruby 4.0", the matrix entries are changed from floats to strings.
2025-12-26 00:25:47 +09:00
Koichi ITO
614c016c8d
Merge pull request #192 from koic/add_missing_assertion
Add a missing assertion in `ConfigurationTest`
2025-12-25 00:33:12 +09:00
Koichi ITO
771163cc94
Merge pull request #188 from koic/add_website_url_to_server_info
Add support for the optional `websiteUrl` parameter in `serverInfo`
2025-12-24 00:49:35 +09:00
Koichi ITO
8d68fc0717
Merge pull request #199 from koic/fix_tool_name_colisions_across_namespaces
Raise an error when duplicate tool names are registered
2025-12-23 01:21:24 +09:00
Koichi ITO
149d977031
Merge pull request #187 from koic/fix_incorrect_example_in_readme
[Doc] Fix incorrect examples in README.md
2025-12-22 00:59:04 +09:00
Koichi ITO
dee80d20ae Raise an error when duplicate tool names are registered
This raises an exception when duplicate tool names are registered,
instead of silently overwriting tools. Tool names are required to be
unique within a server, so this behavior aligns with the MCP specification.

> Tool names SHOULD be unique within a server.

https://modelcontextprotocol.io/specification/2025-11-25/server/tools#tool-names

Validation for tool names could be made more strictly spec-compliant in a separate effort.

Fixes #197
2025-12-21 22:48:43 +09:00
Koichi ITO
62615d65e4 Add support for the optional websiteUrl parameter in serverInfo
This PR adds support for the optional `websiteUrl` parameter in `serverInfo`.
This parameter has been supported since the 2025-11-25 MCP specification.

This PR also implements part of https://github.com/modelcontextprotocol/ruby-sdk/issues/127.
2025-12-21 22:44:36 +09:00
Koichi ITO
171baa876e
Merge pull request #201 from koic/add_description_to_server_info
Add support for the optional `description` parameter in `serverInfo`
2025-12-21 00:42:35 +09:00
Koichi ITO
851974e454 Add support for the optional description parameter in serverInfo
This PR adds support for the optional `description` parameter in `serverInfo`.
This parameter has been supported since the 2025-11-25 MCP specification.
https://modelcontextprotocol.io/specification/2025-11-25/schema#implementation
2025-12-20 19:12:45 +09:00
Koichi ITO
7b3ff946ac
Merge pull request #184 from koic/support_2025_11_25_specification
Allow stable protocol specification version "2025-11-25"
2025-12-20 19:04:36 +09:00
Koichi ITO
67e03d7b3d Allow stable protocol specification version "2025-11-25"
The MCP specification dated 2025-11-25 has been released:

- https://modelcontextprotocol.io/specification/2025-11-25
- https://blog.modelcontextprotocol.io/posts/2025-11-25-first-mcp-anniversary

This PR allows `'2025-11-25'` to be specified for the `:protocol_version` keyword argument
in `MCP::Configuration.new`.
2025-12-20 18:58:28 +09:00
Koichi ITO
baeb75c8d8
Merge pull request #190 from koic/avoid_draft_protocol_version
Default to the latest stable protocol version
2025-12-20 18:55:18 +09:00
Koichi ITO
4eab486d56
Merge pull request #198 from ebeigarts/feature/schema-additional-properties
Refactor schema validation to reduce duplication and add additionalProperties support
2025-12-16 10:32:42 +09:00
Koichi ITO
0b70ef3d6a
Merge pull request #200 from koic/remove_redundant_string_dup
Remove redundant `String#dup`
2025-12-15 07:54:59 +09:00
Koichi ITO
0429284d5d Remove redundant String#dup
Since no destructive methods are being called, `dup` isn’t necessary.
2025-12-14 14:32:10 +09:00
Edgars Beigarts
a3c24d2bcc
Refactor schema validation to reduce duplication and add additionalProperties support
This refactoring extracts common schema validation logic into a base Schema
class, eliminating ~100 lines of duplicate code between InputSchema and
OutputSchema. It also adds support for the JSON Schema `additionalProperties`
keyword to allow fine-grained control over extra properties in tool arguments.

Previously `additionalParameters` could be set only on OutputSchema.

Key changes:

- Created MCP::Tool::Schema base class consolidating:
  - Schema validation against JSON Schema Draft 4 metaschema
  - Deep key transformation (string to symbol conversion)
  - $ref disallowance checking
  - Common validation methods

- Refactored InputSchema to inherit from Schema:
  - Simplified constructor to accept full schema hash
  - Changed required fields storage from symbols to strings
  - Removed ~40 lines of duplicated validation logic

- Refactored OutputSchema to inherit from Schema:
  - Removed ~54 lines of duplicated validation logic
  - Now shares all common functionality with InputSchema

- Updated Tool.input_schema setter:
  - Simplified to pass full hash directly to InputSchema

- Added additionalProperties support:
  - By default, tools now allow additional properties (JSON Schema default)
  - Can explicitly set `additionalProperties: false` to disallow extras
  - Added comprehensive test coverage for both behaviors
2025-12-12 12:49:52 +02:00
Koichi ITO
85b81a6a65
Merge pull request #196 from guillaumebriday/patch-1
[Docs] Rename APITool to WeatherTool and add error handling
2025-12-10 12:16:56 +09:00
Guillaume Briday
2b205581ea
Rename APITool to WeatherTool and add error handling
Updated the APITool class to WeatherTool and modified method parameters. Added section on tool responses with errors.
2025-12-09 20:09:42 +01:00
Koichi ITO
47c70ef8e7
Merge pull request #195 from modelcontextprotocol/dependabot/github_actions/actions/checkout-6
Bump actions/checkout from 5 to 6
2025-12-09 08:05:19 +09:00
dependabot[bot]
8df42c37b3
Bump actions/checkout from 5 to 6
Bumps [actions/checkout](https://github.com/actions/checkout) from 5 to 6.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-12-08 20:27:39 +00:00