Skip to content
agentics.you

Docs

Memory for CrewAI agents

Give every CrewAI agent the same memory. The agent saves what it learns with remember, and any agent in your workspace finds it later with recall. Each memory is a receipt you can check. The connection is the agentics.you MCP server, so there is no extra package to install from us.

Before you start

  1. Create an account at agentics.you/signup.
  2. In the console, open API keys. Under Agent keys, choose Create agent key, pick the agent this code acts as, and copy the key. It starts agk_mcp_ and is shown once.
  3. Keep it in an environment variable, never in code:
bash
export AGENTICS_AGENT_KEY="agk_mcp_..."

Install

bash
pip install crewai "crewai-tools[mcp]"

The code

MCPServerAdapter from crewai-tools connects over streamable-http with the key in headers. Naming remember and recall keeps the crew to those two tools. Each one runs with run, and the same list goes to an Agent.

python
import os

from crewai_tools import MCPServerAdapter

AGENTICS_MCP_URL = os.environ.get("AGENTICS_MCP_URL", "https://agentics.you/mcp")

server = {
    "url": AGENTICS_MCP_URL,
    "transport": "streamable-http",
    "headers": {"Authorization": f"Bearer {os.environ['AGENTICS_AGENT_KEY']}"},
}

with MCPServerAdapter(server, "remember", "recall") as tools:
    by_name = {tool.name: tool for tool in tools}

    # Save a memory, then find it again. Any agent in the workspace can recall it.
    by_name["remember"].run(content="The customer prefers email over phone calls.")
    print(by_name["recall"].run(query="How does the customer like to be contacted?"))

    # Give the same tools to a crew. Its agent recalls before it answers and remembers what it learns.
    if os.environ.get("OPENAI_API_KEY"):
        from crewai import Agent, Crew, Task

        account_manager = Agent(
            role="Account manager",
            goal="Answer questions about customers from what the team already knows.",
            backstory="Call recall before you answer. Call remember to save anything worth keeping.",
            tools=tools,
            llm="gpt-4.1",
        )
        task = Task(description="How should we contact the customer?", expected_output="One sentence.", agent=account_manager)
        print(Crew(agents=[account_manager], tasks=[task]).kickoff())

Run it

bash
python crewai_memory.py

It prints the memory recall found, with its receipt_hash and a verify_url anyone can open. With OPENAI_API_KEY set, it then asks an agent the same question, and the agent can call recall itself.

Next

  • MCP tool reference: every argument remember and recall take, and the other memory tools.
  • Scoping: which memories an agent key can read.
  • Lifecycle: how a newer memory replaces an older one.

This code runs in CI on every change, against a stand-in for the MCP server (examples/guides/ in the repository).