This project has been archived by its maintainers, and is no longer receiving any updates.
pydantic-ai-mimir
Persistent, local-first, encrypted memory for Pydantic AI agents — backed by Mimir.
MimirToolset gives a Pydantic AI Agent durable memory that survives across
runs and processes. Your agent can mimir_remember facts and mimir_recall
them later, with full-text + semantic search, all stored in a local SQLite
database that never leaves the machine (and can be AES-256-GCM encrypted at
rest).
Why this package?
Pydantic AI already speaks the Model Context Protocol natively via
MCPToolset, and Mimir is an MCP stdio
server — so you could wire them together by hand. MimirToolset is the
ergonomic shortcut: it subclasses MCPToolset, resolves the mimir binary,
manages the database path, optionally enables encryption, and spawns
mimir serve for you. One line instead of a transport assembly. Because it
is an MCPToolset, every Pydantic AI MCP feature (tool caching,
include_instructions, process_tool_call, tool filtering/renaming) works
unchanged.
Prerequisite: the mimir binary
Mimir is a single self-contained binary. Install it and make sure it is on your
PATH:
# Build from source (Rust toolchain required):
git clone https://github.com/Perseus-Computing-LLC/mimir
cd mimir && cargo build --release
# then put target/release/mimir on your PATH
# ...or download a prebuilt binary from the releases page:
# https://github.com/Perseus-Computing-LLC/mimir/releases
Verify:
mimir --version
Install
pip install pydantic-ai-mimir
This pulls in pydantic-ai-slim[mcp]. If you already use the full
pydantic-ai, that satisfies the dependency too.
Usage
import asyncio
from pydantic_ai import Agent
from pydantic_ai_mimir import MimirToolset
# Spawns `mimir serve --db ~/.mimir/agent.db` and exposes its memory tools.
memory = MimirToolset(db_path="~/.mimir/agent.db")
agent = Agent(
"openai:gpt-5",
toolsets=[memory],
instructions=(
"You have a persistent memory. Use mimir_remember to store durable "
"facts about the user, and mimir_recall to look them up before "
"answering."
),
)
async def main() -> None:
async with agent: # opens the MCP connection for the agent's lifetime
await agent.run("My favourite colour is teal. Please remember that.")
result = await agent.run("What's my favourite colour?")
print(result.output) # -> teal
asyncio.run(main())
Encryption at rest
memory = MimirToolset(
db_path="~/.mimir/agent.db",
encryption_key="~/.mimir/key.b64", # base64-encoded 32-byte AES-256-GCM key
)
Custom binary location
memory = MimirToolset(
db_path="~/.mimir/agent.db",
mimir_binary="/opt/mimir/bin/mimir", # explicit path; otherwise resolved from PATH
)
Passing through MCPToolset options
Any MCPToolset keyword is forwarded:
memory = MimirToolset(
db_path="~/.mimir/agent.db",
id="mimir-memory", # stable id (needed for Temporal/DBOS durability)
include_instructions=True, # inject Mimir's server instructions into the agent
cache_tools=True,
)
What tools does the agent get?
All of Mimir's MCP tools, including:
| Tool | Purpose |
|---|---|
mimir_remember |
Store a durable memory (category, key, body, tags) |
mimir_recall |
Hybrid full-text + semantic search over memories |
mimir_get_entity |
Fetch a specific memory by id/key |
mimir_timeline |
Time-ordered view of memories |
mimir_forget / mimir_supersede |
Delete or replace memories |
mimir_link / mimir_traverse |
Relate and walk between memories |
| ... | and many more (stats, journaling, vault import/export, etc.) |
The exact set depends on your installed Mimir version.
Development
pip install -e ".[test]"
pytest
The unit tests mock the subprocess and run with no mimir binary installed. A
real end-to-end smoke test runs automatically when a mimir binary is on
PATH, and is skipped otherwise.
License
MIT © 2026 Perseus Computing LLC
Metadata
Release files for pydantic-ai-mimir 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pydantic_ai_mimir-0.1.0.tar.gz | 9.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pydantic_ai_mimir-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.4 kB
Release files / pydantic_ai_mimir-0.1.0.tar.gz
| Download URL | pydantic_ai_mimir-0.1.0.tar.gz |
|---|---|
| Size | 9.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
66ece17b16dd18897c3bdc74835582bd42ce92b36c2c4fd029a323b75640157d
|
|
BLAKE2b-256 checksum How to use checksums |
fc80870a6d8faa3693b54d8b01639ca2d5c488a98f29dcb11a88c83945a642f9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 29, 2026.
Transparency logRelease files / pydantic_ai_mimir-0.1.0-py3-none-any.whl
| Download URL | pydantic_ai_mimir-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
25c8d8fa8a663be14737e271293f03d2a016aedb736e4eb3e1e0b0d07c10e868
|
|
BLAKE2b-256 checksum How to use checksums |
2a1ee858c5039f186ad75e66b56c6207c3736982f6ff0b056a538f47b7e418c4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 29, 2026.
Transparency log