{"record":{"id":"117bb4e62645549c","repo":"mastra-ai/mastra","slug":"mcp-client-get-prompt-failed","errorCode":"MCP_CLIENT_GET_PROMPT_FAILED","errorMessage":"MCP_CLIENT_GET_PROMPT_FAILED","messagePattern":"MCP_CLIENT_GET_PROMPT_FAILED","errorType":"error_code","errorClass":"MastraError","httpStatus":null,"severity":"error","filePath":"packages/mcp/src/client/configuration.ts","lineNumber":604,"sourceCode":"       * @returns Promise resolving to the prompt result with messages\n       * @throws {MastraError} If fetching the prompt fails\n       *\n       * @example\n       * ```typescript\n       * const prompt = await mcp.prompts.get({\n       *   serverName: 'weatherServer',\n       *   name: 'forecast',\n       *   args: { city: 'London' },\n       * });\n       * console.log(prompt.messages);\n       * ```\n       */\n      get: async ({ serverName, name, args }: { serverName: string; name: string; args?: Record<string, any> }) => {\n        try {\n          const internalClient = await this.getConnectedClientForServer(serverName);\n          return internalClient.prompts.get({ name, args });\n        } catch (error) {\n          throw new MastraError(\n            {\n              id: 'MCP_CLIENT_GET_PROMPT_FAILED',\n              domain: ErrorDomain.MCP,\n              category: ErrorCategory.THIRD_PARTY,\n              details: {\n                serverName,\n                name,\n              },\n            },\n            error,\n          );\n        }\n      },\n      /**\n       * Sets a notification handler for when the prompt list changes on a server.\n       *\n       * @param serverName - Name of the server to monitor\n       * @param handler - Callback function invoked when prompts are added/removed/modified","sourceCodeStart":586,"sourceCodeEnd":622,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/mcp/src/client/configuration.ts#L586-L622","documentation":"MastraError wrapping any failure that occurs while fetching a prompt (prompts.get) from an MCP server via MCPClient's prompts API. The library first resolves a connected internal client for the named server, then delegates to internalClient.prompts.get; any error in connection or the remote get call is re-thrown with the serverName, prompt name, and args attached as details. Category THIRD_PARTY because the root cause is usually on the MCP server or connection layer.","triggerScenarios":"Calling mcpClient.prompts.get({ serverName, name, args }) when the server is not yet connected/connection fails, or the server rejects the prompt request (unknown prompt name, invalid args, server-side error).","commonSituations":"Typo in serverName or prompt name; server was disconnected or crashed before the call; args not matching the prompt's argument schema; MCP server version not supporting prompts capability.","solutions":["Verify serverName matches a configured server and that the server is reachable (check its health/logs).","Confirm the prompt name exists via prompts.list on the same server.","Validate args against the prompt's declared arguments schema.","Catch the MastraError and inspect its details (serverName, name) and the wrapped cause for the underlying transport error."],"exampleFix":"// before\nconst prompt = await client.prompts.get({ serverName: 'prod-server', name: 'code-review' });\n// after\nconst prompts = await client.prompts.list({ serverName: 'prod-server' });\nif (!prompts.some(p => p.name === 'code-review')) throw new Error('prompt not found');\nconst prompt = await client.prompts.get({ serverName: 'prod-server', name: 'code-review', args: { language: 'ts' } });","handlingStrategy":"try-catch","validationCode":"const names = Object.keys(configuredServers);\nif (!names.includes(serverName)) throw new Error(`unknown server ${serverName}`);\nconst available = await client.prompts.list({ serverName });\nif (!available.some(p => p.name === name)) throw new Error(`prompt ${name} not on ${serverName}`);","typeGuard":"function isMastraErrorWithDetails(e: unknown): e is MastraError & { details: { serverName: string } } {\n  return e instanceof MastraError && typeof (e as any).details?.serverName === 'string';\n}","tryCatchPattern":"try {\n  const prompt = await client.prompts.get({ serverName, name, args });\n} catch (e) {\n  if (e instanceof MastraError && e.id === 'MCP_CLIENT_GET_PROMPT_FAILED') {\n    console.error(`prompt ${e.details.name} failed on ${e.details.serverName}`, e.detail?.originalMessage);\n  } else throw e;\n}","preventionTips":["Always list prompts before getting them.","Validate args against the prompt's declared argument schema.","Check server connectivity at startup and monitor disconnections.","Pin/verify the MCP server supports the prompts capability."],"tags":["mcp","prompts","third-party","remote-call"],"backgroundTag":"mcp-prompt-fetch-failed","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}