Repository navigation
Conversation
…sting the tools The client only mirrors x-mcp-header arguments for tools it has listed, so a tool called without listing it first was refused with -32020. The spec asks the client to list the tools and retry in that case.
| $this->refuseRejectedTool($name); | ||
|
|
||
| $response = $this->sendRequest($request, $onProgress, $cancellation, $timeoutSeconds); | ||
| $response = $this->sendRequest(new CallToolRequest($name, $arguments), $onProgress, $cancellation, $timeoutSeconds); |
There was a problem hiding this comment.
the retry gets a fresh $timeoutSeconds (plus the tools/list in between), so this can block well past the timeout. I think it should be a deadline for the whole call no?
There was a problem hiding this comment.
Right: the whole call now shares one deadline. The listing and the retry only get what's left of it, and a retry with nothing left throws TimeoutException.
| $cursor = null; | ||
|
|
||
| do { | ||
| $cursor = $this->listTools($cursor)->nextCursor; |
There was a problem hiding this comment.
nit: $cancellation isn't passed to the listing, so a cancel during it is only seen on the retry. Not a blocker, it'd need a change to listTools() signature.
There was a problem hiding this comment.
ok, it's handled without changing listTools() now. The listing goes through a private helper that takes the cancellation and the remaining time.
…sting The listing and the retry after a -32020 only get what is left of the call's timeout, so the call no longer blocks past it, and the listing observes the cancellation without changing listTools().
When the server refuses a
tools/callwith-32020,Client::callTool()lists the tools again and retries the call once, so a tool called without being listed first gets itsMcp-Param-*headers.Closes #773
Motivation and Context
The client only knows the
x-mcp-headerannotations of tools it has listed. A tool called on a fresh client went out without itsMcp-Param-*headers, and a server that mirrors arguments, such as GitHub's, refused it. The 2026-07-28 Streamable HTTP spec says the client SHOULD calltools/listand retry in that case.How Has This Been Tested?
ToolHeaderRetryTestcalls a tool that mirrors two arguments, against the SDK server underphp -S, without listing first: it fails without the change and passes with it. Found in a real application polling GitHub's MCP server, where we worked around it by listing the tools before each call.Breaking Changes
None.
Types of changes
Checklist
Additional context
It retries once and on any
-32020, since the spec also covers a schema that changed after it was listed. A tool the new listing rejects for malformed annotations is refused as before.