[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.
This commit is contained in:
parent
2d8210f411
commit
ff48f5c6dd
1 changed files with 3 additions and 1 deletions
|
|
@ -577,7 +577,9 @@ module Conformance
|
|||
).to_h,
|
||||
]
|
||||
else
|
||||
[]
|
||||
# Per SEP-2164, an unknown URI answers with -32602 carrying the URI in `error.data`;
|
||||
# an empty `contents` array is forbidden.
|
||||
raise MCP::Server::ResourceNotFoundError.new(uri, params)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue