{"record":{"id":"f27cb672489a6f49","repo":"mastra-ai/mastra","slug":"mcp-server-with-id-id-not-found","errorCode":null,"errorMessage":"MCP server with id ${id} not found","messagePattern":"MCP server with id (.+?) not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/src/storage/domains/mcp-servers/inmemory.ts","lineNumber":88,"sourceCode":"    await this.createVersion({\n      id: versionId,\n      mcpServerId: mcpServer.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: StorageUpdateMCPServerInput): Promise<StorageMCPServerType> {\n    const { id, ...updates } = input;\n\n    const existingConfig = this.db.mcpServers.get(id);\n    if (!existingConfig) {\n      throw new Error(`MCP server 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: StorageMCPServerType = {\n      ...existingConfig,\n      ...(authorId !== undefined && { authorId }),\n      ...(activeVersionId !== undefined && { activeVersionId }),\n      ...(status !== undefined && { status: status as StorageMCPServerType['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-servers/inmemory.ts#L70-L106","documentation":"Thrown by `update` in the in-memory MCP servers domain when no MCP server with the given id is stored. Updates mutate only existing records and will not create one implicitly.","triggerScenarios":"Calling `storage.mcpServers.update({ id, ...updates })` with an id absent from the map — never created, created in a different storage instance, or already deleted.","commonSituations":"Stale references after storage re-instantiation between tests; ids from another environment; typos or changed id schemes.","solutions":["Verify the server exists (get/list) before updating.","Implement upsert: fall back to create when update reports not-found.","Share one storage instance across the code path performing create and update."],"exampleFix":"// before\nawait mcpServers.update({ id: serverId, status: 'active' });\n// after\ntry {\n  await mcpServers.update({ id: serverId, status: 'active' });\n} catch (e) {\n  if (!/not found/.test(String(e))) throw e;\n  await mcpServers.create({ mcpServer: { id: serverId } });\n}","handlingStrategy":"try-catch","validationCode":"const existing = await mcpServers.get(id);\nif (!existing) throw new Error(`Cannot update: MCP server ${id} does not exist`);","typeGuard":null,"tryCatchPattern":"try {\n  await mcpServers.update({ id, ...updates });\n} catch (err) {\n  if (err instanceof Error && /not found/.test(err.message)) {\n    // surface 404 or create the record\n    return;\n  }\n  throw err;\n}","preventionTips":["Look up ids via get/list before updating.","Wrap server mutations in an upsert helper.","Keep create/update flows on the same storage instance."],"tags":["storage","not-found","mcp-server","in-memory"],"backgroundTag":"resource-not-found","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T08:17:16.595Z"}