Skip to content

Commit ff48f5c

Browse files
committed
[Conformance] Raise ResourceNotFoundError for unknown resource URIs
## Motivation and Context Per SEP-2164, a `resources/read` request for a nonexistent resource answers with JSON-RPC error -32602 carrying the requested URI in `error.data`, and MUST NOT return an empty `contents` array. The SDK supports this via `MCP::Server::ResourceNotFoundError` (#402), but the conformance fixture's `resources_read_handler` returned an empty array for unknown URIs, so the `sep-2164-resource-not-found` scenario of the 2026-07-28 conformance requirements fails on the fixture ("Server returned a result with an empty contents array"). The gap never surfaced before because the scenario is part of the 2026-07-28 requirement set only; the 2025-11-25 suite the fixture has been passing does not run it. The fixture now raises `ResourceNotFoundError`, which is also the documented pattern for `resources_read_handler` users. ## How Has This Been Tested? - `sep-2164-resource-not-found` passes 4/4 checks at `--spec-version 2026-07-28` against the fixture server. - The `--requirements 2025-11-25` server leg passes 78/78, and each resources scenario reports no change, so known URIs are unaffected. - RuboCop reports no offenses on the changed file. ## Breaking Changes None. The change is confined to the conformance fixture; the shipped gem is untouched.
1 parent 2d8210f commit ff48f5c

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎conformance/server.rb‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,9 @@ def configure_resources_read_handler(server)
577577
).to_h,
578578
]
579579
else
580-
[]
580+
# Per SEP-2164, an unknown URI answers with -32602 carrying the URI in `error.data`;
581+
# an empty `contents` array is forbidden.
582+
raise MCP::Server::ResourceNotFoundError.new(uri, params)
581583
end
582584
end
583585
end

0 commit comments

Comments
 (0)