nil params produce a "params": null in the POST body leading to Bad Request on ListTools calls from internal/mcp. If the params are nil, they should be omitted from the final request.

Based in the JSON-RPC spec the params object is either an array, or an object matching the expected params of the endpoint: https://www.jsonrpc.org/specification#request_object

Reference to the marshalling code: https://github.com/golang/tools/blob/439ea2f0f815f46421aaecd85ffd0f75b0a303f9/internal/jsonrpc2_v2/messages.go#L101-L118

Comment From: findleyr

@andrey-star is this not addressed here? https://cs.opensource.google/go/x/tools/+/master:internal/mcp/server.go;l=283;drc=5efcbbf8bce42ce6035c32c6a90f8bbf49dba164

Is it possible you were using an old version of the code?

Comment From: andrey-star

Apologies, I was referring to the MCP client, not the server - specifically ListTools called with nil params *ListToolsParams argument here: https://cs.opensource.google/go/x/tools/+/master:internal/mcp/client.go;l=284;drc=2cae60e3f82b3e911eab6ef0cd7a7cf589568888 The is present in the latest version of the code

Comment From: andrey-star

I realised that passing a default &ListToolsParams{} works since it uses omitempty in the definition. Perhaps the nil case can be coalesced to &ListToolsParams{}, or an error thrown.

Comment From: findleyr

Yes, we should use a &ListToolParams when the argument is nil.