Skip to main content
The CrewAI example uses CrewAI’s native Flow, MCPClient, and StdioTransport. One flow step saves the caller’s handoff; the next retrieves that known observation through project-scoped search, timeline, and detail tools. It runs without a model key.

Capabilities and verified versions

Verified on Linux with Python 3.12.14, CrewAI 1.15.39, MCP Python SDK 1.30.0, and Claude-Mem 15.17.0. macOS, Windows, AMP/cloud deployment, remote authenticated MCP, and a model choosing tools were not verified. This is a deterministic Flow, without CrewAI’s separate memory or embedding subsystem.

Connect to the local worker

You need Node.js, Python 3.11 or later, an installed Claude-Mem MCP script, and a running local worker. From a Claude-Mem checkout:
Start the worker with npm run worker:start if it is stopped. Select your trusted installed MCP script, or the shipped script in this checkout. If you use a custom CLAUDE_MEM_DATA_DIR or CLAUDE_MEM_WORKER_PORT, set the same values for the example. Paths are passed as individual process arguments, including paths with spaces. The MCP child uses local worker mode with autostart disabled. The example adds no hooks or MCP configuration and does not alter worker settings. Repeating setup creates no duplicate installation entries.

Save and recall a handoff

The @start() method saves the supplied note and requires a confirmed observation ID. The @listen(remember) method then shows a recent project index and recalls that ID’s timeline and details. Every tool call receives the fixed project chosen by the caller. Returned text cannot choose a different project or tool, or authorize another save. Successful output includes saved_id, recalled, and the native flow_id. Repeating the command with the same project, run ID, and note returns the same saved ID. The receipt remains the recall target even if newer notes have pushed it outside the recent 20-result index.

Native client and flow

The example keeps one native MCP client connected while the Flow runs:
For this pinned CrewAI version, max_retries=1 means one attempt, without a retry. The client discovers the worker’s tools and the Flow calls only save_memory, search, timeline, and get_observations. It uses call_tool_result() because call_tool() returns text without the MCP error flag. A failed MCP result is rejected before its content is used. Claude-Mem stores the note through its existing manual-memory contract with platformSource: "crewai", runId, and crewaiFlowId metadata. The flow UUID is generated by CrewAI. A new invocation creates a new Flow; a deliberate duplicate save returns the original observation and retains its original provenance. The logical run ID and note content determine the receipt fingerprint. Neither identity resumes inference or replays a conversation.

Worktree project boundaries

Reads send both the selected project and an explicit projects=json.dumps([project]) list. This prevents the MCP server from automatically widening a worktree’s read scope to its parent checkout. save_memory receives only the selected project. The native tests create a real Git repository and linked worktree, seed a parent-project observation, and run the SDK from that worktree. The chosen project’s index and timeline exclude the parent record; an explicit detail read of its known ID also returns no parent content. The project list is encoded as a JSON string so the GET query path preserves literal commas and JSON-looking keys. Nonempty project names retain their exact outer whitespace. Native checks seed separate split/trimmed-key projects and confirm they stay out of search, timeline, and recalled details.

Repeated runs and failures

The source fingerprint includes the integration, project, run ID, and note text. The worker’s existing receipt prevents duplicate storage on deliberate repeats. Changing the note represents a new explicit save. There are no automatic write retries. If a timeout makes the outcome uncertain, inspect the viewer or repeat with the same run ID and text after checking the worker. Connection, discovery, and tool calls each have a 10-second deadline. An 80-second outer deadline covers the client, Flow, and cleanup. A missing script, blank project, stopped worker, rejected tool call, or deadline gives a nonzero CLI exit and a short diagnostic. A failed recall after a confirmed save does not undo that save; the example reports overall failure without claiming completion.

Real-client verification

With Bun and Node.js available, run:
This verification uses fresh worker settings and a restricted child-process environment. It imports the shipped WorkerService and calls start() directly, so the CLI startup path does not run host hook-configuration repairs. The subshell also clears inherited cloud-sync credentials; it does not change your normal worker’s settings or saved memory. The nine checks use the actual CrewAI Flow and MCP client, the shipped worker, and a fresh SQLite database. They cover save and recall, a repeated receipt after 25 newer notes, project isolation, platform/manual-session/native-flow identity, an actual rejected MCP save, blank input, a stopped worker, telemetry settings, and a bounded slow save with exactly one request. The slow HTTP endpoint is a fault fixture; successful writes and recall use the real worker. The verified run saved observation 3, recalled its supplied text, and returned 3 again after 25 newer notes. Its disposable data path contained spaces. No model request or model key was used.

Data and disconnect

Before importing CrewAI, this standalone script sets OTEL_SDK_DISABLED=true and CREWAI_TRACING_ENABLED=false. These are separate controls: disabling telemetry alone does not disable CrewAI tracing. The Flow also sets tracing=False. The native console formatter is quiet so MCP argument panels do not print the supplied note; the final requested recall remains CLI output. When embedding this example, apply those choices before your application’s CrewAI imports and choose deliberately where final output is retained. Only the explicit note, project, selected IDs, and provenance metadata enter the local memory path. No model or additional memory service receives them from this script. Existing worker sync and export settings still apply to saved notes. Use a trusted local worker: project filtering is not multiuser authentication. Save only text intended for retention. No excluded transcripts or prior conversations are collected and no privacy settings are changed in the worker. Stop running the example or remove it from your application to disconnect. The client’s async context closes its MCP child after the run. You may remove the dedicated virtual environment; no worker configuration or memory is deleted.

Official references