Merge pull request #190 from koic/avoid_draft_protocol_version

Default to the latest stable protocol version
This commit is contained in:
Koichi ITO 2025-12-20 18:55:18 +09:00 • committed by GitHub
commit baeb75c8d8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 13 additions and 13 deletions

View file

@ -38,18 +38,19 @@ module MCP
# 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)

View file

@ -81,7 +81,7 @@ module MCP
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

View file

@ -133,7 +133,7 @@ module MCP
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 @@ module MCP
}
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