Commit graph

955 commits

Author SHA1 Message Date
Koichi ITO
ad2240798a
Merge pull request #76 from atesgoral/curl-json
Use the not-so-new --json arg of curl
2025-07-15 10:20:16 +09:00
Ates Goral
c8fdf25cdb Use the new --json arg of curl 2025-07-14 20:43:43 -04:00
Ates Goral
1ed313951a Add define_custom_method to define custom methods 2025-07-14 20:12:29 -04:00
Koichi ITO
189d5fc5a5
Merge pull request #74 from mogox/increase_streamable_coverage
Adding test for streamable errors for StreamableHTTPTransport
2025-07-14 09:34:23 +09:00
Enrique Mogollan
b1fa433a47 Adding test for streamable errors for http transport 2025-07-13 02:24:20 -07:00
Koichi ITO
13bee9f60e
Merge pull request #63 from kfischer-okarin/check-notification-capabilities
Check all methods & capabilities
2025-07-13 11:34:42 +09:00
Koichi ITO
1a89cc5537
Merge pull request #61 from kfischer-okarin/simplify-and-add-missing-capabilities
Remove automatic capability determination and add missing capabilities
2025-07-12 19:01:35 +09:00
Ateş Göral
2a7511c8f2
Merge pull request #73 from planio-gmbh/fix/input-schema-without-required-fields
fixes input schema validation for schemas without required fields
2025-07-11 07:18:49 -04:00
Jens Kraemer
271ccb43d0 fixes input schema validation for schemas without required fields 2025-07-11 11:27:59 +02:00
Topher Bullock
b94a938d95
Merge pull request #54 from julianojulio/make_server_context_optional_and_sorbet_friendly
Make `server_context` optional for Tools and Prompts
2025-07-09 13:59:09 -04:00
Topher Bullock
db98dbc13d
Merge pull request #72 from koic/use_console_instead_of_bash
[Doc] Use `console` instead of `bash` for code block highlighting
2025-07-02 12:58:05 -04:00
Koichi ITO
6335d21349 [Doc] Use console instead of bash for code block highlighting
Follow-up to https://github.com/modelcontextprotocol/ruby-sdk/pull/67#discussion_r2162083685.

This PR updates code blocks for command examples to use `console` as the language identifier.
2025-06-25 19:14:30 +09:00
Sam Bostock
40e8b47334
Merge pull request #71 from sambostock/curl-headers
Include response headers in `curl` examples
2025-06-24 13:17:41 -04:00
Sam Bostock
9a85975d12
Log headers in all curl examples
The examples showcase to the user how the server works, so it makes
sense to include headers to show the full picture.
2025-06-24 11:23:33 -04:00
Sam Bostock
cccb7494fa
Log headers in curl initialize requests
The user needs the `mcp-session-id` header, so we should log headers.
2025-06-24 11:22:46 -04:00
Sam Bostock
7a2043b49c
Add space before pipe 2025-06-24 11:21:27 -04:00
Koichi ITO
c806e1ecd2
Merge pull request #67 from koic/remove_chebang_from_example_files
Remove shebang from example files
2025-06-24 02:21:12 +09:00
Koichi ITO
b28a477727
Merge pull request #70 from dak2/fix-error-handling-when-sending-notification
Fix handling response when sending notifications in `examples/streamable_http_client.rb`
2025-06-21 20:19:35 +09:00
dak2
7a5bd7c18f Fix handling response when sending notifications in examples/streamable_http_client.rb
Even though the 'tools/call' request to 'notification_tool' is successful and an 'MCP::Tool::Response' is returned, the logger still prints 'Error:'.

```
% ruby examples/streamable_http_client.rb
=== MCP SSE Test Client ===

[CLIENT] INFO 15:41:04.696 - Initializing session...
[CLIENT] INFO 15:41:04.698 - Session initialized: SESSION_ID
[CLIENT] INFO 15:41:04.698 - Server info: {"name" => "sse_test_server", "version" => "0.1.0"}
[CLIENT] INFO 15:41:04.698 - Connecting to SSE stream...
[CLIENT] INFO 15:41:04.698 - SSE stream connected successfully

=== Available Actions ===
1. Send custom notification
2. Test echo
3. List tools
0. Exit

Choose an action: 1
Enter notification message: notification test
Enter delay in seconds (0 for immediate):
[CLIENT] INFO 15:41:11.248 - SSE data: {"jsonrpc":"2.0","id":"0f657eeb-3e05-47bb-b7b4-898e2cb503af","result":{"content":[{"type":"text","text":"Notification: notification test (timestamp: 2025-06-21T15:41:11+09:00)"}],"isError":false}}
[CLIENT] ERROR 15:41:11.249 - Error:

=== Available Actions ===
1. Send custom notification
2. Test echo
3. List tools
0. Exit
```

It is probably trying to output an MCP::Tool::Response, but these appear in the SSE stream. Therefore, the response it is handling this time should either be accepted or an error.

I modified it so that it could handle them.
2025-06-21 19:38:33 +09:00
Ateş Göral
0fe0289a39
Merge pull request #69 from andyw8/andyw8/disable-release-workflow-on-forks
Disable release workflow on forks
2025-06-20 01:42:20 +03:00
Andy Waite
e955cecb61 Disable release workflow on forks 2025-06-19 15:40:18 -04:00
Koichi ITO
55a3cda66f
Merge pull request #68 from sambostock/deps
Remove `json-schema` limit and reorganize dev deps
2025-06-20 03:51:46 +09:00
Sam Bostock
6935db486e
Stop limiting json-schema version
This was causing conflicts in applications using `json-schema` 5.x.

The only breaking change in 5.0 was dropping support for old Ruby
versions, which we don't support either.
2025-06-19 14:28:09 -04:00
Sam Bostock
f4ba40a71e
Consistently organize development dependencies 2025-06-19 14:26:55 -04:00
Juliano Julio Costa
5d0c5b7f0e Merge remote-tracking branch 'upstream/main' into make_server_context_optional_and_sorbet_friendly 2025-06-19 11:08:00 -04:00
Koichi ITO
100d1a1ab3 Remove shebang from example files
Since the example files are not executable binaries, this PR removes the shebangs.

This ensures that all examples are consistently executed via `ruby` command.
It also removes the executable permission from `examples/stdio_server.rb` using `chmod 444`,
bringing it in line with the other example files.
2025-06-19 16:00:38 +09:00
Ateş Göral
af686a387d
Merge pull request #66 from dak2/fix/readme-of-sse
Rename the example file names related to SSE.
2025-06-18 13:05:59 +03:00
dak2
10cb6c0eb9 Rename the example file names related to SSE.
This PR renamed the files related to the SSE example and fixed the README.md.
Because missing files were specified in README.md.

And also, I removed the word 'test' from the file names related to the SSE example.
Other examples file names do not contain the word `test`.
2025-06-18 18:30:40 +09:00
Kevin Fischer
222147014a
Fix hash format in tests 2025-06-18 13:23:51 +09:00
Kevin Fischer
d7c866efcf
Simplify capability handling again 2025-06-18 13:23:25 +09:00
Topher Bullock
8dda58e77c
Merge pull request #43 from tylerrowsell/tool-arg-validation
Validate ToolCall Args against Schema
2025-06-17 17:39:13 -04:00
Sam Bostock
ffa06b103d
Merge pull request #64 from sambostock/duplicate-method-instrumentation
Remove duplicate `method` instrumentation
2025-06-17 11:58:36 -04:00
Koichi ITO
0027ce7126
Merge pull request #51 from koic/add_migration_path_for_server_transports_std_transport
Add a migration path for `Server::Transports::StdioTransport`
2025-06-18 00:25:00 +09:00
Sam Bostock
ce1c8719cf
Remove duplicate method instrumentation
`handle_request` already adds the `method` to the instrumentation data,
so there is no need to repeat this. Moreover, consumers can override
these anyway.
2025-06-17 02:07:25 -04:00
Kevin Fischer
ff92a3d016
Add missing checks 2025-06-15 17:35:18 +09:00
Kevin Fischer
280e835184
Refactor capability check 2025-06-15 17:35:18 +09:00
Kevin Fischer
9a00406fae
Rewrite extend self to class << self 2025-06-15 17:35:18 +09:00
Kevin Fischer
127f12f740
Add missing method constants 2025-06-15 17:35:18 +09:00
Kevin Fischer
e4c9644e78
Refactor ensure capability tests 2025-06-15 17:35:18 +09:00
Koichi ITO
529f3bbe57
Merge pull request #62 from dak2/fix/rename-to-mcp
Rename to `MCP` when handling exceptions in Streamable HTTP transport
2025-06-15 15:43:28 +09:00
dak2
dc38c9f84a Rename to MCP when handling exceptions in Streamable HTTP transport
The reason for the change is that a NameError occurs when a POST request is made while the stream is closed because ModelContextProtocol is undefined.

I have also added test cases to check the behaviour when IOError and Errno::EPIPE occurs.
2025-06-15 15:21:22 +09:00
Topher Bullock
382ae13e25
Merge pull request #33 from Ginja/streamable-http
Implement Streamable HTTP transport
2025-06-13 18:29:40 -04:00
Topher Bullock
110160b40f
Merge pull request #58 from koic/update_the_mcp_spec_url
[Doc] Update the MCP spec URL
2025-06-13 18:25:06 -04:00
Riley Shott
4d79263a87 Addressing feedback 2025-06-11 13:44:54 -07:00
Riley Shott
2942d456cc JSON body fix in examples/http_server.rb 2025-06-10 12:54:21 -07:00
Juliano Julio Costa
c10c0ddf9d Refactor MCP tool and server to handle optional server_context parameter
- Updated `call` method in `MCP::Tool` and `MCP::Prompt` to accept `server_context` as an optional parameter.
- Refactored `MCP::Server` to streamline argument handling for tool and prompt calls, introducing helper methods `call_tool_with_args` and `call_prompt_template_with_args`.
- Adjusted tests to reflect changes in method signatures and ensure compatibility with optional `server_context` parameter.
2025-06-10 15:40:28 -04:00
Koichi ITO
1b87b3ffde [Doc] Update the MCP spec URL
https://spec.modelcontextprotocol.io/specification/2024-11-05/ URL is redirected to
https://modelcontextprotocol.io/specification/2025-03-26

This update avoids unnecessary redirects from the old URL to the new URL.
2025-06-11 02:00:12 +09:00
Koichi ITO
16ab4bac81 Add a migration path for Server::Transports::StdioTransport
Follow-up to #27.

This PR adds a migration path for `Server::Transports::StdioTransport`. e.g.,

```console
$ cat /tmp/example.rb
require "mcp/transports/stdio"

MCP::Transports::StdioTransport
```

This change displays the following warning instead of raising an error for such cases, allowing execution to proceed:

```console
$ bundle exec ruby /tmp/example.rb
/tmp/example.rb:1: warning: Use `require "mcp/server/transports/stdio_transport"` instead of `require "mcp/transports/stdio"`.
Also use `MCP::Server::Transports::StdioTransport` instead of `MCP::Transports::StdioTransport`.
This API is deprecated and will be removed in a future release.
```

Currently (v0.1.0), it results in an error without any warning.
This MCP gem is not yet close to version 1.0, but introducing breaking changes to a published interface is undesirable.

This compatibility code should be removed at some point after a few releases.

Closes #50.
2025-06-10 16:27:22 +09:00
Riley Shott
91af9ad19a Gracefully handle POST requests with nil bodies 2025-06-09 14:14:41 -07:00
Riley Shott
580029954f Cleanup logs for examples/http_server.rb 2025-06-09 14:13:49 -07:00