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:
parent
ab17d50288
commit
feba4d4893
1 changed files with 24 additions and 2 deletions
|
|
@ -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",
|
||||
|
|
|
|||
Loading…
Reference in a new issue