{"record":{"id":"fa87b4b7be509124","repo":"mastra-ai/mastra","slug":"failed-to-fetch-resources-from-server-this-clien","errorCode":null,"errorMessage":"Failed to fetch resources from server ${this.client.name}: ${e instanceof Error ? e.stack || e.message : String(e)}","messagePattern":"Failed to fetch resources from server (.+?): (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/mcp/src/client/actions/resource.ts","lineNumber":67,"sourceCode":"      if (response && response.resources && Array.isArray(response.resources)) {\n        return response.resources;\n      } else {\n        this.logger.warn('Resources response did not have expected structure', {\n          server: this.client.name,\n          response,\n        });\n        return [];\n      }\n    } catch (e: any) {\n      // MCP Server might not support resources, so we return an empty array\n      if (e.code === ProtocolErrorCode.MethodNotFound) {\n        return [];\n      }\n      this.logger.error('Error getting resources from server', {\n        server: this.client.name,\n        error: e instanceof Error ? e.message : String(e),\n      });\n      throw new Error(\n        `Failed to fetch resources from server ${this.client.name}: ${e instanceof Error ? e.stack || e.message : String(e)}`,\n      );\n    }\n  }\n\n  /**\n   * Retrieves all available resource templates from the connected MCP server.\n   *\n   * Resource templates are URI templates (RFC 6570) that describe dynamic resources.\n   * Returns an empty array if the server doesn't support resource templates.\n   *\n   * @returns Promise resolving to array of resource templates\n   * @throws {Error} If fetching resource templates fails (excluding MethodNotFound)\n   *\n   * @example\n   * ```typescript\n   * const templates = await client.resources.templates();\n   * templates.forEach(template => {","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/mcp/src/client/actions/resource.ts#L49-L85","documentation":"InternalMastraMCPClient's resources.list() wraps any failure from the MCP resources/list request in this Error, logging the underlying message first. The thrown error preserves the original stack or message, indicating the resource listing round-trip with the named server failed.","triggerScenarios":"Calling client.resources.list() when the resources/list MCP request throws or returns an error — unreachable server, closed transport, JSON-RPC error response, or timeout.","commonSituations":"Remote MCP server temporarily down; auth token expired mid-session; stdio server exited; calling resources.list() on a server that never connected.","solutions":["Inspect the wrapped inner error for the root cause","Confirm the server connection is alive (reconnect if needed)","Check that the server declares the resources capability before listing","Retry with backoff for transient connectivity problems"],"exampleFix":"// before\nconst resources = await client.resources.list();\n// after\nif (client.isConnected()) {\n  const resources = await client.resources.list();\n} else {\n  await client.connect();\n}","handlingStrategy":"retry","validationCode":"if (!client.isConnected()) await client.connect();","typeGuard":null,"tryCatchPattern":"try {\n  const resources = await client.resources.list();\n} catch (e) {\n  const cause = e instanceof Error ? e.stack || e.message : String(e);\n  logger.error('resources/list failed:', cause);\n  // retry with backoff or reconnect\n}","preventionTips":["Add exponential backoff retries around resource listing","Verify the server supports the resources capability before calling","Reconnect the client on repeated failures"],"tags":["mcp","network","resources","wrapped-error"],"backgroundTag":"failed-to-fetch-from-server","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}