Commit graph

362 commits

Author SHA1 Message Date
Keisuke Umegaki
6f86acc161
fix dev style (#208) 2026-01-06 01:00:31 -05: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
Koichi ITO
7ca4bf85ad
Merge pull request #193 from devonboyer/fix-symlink-path-comparison-in-schema-validation
Fix symlink path comparison in schema validation
2025-12-06 10:06:48 +09:00
Devon Boyer
b34fae93f0 Fix symlink path comparison in schema validation 2025-12-04 22:39:23 -05:00
Koichi ITO
acf4d6025c Add a missing assertion in ConfigurationTest
This PR adds a missing assertion in `ConfigurationTest`.
2025-12-05 08:49:18 +09:00
Koichi ITO
c786a14f61 Default to the latest stable protocol version
When starting an MCP server in Claude Code with `protocol_version` set to `DRAFT-2025-v3`,
it fails with the following error:

```console
2025-12-04T02:58:01.548Z [DEBUG] MCP server "example": Connection failed after 2093ms: Server's protocol version is not supported: DRAFT-2025-v3
2025-12-04T02:58:01.548Z [ERROR] MCP server "example" Connection failed: Server's protocol version is not supported: DRAFT-2025-v3
```

This PR changes the default behavior so that if `protocol_version` is not specified,
it uses the latest stable protocol version instead of the draft version.

This PR also updates the README to note that the latest stable protocol version includes
new features from the draft version.
2025-12-04 14:58:41 +09:00
Koichi ITO
117bb426e5 [Docs] Update specification URL to latest
This PR updates the specification URL to `latest`.
This change avoids the need to update the URL whenever a new protocol version is released.
The `latest` path redirects to the latest protocol version.
2025-11-30 17:42:27 +09:00
Koichi ITO
dacd5f1741 [Doc] Fix incorrect examples in README.md
This PR fixes incorrect examples in README.md. The block variable could be removed if it is unused,
but when presenting an example `:server_context` should still be shown as a keyword argument.

Fixes #185.
2025-11-28 12:29:06 +09:00
Koichi ITO
00392b660d
Merge pull request #181 from jonathanhefner/generate-api-docs
Add API documentation with GitHub Pages deployment
2025-11-27 12:54:46 +09:00
Koichi ITO
6bb96dd891
Merge pull request #183 from modelcontextprotocol/dependabot/github_actions/actions/checkout-6
Bump actions/checkout from 5 to 6
2025-11-26 00:45:37 +09:00
dependabot[bot]
fecf33588c
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-11-24 20:51:26 +00:00
Koichi ITO
d31c3da8f2
Merge pull request #178 from koic/add_elicitation_skeleton
Add Elicitation skeleton
2025-11-25 01:02:30 +09:00
Koichi ITO
14ef006cd3
Merge pull request #182 from koic/update_agents_md
Update AGENTS.md
2025-11-24 03:49:49 +09:00
Koichi ITO
056b0a61b4 Update AGENTS.md
Follow-up to #175.

Since `json_rpc_handler` was merged in #175, it has been removed from AGENTS.md.

The "Dependencies" section was also removed because the information there would have become redundant.
2025-11-23 02:48:03 +09:00
Jonathan Hefner
281c334075 Add API documentation with GitHub Pages deployment
This adds automated deployment of a versioned API documentation landing
page using GitHub Pages. The landing page links to documentation hosted
on RubyDoc.info, the de facto standard documentation site for the Ruby
ecosystem. The landing page will update to reflect new releases.

Changes
-------

1. **Documentation generation script** (see `bin/generate-gh-pages.sh`)

    Copies and commits documentation files to the gh-pages branch. The
    script uses git worktrees to isolate the process from the main
    workspace.

    The script:

    - Creates the gh-pages branch as an orphan branch if it doesn't exist
    - Parses semantic versions from tag names, ignoring arbitrary
      prefixes (e.g., tags `1.2.3`, `v1.2.3`, and `release-1.2.3` all
      create `v1.2.3`)
    - Determines the latest version using semantic version sorting
    - Copies static Jekyll template files from `docs/` to the gh-pages
      root (for the latest version only)
    - Generates `docs/_data/versions.yml` with a list of all versions
      for the Jekyll templates to consume

2. **Jekyll template files** (see `docs/` directory)

    - `docs/_config.yml` - Jekyll configuration
    - `docs/index.md` - Landing page template that links to all versions
      on RubyDoc.info based on generated `docs/_data/versions.yml`
    - `docs/latest/index.html` - Redirect page template that redirects
      to the latest documentation on RubyDoc.info

3. **GitHub Actions workflow** (see `.github/workflows/release.yml`)

    Added a `publish_gh_pages` job that runs after the `publish_gem` job
    on release events. The job invokes the generation script with the
    release tag name, then pushes the updated gh-pages branch to deploy
    the documentation.

4. **CI validation** (see `.github/workflows/ci.yml`)

    Added a `yard` job that runs YARD validation with `--no-output`.
    This ensures YARD can successfully parse the codebase (without
    generating output), catching documentation issues early in CI.

5. **YARD dependencies** (see `Gemfile`)

    Added `yard` and `yard-sorbet` gems as development dependencies to
    support documentation validation in CI.

    YARD documentation is automatically generated and hosted by
    RubyDoc.info when the gem is published to RubyGems.org.

6. **Documentation links** (see `README.md` and `mcp.gemspec`)

    Added links to the published API documentation on RubyDoc.info in
    the README and gemspec metadata.

Documentation URL
-----------------

Custom documentation will be available at:
https://modelcontextprotocol.github.io/ruby-sdk/

RubyDoc.info documentation will be accessible at:
- https://rubydoc.info/gems/mcp (latest version)
- https://rubydoc.info/gems/mcp/1.2.3 (specific versions)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 12:21:38 -06:00
Koichi ITO
11aea51c42
Merge pull request #179 from koic/add_draft_version
Add "Draft" protocol version to supported protocol versions
2025-11-22 01:57:51 +09:00
Koichi ITO
26bbdfc28c
Merge pull request #180 from koic/refactor_mcp_server
Refactor to extract duplicate error tool response in `MCP::Server`
2025-11-21 02:43:05 +09:00
Koichi ITO
dd458b1fb7 Add Elicitation skeleton
The MCP 2025-06-18 specification includes a feature called Elicitation:
https://modelcontextprotocol.io/specification/2025-06-18/client/elicitation

Like Log Level, an implementation is expected to be provided in the near future.
This PR adds Elicitation as a skeleton implementation for now.
2025-11-21 02:42:20 +09:00
Koichi ITO
3c452b807c
Merge pull request #176 from koic/tweak_the_readme_doc_for_stateless
[Doc] Tweak the README for stateless
2025-11-20 10:10:31 +09:00
Koichi ITO
1c4ac125e1 Refactor to extract duplicate error tool response in MCP::Server
Consolidates four identical constructions of error `Tool::Response` in
`handle_call_tool_request` into a single private `error_tool_response` method,
reducing duplication and improving maintainability. No behavior change.
2025-11-14 13:54:44 +09:00
Koichi ITO
bf729baef2 Add "Draft" protocol version to supported protocol versions
For example, the `title` introduced in #109 is not supported in the latest stable protocol version "2025-06-18":
https://modelcontextprotocol.io/specification/2025-06-18

It is supported in the Draft of the next version:
https://modelcontextprotocol.io/specification/draft

In other words, the fact that the Ruby SDK treats "2025-06-18" as the default protocol version while `title` is
only supported in the Draft results in an inconsistency.

Because of this, a new version `"Draft"` has been added to the list of supported versions.
Its value follows the schema below and is defined as `DRAFT-2025-v3`:
14ec41c/schema/draft/schema.ts (L15)

It was also considered to continue using the latest stable version "2025-06-18" as the Ruby SDK default instead of the Draft.
However, in that case, users would need to explicitly specify `MCP::Server.new(protocol_version: 'DRAFT-2025-v3')`,
which adds extra burden. In this PR, Draft is made the default in order to provide the following benefits:

- Users are likely to prefer using the Draft version over the latest stable version
- No need to specify the `protocol_version` option when initializing `MCP::Server`
- Users generally do not need to know the internal development value `DRAFT-2025-v3`

The primary case for specifying `protocol_version` explicitly is when strict adherence to a particular version is required.
However, it seems more practical to prioritize use cases where backward-compatible features, including those from the Draft,
are desirable. This is the rationale behind making the Draft version the default.

In addition, making the Draft version the default protocol version preserves backward compatibility for `MCP::Server`.

NOTE: `DRAFT-2025-v3` is a development code, so its value cannot be set externally.
It is applied either when `protocol_version` is omitted or when `nil` is set explicitly,
such as with `MCP::Configuration.new(protocol_version: nil)`.
This prevents users from creating implementations that depend on development codes like `DRAFT-2025-v3`.
2025-11-11 15:44:36 +09:00