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