{"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":857,"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":839,"sourceCodeEnd":875,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/d8bc9755e74915e5c3b999181e10a67c889bce2a/src/services/sync/ChromaMcpManager.ts#L839-L875","documentation":"Error thrown when the chroma-mcp server responds successfully at the transport level but flags the result as an MCP tool error (result.isError true). The manager extracts the first text content item as the error detail (falling back to 'Unknown chroma-mcp error') and rethrows it as a plain Error naming the tool. This is an application-level error from the Chroma tool itself, not a connection problem.","triggerScenarios":"Any callTool() invocation where chroma-mcp returns isError=true — e.g. chroma_add_documents with an invalid collection name, chroma_query_documents on a nonexistent collection, malformed arguments rejected by the tool, or ChromaDB-side failures surfaced as MCP tool errors.","commonSituations":"Querying/deleting a collection that was never created (typo'd collection name); passing wrong argument types (e.g. ids as string instead of array); embedding function mismatch causing dimension errors on add; ChromaDB storage directory permission or corruption issues.","solutions":["Read the wrapped errorText — it contains chroma-mcp's own diagnostic for the failing tool call.","Verify the tool name and argument schema against the installed chroma-mcp version (argument mismatches are the most common cause).","Ensure the target collection exists before querying/updating/deleting it (call chroma_list_collections first).","Check embedding dimension consistency between indexed and queried documents.","Inspect the ChromaDB persistence directory for permission or corruption problems.","Catch this error and surface the embedded errorText to the caller for targeted handling."],"exampleFix":"// before\nawait manager.callTool('chroma_delete_documents', { collectionName: 'my-col', ids: ['x'] });\n// Error: tool returned error: Collection my-col does not exist\n// after\nconst collections = await manager.callTool('chroma_list_collections', {});\nif (JSON.stringify(collections).includes('my-col')) {\n  await manager.callTool('chroma_delete_documents', { collectionName: 'my-col', ids: ['x'] });\n}","handlingStrategy":"validation","validationCode":"// Validate arguments and collection existence before calling the tool\nconst cols = await manager.callTool('chroma_list_collections', {});\nconst exists = JSON.stringify(cols).includes('\"my-collection\"');\nif (!exists) throw new Error('collection my-collection does not exist');\nif (!Array.isArray(ids) || ids.length === 0) throw new Error('ids must be a non-empty array');","typeGuard":"function isToolError(e: unknown): boolean {\n  return e instanceof Error && /^chroma-mcp tool \".+\" returned error: /.test(e.message);\n}\nfunction extractToolErrorText(e: unknown): string | null {\n  const m = (e as Error)?.message?.match(/returned error: (.+)$/);\n  return m ? m[1] : null;\n}","tryCatchPattern":"try {\n  await manager.callTool('chroma_query_documents', args);\n} catch (e) {\n  const detail = /returned error: (.+)$/.exec((e as Error)?.message ?? '')?.[1];\n  if (detail?.includes('does not exist')) {\n    // create collection or skip\n  } else { throw e; }\n}","preventionTips":["Validate tool arguments against the chroma-mcp schema for the installed version","Ensure the target collection exists before query/update/delete calls","Keep embedding dimensions consistent between writes and queries","Check ChromaDB persistence directory permissions","Parse out the embedded errorText for precise diagnostics instead of treating it as a transport failure"],"tags":["chroma","mcp","tool-error","vector-store","api"],"backgroundTag":"api-error-response","analyzedSha":"d8bc9755e74915e5c3b999181e10a67c889bce2a","analyzedAt":"2026-09-17T16:40:26.182Z","contentChangedAt":"2026-09-17T16:40:26.182Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}