From 2b36bf6b2d5b9b1e1c2989f8f900e639ade6084b Mon Sep 17 00:00:00 2001 From: Koichi ITO Date: Sun, 20 Jul 2025 16:11:08 +0900 Subject: [PATCH] Set default protocol version to the latest specification Currently, MCP has three versions: 2024-11-05, 2025-03-26, and 2025-06-18. - https://modelcontextprotocol.io/specification/2024-11-05/basic/transports (stdio and HTTP with SSE) - https://modelcontextprotocol.io/specification/2025-03-26/basic/transports (stdio and Streamable HTTP) - https://modelcontextprotocol.io/specification/2025-06-18/basic/transports (stdio and Streamable HTTP) The newer specification supports stdio and Streamable HTTP as transport mechanisms. Only the oldest version, 2024-11-05, supports stdin and HTTP with SSE, but that version is now considered legacy. Given the current behavior of the Ruby SDK, it likely makes more sense to set the default protocol version to the latest one, 2025-06-18, rather than the oldest, 2024-11-05. Ideally, the implementation should adjust its behavior based on the version, but this PR is limited to updating the default protocol version only. --- README.md | 4 ++-- lib/mcp/configuration.rb | 4 ++-- test/mcp/server/transports/streamable_http_transport_test.rb | 2 +- test/mcp/server_test.rb | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index a7dc6927..d1db291d 100644 --- a/README.md +++ b/README.md @@ -148,7 +148,7 @@ server.notify_tools_list_changed() #### Rails Controller When added to a Rails controller on a route that handles POST requests, your server will be compliant with non-streaming -[Streamable HTTP](https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#streamable-http) transport +[Streamable HTTP](https://modelcontextprotocol.io/specification/2025-06-18/basic/transports#streamable-http) transport requests. You can use the `Server#handle_json` method to handle requests. @@ -340,7 +340,7 @@ MCP::Server.protocol_version = nil If an invalid `protocol_version` value is set, an `ArgumentError` is raised. -Be sure to check the [MCP spec](https://modelcontextprotocol.io/specification/2025-03-26) for the protocol version to understand the supported features for the version being set. +Be sure to check the [MCP spec](https://modelcontextprotocol.io/specification) for the protocol version to understand the supported features for the version being set. ### Exception Reporting diff --git a/lib/mcp/configuration.rb b/lib/mcp/configuration.rb index 038be59a..30dcc5a6 100644 --- a/lib/mcp/configuration.rb +++ b/lib/mcp/configuration.rb @@ -2,8 +2,8 @@ module MCP class Configuration - DEFAULT_PROTOCOL_VERSION = "2024-11-05" - SUPPORTED_PROTOCOL_VERSIONS = ["2025-06-18", "2025-03-26", DEFAULT_PROTOCOL_VERSION] + DEFAULT_PROTOCOL_VERSION = "2025-06-18" + SUPPORTED_PROTOCOL_VERSIONS = [DEFAULT_PROTOCOL_VERSION, "2025-03-26", "2024-11-05"] attr_writer :exception_reporter, :instrumentation_callback, :protocol_version, :validate_tool_call_arguments diff --git a/test/mcp/server/transports/streamable_http_transport_test.rb b/test/mcp/server/transports/streamable_http_transport_test.rb index 2e86696c..34cd529c 100644 --- a/test/mcp/server/transports/streamable_http_transport_test.rb +++ b/test/mcp/server/transports/streamable_http_transport_test.rb @@ -84,7 +84,7 @@ class StreamableHTTPTransportTest < ActiveSupport::TestCase body = JSON.parse(response[2][0]) assert_equal "2.0", body["jsonrpc"] assert_equal "123", body["id"] - assert_equal "2024-11-05", body["result"]["protocolVersion"] + assert_equal "2025-06-18", body["result"]["protocolVersion"] end test "handles GET request with valid session ID" do diff --git a/test/mcp/server_test.rb b/test/mcp/server_test.rb index e1b12d34..3e5853f0 100644 --- a/test/mcp/server_test.rb +++ b/test/mcp/server_test.rb @@ -114,7 +114,7 @@ class ServerTest < ActiveSupport::TestCase jsonrpc: "2.0", id: 1, result: { - protocolVersion: "2024-11-05", + protocolVersion: "2025-06-18", capabilities: { prompts: { listChanged: true }, resources: { listChanged: true },