Commit graph ruby-sdk/README.md
Author SHA1 Message Date
Adam Jones
685a4913d4
chore: update licensing to Apache 2.0 for new contributions 2026-01-12 22:49:19 +00: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
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
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
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
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
d31c3da8f2
Merge pull request #178 from koic/add_elicitation_skeleton
Add Elicitation skeleton
2025-11-25 01:02:30 +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
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
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
Koichi ITO
b8719ce04f [Doc] Tweak the README for stateless
`stateless` was supported in #101. However, as shown in the official specification below,
the supported transports are stdout and Streamable HTTP, and whether it is stateless is
a detail specific to Streamable HTTP:
https://modelcontextprotocol.io/specification/2025-06-18/basic/transports

This PR updates the documentation to describe `stateless` as part of the Streamable HTTP section.
2025-11-08 12:55:35 +09:00
Hiren Hiranandani
08a84c7320
Introduce stateless mode to allow for HA
- Create failing tests for `stateless` mode
- Implement `stateless` mode by turning of SSE in Streamable HTTP,
  making the interaction a standard HTTP Req/Resp
2025-11-04 15:26:12 -08:00
Koichi ITO
5b737eb9c3 [Docs] Extract release documentation to RELEASE.md
README is generally better kept focused on information that is most valuable to users.
For that reason, release procedures that are not relevant to end users have been moved to
a separate RELEASE.md file.
2025-11-04 11:13:39 +09:00
Koichi ITO
fb67a9b969 [Doc] Fix incorrect schema name
This PR fixes an incorrect schema name.

The test code already uses `items:`.
https://github.com/modelcontextprotocol/ruby-sdk/blob/v0.4.0/test/mcp/tool/output_schema_test.rb#L135-L141

Fixes #170.
2025-10-26 01:24:45 +09:00
Koichi ITO
ad87c8d805
Merge pull request #163 from dak2/add-client-prompts-support
Add `prompts/list` and `prompts/get` support to client
2025-10-19 02:24:36 +09:00
dak2
e88deb6b65 Add prompts/list and prompts/get support to client
This commit adds two new methods to `MCP::Client`:
- prompts: Lists available prompts from the server via `prompts/list`
- get_prompt: Retrieves a specific prompt by name via `prompts/get`

Both methods follow the same pattern as the existing resources support,
including comprehensive test coverage and README documentation updates.

ref. https://github.com/modelcontextprotocol/modelcontextprotocol/blob/main/docs/specification/2025-03-26/server/prompts.mdx#protocol-messages
2025-10-15 13:16:41 +09:00
Koichi ITO
f312695798
Merge pull request #153 from modelcontextprotocol/prompt-spec-compliance
fix `Prompt` type gaps with 2025-06-18 spec
2025-10-15 01:22:45 +09:00
Koichi ITO
93215f4d52 [Doc] Mention resources/list and resources/read in the README
Follow-up to https://github.com/modelcontextprotocol/ruby-sdk/pull/160
2025-10-12 00:33:01 +09:00
Topher Bullock
a1dd3dd005 add _meta field to Prompt
> See [General fields: `_meta`](/specification/2025-06-18/basic/index#meta) for notes on `_meta` usage.

51e093b8eb/schema/2025-06-18/schema.ts (L680-L683)
2025-10-10 09:05:55 -04:00
Koichi ITO
a217f70d95 [Doc] Fix incorrect example code in README
Follow-up to https://github.com/modelcontextprotocol/ruby-sdk/pull/33.

A `NameError` occurs because `MCP::Transports::HTTP` does not exist.
The correct constant is `MCP::Server::Transports::StreamableHTTPTransport`.
2025-10-09 11:44:58 +09:00
Koichi ITO
bee6eace22 Remove unnecessary transport requires
The transports are already required by `require 'mcp'`:
https://github.com/modelcontextprotocol/ruby-sdk/blob/v0.3.0/lib/mcp.rb#L16-L17
2025-10-07 14:10:48 +09:00
Topher Bullock
701f6faab6 add title field to prompt argument
`PromptArgument extends BaseMetadata`, which includes both name and
title
 - 51e093b8eb/schema/2025-06-18/schema.ts (L686-L698)
 - 51e093b8eb/schema/2025-06-18/schema.ts (L294-l309)
2025-10-06 09:35:42 -04:00
Koichi ITO
de1e833ae3
Merge pull request #144 from nilcolor/output_schema_arrays
Allow output schema to be array of objects
2025-09-28 03:17:09 +09:00
Anandaroop Roy
f7cf080cc0
Support structuredContent in tool response (#147) 2025-09-27 02:23:41 -04:00
Koichi ITO
99f90b8b31 Fix some typos
The `ModelContextProtocol` module name has been renamed to `MCP`,
and `define_protocol` appears to be a typo for `define_prompt`.
2025-09-25 18:06:34 +09:00
Alexey Blinov
4ee128ad67 Allow output schema to be array of objects
closes #142
2025-09-25 11:56:03 +05: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
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
Joey Cardosi
8b764428b1
Add basic HTTP client support with pluggable transports 2025-09-08 15:52:37 -05: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
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
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
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
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
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
62360338f4
Merge pull request #109 from jdnvn/main
Add title to tools, prompts and resources
2025-08-20 16:19:38 -04:00