Stamp the required resultType on modern results per SEP-2322
## Motivation and Context SEP-2322 (merged for the 2026-07-28 spec release) makes `resultType` a REQUIRED member of every result a 2026-07-28 server returns: "Servers implementing this protocol version MUST include this field", with absence tolerated only when the result comes FROM an earlier protocol version. The client-side vocabulary landed earlier (`MCP::ResultType`, treating an absent value as `"complete"`), but every ordinary modern result the server returns is unstamped, which violates the MUST for `tools/list`, `tools/call`, `ping`, and every other standard result on the modern wire. The conformance suite's 2026-07-28 requirements fail each of those scenarios on wire-schema validation (`CallToolResult: must have required property 'resultType'`). The dispatch path now stamps `resultType: "complete"` centrally: any Hash result of a request carrying the SEP-2575 `_meta` envelope that does not already carry a `resultType` gets the standard value merged in. Results that already carry a discriminator keep it, notifications and cancellation-suppressed responses are untouched, and legacy results stay unstamped because pre-2026 clients do not know the field. `server/discover`, which is exempt from the `_meta` envelope (pre-version discovery), stamps its `DiscoverResult` at its construction site instead. ## How Has This Been Tested? `bundle exec rake test` passes with zero failures. New tests in `test/mcp/server_test.rb`: `tools/list`, `ping`, and `tools/call` results carry `resultType: "complete"` on modern requests and no `resultType` on legacy requests; `server/discover` carries the stamp. The conformance scenarios previously failing on the missing property (`tools-call-simple-text`, `prompts-get-simple`, `completion-complete`, and the other tools/prompts scenarios) pass at `--spec-version 2026-07-28` against the conformance fixture server. ## Breaking Changes None. The stamp applies only to results of requests carrying the SEP-2575 modern `_meta` envelope; results on stable protocol versions through 2025-11-25 are byte-for-byte unchanged.
This commit is contained in:
parent
e5ab590c05
commit
14bf3a7091
1 changed files with 61 additions and 1 deletions
|
|
@ -4142,6 +4142,42 @@ module MCP
|
|||
refute Apps.client_supports?(server.client_capabilities)
|
||||
end
|
||||
|
||||
# SEP-2322 makes `resultType` REQUIRED on every result of a 2026-07-28 server;
|
||||
# `"complete"` is the standard shape, and legacy results stay unstamped.
|
||||
test "modern results carry resultType complete" do
|
||||
server = Server.new(name: "result_type_test", tools: [result_type_tool])
|
||||
|
||||
[
|
||||
modern_request(Methods::TOOLS_LIST, {}),
|
||||
modern_request(Methods::PING, {}),
|
||||
modern_request(Methods::TOOLS_CALL, { name: "result_type_tool", arguments: {} }),
|
||||
].each do |request|
|
||||
response = server.handle(request)
|
||||
assert_equal "complete", response.dig(:result, :resultType), "expected stamp for #{request[:method]}"
|
||||
end
|
||||
end
|
||||
|
||||
test "legacy results carry no resultType" do
|
||||
server = Server.new(name: "result_type_test", tools: [result_type_tool])
|
||||
|
||||
[
|
||||
{ jsonrpc: "2.0", method: Methods::TOOLS_LIST, id: 1 },
|
||||
{ jsonrpc: "2.0", method: Methods::PING, id: 2 },
|
||||
{ jsonrpc: "2.0", method: Methods::TOOLS_CALL, id: 3, params: { name: "result_type_tool", arguments: {} } },
|
||||
].each do |request|
|
||||
response = server.handle(request)
|
||||
refute response[:result].key?(:resultType), "expected no stamp for #{request[:method]}"
|
||||
end
|
||||
end
|
||||
|
||||
test "server/discover carries resultType complete" do
|
||||
server = Server.new(name: "result_type_test", tools: [result_type_tool])
|
||||
|
||||
response = server.handle({ jsonrpc: "2.0", method: Methods::SERVER_DISCOVER, id: 1 })
|
||||
|
||||
assert_equal "complete", response.dig(:result, :resultType)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Builds a request carrying the SEP-2575 modern `_meta` envelope.
|
||||
|
|
@ -4159,5 +4195,11 @@ module MCP
|
|||
),
|
||||
}
|
||||
end
|
||||
|
||||
def result_type_tool
|
||||
@result_type_tool ||= Tool.define(name: "result_type_tool") do |**|
|
||||
Tool::Response.new([{ type: "text", text: "ok" }])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue