Skip to content

AI MEMORY FOR AGENTS · PYDANTIC AI

Give your Pydantic AI agents knowledge they can build on.

We connect your agents to lasting project memory. Save a decision worth keeping, find it in a later run and read the evidence behind it—all through Pydantic AI’s native MCP tools.

Explicit save and recall through your local Claude-Mem worker.

KNOWLEDGE THAT LASTS

Your next run can start with what you learned.

Keep knowledge beyond one run.

We store the project decisions you choose to save, so your next agent run has useful knowledge to build on.

Use the tools your agent already speaks.

Our example connects Pydantic AI’s native MCPToolset to your existing Claude-Mem worker. No second memory database to operate.

Follow the answer back to its source.

Search the project, inspect the timeline and fetch selected records. The demo checks the exact note confirmed by the save receipt.

ILLUSTRATIVE NOTE · REAL TOOL SEQUENCE

A small decision. A lasting reference.

“Run the smoke suite before releasing the application.”

This is the bundled example’s note. Follow it from a selected decision to a verified record your agent can use again.

  1. 01

    Choose a durable note

    Save a project decision with save_memory. The example uses a harmless release checklist.

  2. 02

    Keep its confirmed ID

    A confirmed save identifies the observation. Repeating the same example note and project reuses its fingerprint.

  3. 03

    Find the surrounding knowledge

    Search your selected project and inspect timeline context around the saved observation.

  4. 04

    Read the original record

    Fetch the receipt’s observation ID and check its text before the next run relies on it.

START WITH ONE PROJECT

Connect. Save one note. Read it back.

  1. Install Claude-Mem and start its worker. Follow the installation guide, then check npx claude-mem doctor. Keep your existing worker settings.
  2. Use the example from a source checkout. You need Node.js on PATH, Python 3.11 or later and the installed MCP bundle. If using a source-built bundle, run npm run build first.
  3. Set your paths and project. Replace both absolute paths below. The project selects the memory scope; --cwd is your application directory.
python3 -m venv .venv-pydantic
.venv-pydantic/bin/python -m pip install -r examples/pydantic-ai/requirements.txt

export CLAUDE_MEM_MCP_SERVER="/absolute/path/to/claude-mem/plugin/scripts/mcp-server.cjs"
.venv-pydantic/bin/python examples/pydantic-ai/memory.py --project "my-application" --cwd "/absolute/path/to/my-application"

Check the result. Success includes your project, an observation ID, recalled: true and model_requests: 0. The ID depends on your database. The command saves the example note and retrieves its actual text.

Next, import memory_toolset and MEMORY_TOOLS from the example into your agent. Follow the guide’s native Agent setup with your chosen model and credentials.

AI memory in production

70 days of work. One searchable memory.

Alessandro used our open-source engine across three machines for 70 days. His customized deployment captured the decisions, fixes and discoveries behind the work—and published the data.

Observations captured
22,718
Bug fixes recorded
1,262
Decisions recorded
757

See how he made that knowledge searchable. Then give your own agents a memory to build on.

Claude-Mem’s mascot files a note in a shared card catalogue connected to three computers.
Alessandro’s published field study · March–May 2026

Before you connect

Will it record every prompt or tool call?

This connection saves only selected notes. It does not automatically record conversations, prompts or tool results, and does not inject context at startup. Memory enters a run when its tools are called.

Does the demonstration need a model account?

No. The command exercises the actual memory tools without a model request. A real Pydantic AI agent run needs your chosen provider package and credentials. Recalled text is then part of what you send to that provider.

Can I use it with hosted CMEM Pro?

This example connects to an already-running local worker through an installed MCP bundle. It does not configure a hosted connector. Your worker continues to follow its existing storage and sync settings.

How is project memory selected?

The example binds all four tools to the project you choose, including detail reads. These local-worker filters are not a multi-user authorization boundary; separate accounts or trust boundaries need separate worker data directories.

What if the save is old or the worker is offline?

Search can omit an older record from its limited result window. The demo uses the ID returned by save_memory for timeline and detail retrieval. An unavailable worker or unconfirmed save fails the check; the example queues no retry and does not start the worker for you.

Which versions and platforms does the guide cover?

The checked-in setup pins Pydantic AI 2.67.0, FastMCP 4.1.8 and MCP 2.3.0. The published guide records Linux verification with Python 3.12 and requires Python 3.11 or later. This page does not claim Windows or macOS acceptance. Use the source requirements for a repeatable setup.

How do I disconnect?

Remove the toolset from your agent and remove the example virtual environment if no longer needed. The example does not alter hooks, MCP configuration or provider settings. Existing memories remain in Claude-Mem.

Build on a working example.

Source reviewed November 20, 2026. The published fixture checks explicit save/recall, repeated-save identity, selected-project reads and offline failure with harmless notes. Its model-free verification is separate from a model-driven agent run.

Give the next run a useful starting point.

Keep the decision. Find the evidence. Build from there.