Return Invalid Params for unknown prompts and missing prompt arguments

An unknown prompt name and a missing required prompt argument are client input errors, but prompts/get raised them with the default Internal Error (-32603). The tools/call, resources/read, and completion/complete siblings already return Invalid Params (-32602) for the same not-found and missing-input conditions (resources/read via ResourceNotFoundError, per SEP-2164).

Add an explicit error_code so both map to -32602 while keeping the descriptive message and the existing instrumentation labels.
This commit is contained in:
latent-9 2026-08-15 07:55:27 +12:00
commit feba4d4893
No known key found for this signature in database

View file

@ -1395,6 +1395,9 @@ module MCP
}
response = @server.handle(request)
# An unknown prompt is client input, so it maps to Invalid Params (-32602), not the
# default Internal Error (-32603); matches the tools/call and completion/complete siblings.
assert_equal JsonRpcHandler::ErrorCode::INVALID_PARAMS, response.dig(:error, :code)
assert_equal("Prompt not found unknown_prompt", response[:error][:data])
assert_instrumentation_data({ method: "prompts/get", error: :prompt_not_found })
end
@ -1411,6 +1414,9 @@ module MCP
}
response = @server.handle(request)
# A missing required argument is client input, so it maps to Invalid Params (-32602),
# not the default Internal Error (-32603).
assert_equal JsonRpcHandler::ErrorCode::INVALID_PARAMS, response.dig(:error, :code)
assert_equal "Missing required arguments: test_argument", response[:error][:data]
assert_instrumentation_data({
method: "prompts/get",