{"record":{"id":"7ea972fe281dc2a4","repo":"mastra-ai/mastra","slug":"stored-mcp-client-with-id-storedmcpclientid-not","errorCode":null,"errorMessage":"Stored MCP client with id ${storedMCPClientId} not found","messagePattern":"Stored MCP client with id (.+?) not found","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"error","filePath":"packages/server/src/server/handlers/stored-mcp-clients.ts","lineNumber":99,"sourceCode":"  tags: ['Stored MCP Clients'],\n  requiresAuth: true,\n  handler: async ({ mastra, storedMCPClientId, status, requestContext }) => {\n    try {\n      const storage = mastra.getStorage();\n\n      if (!storage) {\n        throw new HTTPException(500, { message: 'Storage is not configured' });\n      }\n\n      const mcpClientStore = await storage.getStore('mcpClients');\n      if (!mcpClientStore) {\n        throw new HTTPException(500, { message: 'MCP clients storage domain is not available' });\n      }\n\n      const mcpClient = await mcpClientStore.getByIdResolved(storedMCPClientId, { status });\n\n      if (!mcpClient) {\n        throw new HTTPException(404, { message: `Stored MCP client with id ${storedMCPClientId} not found` });\n      }\n      assertStoredResourceScope(mcpClient, await getStoredResourceScope(mastra, requestContext));\n\n      return mcpClient;\n    } catch (error) {\n      return handleError(error, 'Error getting stored MCP client');\n    }\n  },\n});\n\n/**\n * POST /stored/mcp-clients - Create a new stored MCP client\n */\nexport const CREATE_STORED_MCP_CLIENT_ROUTE = createRoute({\n  method: 'POST',\n  path: '/stored/mcp-clients',\n  responseType: 'json',\n  bodySchema: createStoredMCPClientBodySchema,","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/server/src/server/handlers/stored-mcp-clients.ts#L81-L117","documentation":"HTTP 404 thrown after getByIdResolved(storedMCPClientId, { status }) returns no record, meaning no stored MCP client exists with that id (in the requested status). This is a normal not-found signal, not a crash: the store was reachable but the row was absent.","triggerScenarios":"GET /api/mcp/clients/:id with an id that was never created, a typo'd id, or an id that exists only in a different status than requested (e.g. exists as draft but queried with status 'archived').","commonSituations":"Client code cached an id from a deleted client; ids derived via toSlug(name) changed after a rename; requesting a non-draft status for a freshly created client.","solutions":["Confirm the exact id via the list endpoint (GET /api/mcp/clients) before fetching by id.","Retry with status 'draft' or omit the status filter for newly created clients.","Recreate the client with POST if it was intentionally deleted.","Check for slug drift: the id is derived from name via toSlug, so renamed clients may have new ids."],"exampleFix":"// before\nconst c = await fetch(`/api/mcp/clients/${id}?status=archived`).json();\n// after\nconst c = await fetch(`/api/mcp/clients/${id}?status=draft`).json();\nif (!c) throw new Error(`Client ${id} not found`);","handlingStrategy":"try-catch","validationCode":"const list = await fetch('/api/mcp/clients').then(r => r.json());\nconst exists = list.some(c => c.id === targetId);\nif (!exists) console.warn(`${targetId} not present; skipping fetch`);","typeGuard":"function isNotFound(res: Response): boolean { return res.status === 404; }","tryCatchPattern":"const res = await fetch(`/api/mcp/clients/${id}?status=${status}`);\nif (res.status === 404) {\n  return null; // treat as absent, not fatal\n}\nif (!res.ok) throw new Error(`Unexpected ${res.status}`);\nreturn res.json();","preventionTips":["Resolve ids from the list endpoint instead of hardcoding.","Remember fresh clients are drafts — query with the right status.","Re-derive ids after renames (toSlug drift).","Handle 404 as a normal branch in client code."],"tags":["mcp","not-found","http-404","rest"],"backgroundTag":"resource-not-found","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}