Describe the bug
For a well-formed JSON-RPC request with a nonexistent method, the PHP SDK returns an error response with id:"" instead of preserving the original request id.
The request has jsonrpc:"2.0", a readable request id, a string method name, and object params. The implementation appears to identify the method as unknown because the error message includes the submitted method name, but the response loses the request id.
Unknown methods can happen with version skew, optional extensions, experimental methods, or methods renamed/removed across protocol or SDK versions.
Tested with:
- PHP SDK: reproduced with stable release
v0.6.0 (433c84b58af346dd32f15f9909679e96a46ebe23)
- Transports: stdio and Streamable HTTP
To Reproduce
- Start a PHP SDK MCP server.
- Complete a normal initialization flow.
- Send this request:
{"jsonrpc":"2.0","id":7,"method":"nonexistent/method","params":{}}
Expected behavior
The server should preserve the request id so the client can correlate the error response with the pending request.
For example:
{"jsonrpc":"2.0","id":7,"error":{"code":-32601,"message":"Method not found"}}
Logs
stdio returned:
{"jsonrpc":"2.0","id":"","error":{"code":-32600,"message":"Unknown method \"nonexistent\/method\"."}}
Streamable HTTP returns the same JSON-RPC error body (id:"", code:-32600) inside an HTTP 200 response.
In both transports, the server remains usable and subsequent pings succeed.
Additional context
The same id:"" behavior also appears on broader validation-error paths, including malformed initialize params, wrong or missing jsonrpc, an empty method string, and method as a number. Those cases are more debatable because some malformed-envelope inputs can make id recovery implementation-dependent.
Describe the bug
For a well-formed JSON-RPC request with a nonexistent method, the PHP SDK returns an error response with id:"" instead of preserving the original request id.
The request has
jsonrpc:"2.0", a readable request id, a string method name, and object params. The implementation appears to identify the method as unknown because the error message includes the submitted method name, but the response loses the request id.Unknown methods can happen with version skew, optional extensions, experimental methods, or methods renamed/removed across protocol or SDK versions.
Tested with:
v0.6.0(433c84b58af346dd32f15f9909679e96a46ebe23)To Reproduce
{"jsonrpc":"2.0","id":7,"method":"nonexistent/method","params":{}}Expected behavior
The server should preserve the request id so the client can correlate the error response with the pending request.
For example:
{"jsonrpc":"2.0","id":7,"error":{"code":-32601,"message":"Method not found"}}Logs
stdio returned:
{"jsonrpc":"2.0","id":"","error":{"code":-32600,"message":"Unknown method \"nonexistent\/method\"."}}Streamable HTTP returns the same JSON-RPC error body (
id:"",code:-32600) inside an HTTP 200 response.In both transports, the server remains usable and subsequent pings succeed.
Additional context
The same
id:""behavior also appears on broader validation-error paths, including malformed initialize params, wrong or missingjsonrpc, an empty method string, andmethodas a number. Those cases are more debatable because some malformed-envelope inputs can make id recovery implementation-dependent.