From c786a14f61ca73dcb6e030301416aea0e55bca43 Mon Sep 17 00:00:00 2001 From: Koichi ITO Date: Thu, 4 Dec 2025 03:15:02 +0900 Subject: [PATCH] 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. --- README.md | 3 ++- lib/mcp/configuration.rb | 8 +++----- test/mcp/configuration_test.rb | 9 +++++---- .../server/transports/streamable_http_transport_test.rb | 2 +- test/mcp/server_test.rb | 4 ++-- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index c041c3a..c60ccad 100644 --- a/README.md +++ b/README.md @@ -349,7 +349,8 @@ configuration = MCP::Configuration.new(protocol_version: "2024-11-05") MCP::Server.new(name: "test_server", configuration: configuration) ``` -If no protocol version is specified, the [Draft version](https://modelcontextprotocol.io/specification/draft) will be applied by default. +If no protocol version is specified, the latest stable version will be applied by default. +The latest stable version includes new features from the [draft version](https://modelcontextprotocol.io/specification/draft). This will make all new server instances use the specified protocol version instead of the default version. The protocol version can be reset to the default by setting it to `nil`: diff --git a/lib/mcp/configuration.rb b/lib/mcp/configuration.rb index 1a22a24..8642dbc 100644 --- a/lib/mcp/configuration.rb +++ b/lib/mcp/configuration.rb @@ -2,10 +2,8 @@ module MCP class Configuration - # DRAFT-2025-v3 is the latest draft protocol version: - # https://github.com/modelcontextprotocol/modelcontextprotocol/blob/14ec41c/schema/draft/schema.ts#L15 - DRAFT_PROTOCOL_VERSION = "DRAFT-2025-v3" - SUPPORTED_STABLE_PROTOCOL_VERSIONS = ["2025-06-18", "2025-03-26", "2024-11-05"] + LATEST_STABLE_PROTOCOL_VERSION = "2025-06-18" + SUPPORTED_STABLE_PROTOCOL_VERSIONS = [LATEST_STABLE_PROTOCOL_VERSION, "2025-03-26", "2024-11-05"] attr_writer :exception_reporter, :instrumentation_callback @@ -35,7 +33,7 @@ def validate_tool_call_arguments=(validate_tool_call_arguments) end def protocol_version - @protocol_version || DRAFT_PROTOCOL_VERSION + @protocol_version || LATEST_STABLE_PROTOCOL_VERSION end def protocol_version? diff --git a/test/mcp/configuration_test.rb b/test/mcp/configuration_test.rb index a4193a2..d8656a4 100644 --- a/test/mcp/configuration_test.rb +++ b/test/mcp/configuration_test.rb @@ -38,18 +38,19 @@ class ConfigurationTest < ActiveSupport::TestCase # https://github.com/modelcontextprotocol/modelcontextprotocol/blob/14ec41c/schema/draft/schema.ts#L15 test "initializes with default protocol version" do config = Configuration.new - assert_equal Configuration::DRAFT_PROTOCOL_VERSION, config.protocol_version + assert_equal Configuration::LATEST_STABLE_PROTOCOL_VERSION, config.protocol_version end test "uses the draft protocol version when protocol_version is set to nil" do config = Configuration.new(protocol_version: nil) - assert_equal Configuration::DRAFT_PROTOCOL_VERSION, config.protocol_version + assert_equal Configuration::LATEST_STABLE_PROTOCOL_VERSION, config.protocol_version end test "raises ArgumentError when setting the draft protocol version" do exception = assert_raises(ArgumentError) do - # To use the draft version externally, either omit `protocol_version` or set it to nil. - Configuration.new(protocol_version: Configuration::DRAFT_PROTOCOL_VERSION) + # DRAFT-2025-v3 is the latest draft protocol version: + # https://github.com/modelcontextprotocol/modelcontextprotocol/blob/14ec41c/schema/draft/schema.ts#L15 + Configuration.new(protocol_version: "DRAFT-2025-v3") end assert_equal("protocol_version must be 2025-06-18, 2025-03-26, or 2024-11-05", exception.message) diff --git a/test/mcp/server/transports/streamable_http_transport_test.rb b/test/mcp/server/transports/streamable_http_transport_test.rb index 2a1ee53..acae7b6 100644 --- a/test/mcp/server/transports/streamable_http_transport_test.rb +++ b/test/mcp/server/transports/streamable_http_transport_test.rb @@ -81,7 +81,7 @@ class StreamableHTTPTransportTest < ActiveSupport::TestCase body = JSON.parse(response[2][0]) assert_equal "2.0", body["jsonrpc"] assert_equal "123", body["id"] - assert_equal Configuration::DRAFT_PROTOCOL_VERSION, body["result"]["protocolVersion"] + assert_equal Configuration::LATEST_STABLE_PROTOCOL_VERSION, 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 dba9b80..8466bc5 100644 --- a/test/mcp/server_test.rb +++ b/test/mcp/server_test.rb @@ -133,7 +133,7 @@ class ServerTest < ActiveSupport::TestCase jsonrpc: "2.0", id: 1, result: { - protocolVersion: Configuration::DRAFT_PROTOCOL_VERSION, + protocolVersion: Configuration::LATEST_STABLE_PROTOCOL_VERSION, capabilities: { prompts: { listChanged: true }, resources: { listChanged: true }, @@ -776,7 +776,7 @@ def call(message:, server_context: nil) } response = @server.handle(request) - assert_equal Configuration::DRAFT_PROTOCOL_VERSION, response[:result][:protocolVersion] + assert_equal Configuration::LATEST_STABLE_PROTOCOL_VERSION, response[:result][:protocolVersion] end test "server response does not include title when not configured" do