MCP Client : Incorrect timeout Parameter Position in listTools Call
Summary
The listTools function in packages/mcp/src/client/client.ts passes timeout in the wrong parameter position, causing the timeout configuration to be ignored.
Location
- File: packages/mcp/src/client/client.ts
- Line: 694
- URL: https://github.com/mastra-ai/mastra/blob/4051a9b2a45dbc420f3bb104930825b81414556c/packages/mcp/src/client/client.ts#L694
Current Code (Incorrect)
Expected Behavior
The timeout should be passed in the options parameter (2nd argument), not the params parameter (1st argument).
MCP SDK Signature
From
https://github.com/modelcontextprotocol/typescript-sdk/blob/466483f25df51e71f00689542f4d95a8a50f6b70/src/client/index.ts#L599:
- 1st param (params): Request parameters
- 2nd param (options): Request options including timeout
Impact
- The timeout value is incorrectly passed as a request parameter
- MCP server receives an unexpected timeout field in the request body
- The actual request timeout is not applied, potentially causing hanging requests
Proposed Fix
4 Replies
📝 Created GitHub issue: https://github.com/mastra-ai/mastra/issues/10583
🔍 If you're experiencing an error, please provide a minimal reproducible example whenever possible to help us resolve it quickly.
🙏 Thank you for helping us improve Mastra!
@Valérian thanks for reporting this! Why dont you open a PR with the fix!
Next time i'll do it. Didn"t have much time these days, sorry 🙃
no problem! i got a fix out!