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
|
|
@ -111,8 +111,15 @@ module MCP
|
|||
missing = required_args - args.keys
|
||||
return if missing.empty?
|
||||
|
||||
# The explicit `error_code` maps a missing prompt argument to Invalid Params (-32602) rather
|
||||
# than the default Internal Error (-32603); a missing required argument is client input, not a
|
||||
# server fault. `error_type: :missing_required_arguments` keeps the descriptive message and
|
||||
# instrumentation label. Mirrors `MCP::Server::ResourceNotFoundError`.
|
||||
raise MCP::Server::RequestHandlerError.new(
|
||||
"Missing required arguments: #{missing.join(", ")}", nil, error_type: :missing_required_arguments
|
||||
"Missing required arguments: #{missing.join(", ")}",
|
||||
nil,
|
||||
error_type: :missing_required_arguments,
|
||||
error_code: JsonRpcHandler::ErrorCode::INVALID_PARAMS,
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue