{"record":{"id":"c4acca62874f409f","repo":"thedotmack/claude-mem","slug":"chroma-mcp-tool-toolname-returned-error-er","errorCode":null,"errorMessage":"chroma-mcp tool \"${toolName}\" returned error: ${errorText}","messagePattern":"chroma-mcp tool \"(.+?)\" returned error: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/services/sync/ChromaMcpManager.ts","lineNumber":761,"sourceCode":"      try {\n        if (callGeneration !== this.connectionGeneration) {\n          throw new ChromaMcpConnectionCancelledError('chroma-mcp call cancelled during shutdown');\n        }\n        await this.ensureConnected();\n        result = await this.client!.callTool({\n          name: toolName,\n          arguments: toolArguments\n        });\n      } catch (retryError) {\n        this.connected = false;\n        throw new Error(`chroma-mcp transport error during \"${toolName}\" (retry failed): ${retryError instanceof Error ? retryError.message : String(retryError)}`);\n      }\n    }\n\n    if (result.isError) {\n      const errorText = (result.content as Array<{ type: string; text?: string }>)\n        ?.find(item => item.type === 'text')?.text || 'Unknown chroma-mcp error';\n      throw new Error(`chroma-mcp tool \"${toolName}\" returned error: ${errorText}`);\n    }\n\n    const contentArray = result.content as Array<{ type: string; text?: string }>;\n    if (!contentArray || contentArray.length === 0) {\n      return null;\n    }\n\n    const firstTextContent = contentArray.find(item => item.type === 'text' && item.text);\n    if (!firstTextContent || !firstTextContent.text) {\n      return null;\n    }\n\n    try {\n      return JSON.parse(firstTextContent.text);\n    } catch (parseError: unknown) {\n      if (parseError instanceof Error) {\n        logger.debug('CHROMA_MCP', 'Non-JSON response from tool, returning null', {\n          toolName,","sourceCodeStart":743,"sourceCodeEnd":779,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/d768ba364302d12b76e69e4f021f0bb1d2d50ed6/src/services/sync/ChromaMcpManager.ts#L743-L779","documentation":"Thrown when a chroma-mcp tool call returned a well-formed MCP response but result.isError is true. The manager extracts the first text content item as errorText (defaulting to 'Unknown chroma-mcp error') and throws a plain Error naming the tool and the embedded error text. This is an application-level error from inside chroma-mcp (e.g. invalid collection, bad query args), not a transport failure.","triggerScenarios":"callTool('chroma_query_documents'|'chroma_add_documents'|...) reached the subprocess, which returned isError=true — typical causes: querying/upserting a non-existent collection_name, malformed where-filter, dimension mismatch between embedding and collection, or chroma internal errors surfaced as text.","commonSituations":"Querying before the collection was created (collection_name mismatch); embedding model/dimension change after the collection was created; passing a whereFilter whose operators chroma rejects; chroma version upgrade that renamed a tool or changed an argument.","solutions":["Read the errorText in the message — it is chroma-mcp's own explanation and usually names the exact problem (e.g. 'Collection not found').","If the collection is missing, ensure ensureCollectionExists ran successfully for the collection_name in the call.","Validate toolArguments shape (collection_name, where filter syntax, include array) against the chroma-mcp version in use.","If embeddings/dimensions mismatch after a model change, re-create the collection and re-backfill.","Bump or pin chroma-mcp to a version whose tool names/args match what ChromaMcpManager emits."],"exampleFix":"// before: querying a collection that may not exist yet\nawait chromaMcp.callTool('chroma_query_documents', { collection_name: name, ... });\n// after: ensure the collection exists first, then query\nawait chromaMcp.callTool('chroma_get_or_create_collection', { collection_name: name });\nawait chromaMcp.callTool('chroma_query_documents', { collection_name: name, ... });","handlingStrategy":"validation","validationCode":"// Validate collection exists and args shape before calling\nasync function safeQuery(manager, collectionName: string, args: Record<string, unknown>) {\n  await manager.callTool('chroma_get_or_create_collection', { collection_name: collectionName });\n  return manager.callTool('chroma_query_documents', { collection_name: collectionName, ...args });\n}","typeGuard":"function isToolReturnedError(e: unknown): boolean {\n  return e instanceof Error && /chroma-mcp tool \".*\" returned error:/i.test(e.message);\n}","tryCatchPattern":"try { return await manager.callTool(toolName, args); }\ncatch (e) {\n  if (isToolReturnedError(e)) { log.warn('chroma tool error', { tool: toolName, msg: e.message }); return null; }\n  throw e;\n}","preventionTips":["Always ensureCollectionExists before query/upsert against a collection_name.","Pin chroma-mcp to a version whose tool names/args match ChromaMcpManager's expectations.","Validate where-filter operators against chroma's supported syntax before sending.","Re-create collections after an embedding-model/dimension change to avoid mismatches."],"tags":["chroma","mcp","tool-error","validation","vector-search"],"backgroundTag":null,"analyzedSha":"d768ba364302d12b76e69e4f021f0bb1d2d50ed6","analyzedAt":"2026-08-12T23:52:55.241Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}