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)
const { tools } = await this.client.listTools({ timeout: this.timeout });
const { tools } = await this.client.listTools({ timeout: this.timeout });
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:
async listTools(params?: ListToolsRequest['params'], options?: RequestOptions)
async listTools(params?: ListToolsRequest['params'], options?: RequestOptions)
- 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
const { tools } = await this.client.listTools({}, { timeout: this.timeout });
const { tools } = await this.client.listTools({}, { timeout: this.timeout });
4 Replies
Mastra Triager
📝 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!
Abhi Aiyer
Abhi Aiyer2w ago
@Valérian thanks for reporting this! Why dont you open a PR with the fix!
Valérian
ValérianOP2w ago
Next time i'll do it. Didn"t have much time these days, sorry 🙃
Abhi Aiyer
Abhi Aiyer2w ago
no problem! i got a fix out!

Did you find this page helpful?