{"record":{"id":"e1adf8d60a14d7f5","repo":"mastra-ai/mastra","slug":"mcp-client-with-id-id-not-found","errorCode":null,"errorMessage":"MCP client with id ${id} not found","messagePattern":"MCP client with id (.+?) not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/src/storage/domains/mcp-clients/inmemory.ts","lineNumber":88,"sourceCode":"    await this.createVersion({\n      id: versionId,\n      mcpClientId: mcpClient.id,\n      versionNumber: 1,\n      ...snapshotConfig,\n      changedFields: Object.keys(snapshotConfig),\n      changeMessage: 'Initial version',\n    });\n\n    // Return the thin record\n    return this.deepCopyConfig(newConfig);\n  }\n\n  async update(input: StorageUpdateMCPClientInput): Promise<StorageMCPClientType> {\n    const { id, ...updates } = input;\n\n    const existingConfig = this.db.mcpClients.get(id);\n    if (!existingConfig) {\n      throw new Error(`MCP client with id ${id} not found`);\n    }\n\n    // Separate metadata fields from config fields\n    const { authorId, activeVersionId, metadata, status } = updates;\n\n    // Update metadata fields on the record\n    const updatedConfig: StorageMCPClientType = {\n      ...existingConfig,\n      ...(authorId !== undefined && { authorId }),\n      ...(activeVersionId !== undefined && { activeVersionId }),\n      ...(status !== undefined && { status: status as StorageMCPClientType['status'] }),\n      ...(metadata !== undefined && {\n        metadata: { ...existingConfig.metadata, ...metadata },\n      }),\n      updatedAt: new Date(),\n    };\n\n    // Save the updated record","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/storage/domains/mcp-clients/inmemory.ts#L70-L106","documentation":"Thrown by `update` in the in-memory MCP clients domain when no client with the given id exists in the map. Update only mutates existing records; it never creates them. This is a look-before-mutate guard.","triggerScenarios":"Calling `storage.mcpClients.update({ id, ...updates })` with an id that was never created, was created in a different storage instance, or belongs to a record that was removed.","commonSituations":"Hardcoded ids referencing another environment's data; operating on a stale reference after storage was re-instantiated (common in tests between test cases); typos in id strings.","solutions":["Verify the client exists (list/get) before calling update.","Create the client first if the id is expected to be new (upsert pattern: try update, fall back to create).","Ensure the same storage instance is used across the operations in tests or runtime."],"exampleFix":"// before\nawait mcpClients.update({ id: clientId, status: 'active' });\n// after\nconst existing = await mcpClients.get(clientId);\nif (!existing) await mcpClients.create({ mcpClient: { id: clientId } });\nelse await mcpClients.update({ id: clientId, status: 'active' });","handlingStrategy":"try-catch","validationCode":"const existing = await mcpClients.get(id);\nif (!existing) throw new Error(`Cannot update: MCP client ${id} does not exist`);","typeGuard":null,"tryCatchPattern":"try {\n  await mcpClients.update({ id, ...updates });\n} catch (err) {\n  if (err instanceof Error && /not found/.test(err.message)) {\n    // handle missing record: create it or surface a 404\n    return;\n  }\n  throw err;\n}","preventionTips":["Resolve record ids from a get/list call rather than hardcoding strings.","Keep one storage instance per test to avoid cross-test staleness.","Wrap updates in an upsert helper."],"tags":["storage","not-found","mcp-client","in-memory"],"backgroundTag":"resource-not-found","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}