Skip to main content

MenteDB Python SDK

Python bindings for MenteDB, the mind database for AI agents. Built with PyO3 and maturin for native Rust performance from Python.

Installation

From source (development)

cd sdks/python
pip install maturin
maturin develop

From PyPI (once published)

pip install mentedb

On Debian and Ubuntu systems pip refuses system wide installs (PEP 668). Use a virtual environment or pipx:

python3 -m venv .venv && .venv/bin/pip install mentedb
# or: pipx install mentedb

Quick start

from mentedb import MenteDB

with MenteDB("./agent-memory") as db:
    # process_turn — the primary API, one call does everything
    result = db.process_turn(
        user_message="The deployment failed because the config was missing",
        assistant_response="I'll check the config setup.",
        turn_id=0,
    )
    # result.context — relevant memories for your prompt
    # result.facts_extracted — what was learned this turn
    # result.contradiction_count — conflicting beliefs detected
    # Optional kwargs: project_context, agent_id, session_id (tags stored
    # turns so injection recall can exclude the requesting session)

    # Sleeptime enrichment runs automatically after process_turn:
    # - Extracts semantic facts from conversations
    # - Links and deduplicates entities
    # - Builds community summaries and user profile
    # Requires LLM config: MENTEDB_OPENAI_API_KEY or MENTEDB_ANTHROPIC_API_KEY

    # Or use low-level APIs directly:

    # Store a memory
    mid = db.store(
        "The deployment failed because the config was missing",
        memory_type=MemoryType.EPISODIC,
        tags=["deployment", "config"],
    )

    # Recall memories with MQL
    result = db.recall("RECALL tag:deployment LIMIT 5")
    print(result.text)

    # Vector similarity search
    hits = db.search(embedding=[0.1] * 384, k=5)
    for hit in hits:
        print(f"{hit.id}: {hit.score:.4f}")

    # Relate memories
    mid2 = db.store("Always validate config before deploy", memory_type=MemoryType.PROCEDURAL)
    db.relate(mid, mid2, edge_type=EdgeType.CAUSED)

    # Forget a memory
    db.forget(mid)

MenteDB Cloud (hosted)

Prefer a managed API with no engine to run? Use MenteDBClient with an mdb_ key from app.mentedb.com. The verbs mirror the embedded client, so only the constructor changes.

from mentedb import MenteDBClient

client = MenteDBClient(api_key="mdb_...")

# Turn 0: tell it something.
client.process_turn("I switched from Postgres to SQLite for side projects", "Noted.", 0)

# Turn 1: it remembers.
result = client.process_turn("what database am I using for side projects?", "", 1)
for memory in result.context:
    print(memory.content)

# Also available: client.search(...), client.store(...),
# client.store_multimodal(data, media_type=...), client.forget(memory_id)

MenteDBClient is pure standard library (no extra dependencies) and talks to https://api.mentedb.com. process_turn uses the REST endpoint, while store, search, store_multimodal, and forget use the hosted MCP tools.

Cognitive features

The SDK also exposes MenteDB cognitive subsystems for real time stream monitoring, conversation trajectory tracking, and pain signal management.

Sleeptime Enrichment

MenteDB automatically enriches memories in the background after process_turn. The pipeline extracts semantic facts, links and deduplicates entities, groups them into communities with summaries, and builds a user profile — all feeding back into future process_turn context retrieval.

Requires an LLM provider: set MENTEDB_OPENAI_API_KEY or MENTEDB_ANTHROPIC_API_KEY. Without one, the engine works normally — enrichment just doesn't run.

Cognitive subsystems

from mentedb._mentedb_python import CognitionStream, TrajectoryTracker, PainRegistry

# Stream monitoring
stream = CognitionStream(buffer_size=500)
stream.feed_token("The")
stream.feed_token(" sky")
alerts = stream.check_alerts([("some-uuid", "the sky is blue")])

# Trajectory tracking
tracker = TrajectoryTracker(max_turns=50)
tracker.record_turn("deployment", "investigating", ["which env?"])
context = tracker.get_resume_context()

# Pain registry
pain = PainRegistry(max_warnings=3)
pain.record_pain("some-uuid", 0.8, ["timeout", "deploy"], "deploy timed out")
warnings = pain.check_triggers(["deploy"])

API reference

MenteDB

Method Description
process_turn(user_message, assistant_response, turn_id, project_context, agent_id) Primary API. Process a conversation turn through the full cognitive pipeline
store(content, memory_type, embedding, agent_id, tags) Store a memory, returns its UUID
recall(query) Recall memories using MQL
search(embedding, k) Vector similarity search
relate(source, target, edge_type, weight) Add a relationship
forget(memory_id) Remove a memory
close() Flush and close the database

Types

MemoryType: episodic, semantic, procedural, anti_pattern, reasoning, correction

EdgeType: caused, before, related, contradicts, supports, supersedes, derived, part_of

License

Apache 2.0. See the repository root LICENSE file for details.

Metadata

Release files for mentedb 0.39.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for mentedb 0.39.1
File
mentedb-0.39.1-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details
mentedb-0.39.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 abi3 Linux glibc 2.17+ x86-64 Details
mentedb-0.39.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.9 abi3 Linux glibc 2.17+ ARM64 Details
mentedb-0.39.1-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details

Total release size: 32.0 MB

Release files / mentedb-0.39.1-cp39-abi3-win_amd64.whl

Download URL mentedb-0.39.1-cp39-abi3-win_amd64.whl
Size 6.1 MB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
b3cb7403b89fbae1986ac13f978857974d37c8116628ec4cdaf5b199fddb7f57
BLAKE2b-256 checksum
How to use checksums
2861500f8aeed7b57e5c3c0b74d43d942a25ee96d2931c3bbb68437176a71897
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 18, 2026.

Transparency log

Release files / mentedb-0.39.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL mentedb-0.39.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 9.8 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
14c9e2eaceff932950a7c79c757bbf145e886890cfd24177f5f4e6e9695cf727
BLAKE2b-256 checksum
How to use checksums
888d15220c364a7d819b76e4efc16f1630972fb350e1b9c779ac4b3d9cffb197
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 18, 2026.

Transparency log

Release files / mentedb-0.39.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL mentedb-0.39.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 9.9 MB
Tags CPython 3.9 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
fa50da206be547ec7eb957934a78fa68404bac63a76b36066819b215f6e47b32
BLAKE2b-256 checksum
How to use checksums
36bfb406d79ce9910a2dec2946020724ccdbaf802602f7f4c30c1ad2c2dd5c01
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 18, 2026.

Transparency log

Release files / mentedb-0.39.1-cp39-abi3-macosx_11_0_arm64.whl

Download URL mentedb-0.39.1-cp39-abi3-macosx_11_0_arm64.whl
Size 6.3 MB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
776038ff7bd4431819a4c916e82bcd84a6fcffcc2ec06face1181276dfa88429
BLAKE2b-256 checksum
How to use checksums
51112b98b781b19438eba6e67ba3ab2c6e2a7d12f4f41f7992a3dd24f22ead98
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 18, 2026.

Transparency log

Release history Release notifications | RSS feed

0.42.0

4 release files

0.41.1

4 release files

0.41.0

4 release files

0.40.0

4 release files

0.39.2

4 release files

This release

0.39.1 This release

4 release files

0.39.0

4 release files

0.38.0

4 release files

0.32.2

4 release files

0.32.1

4 release files

0.32.0

4 release files

0.31.0

4 release files

0.30.0

4 release files

0.29.0

4 release files

0.28.0

4 release files

0.27.3

4 release files

0.27.2

4 release files

0.27.1

4 release files

0.27.0

4 release files

0.26.0

4 release files

0.25.0

4 release files

0.24.6

4 release files

0.24.5

4 release files

0.24.4

4 release files

0.24.3

4 release files

0.21.1

4 release files

0.21.0

4 release files

0.20.4

4 release files

0.20.3

4 release files

0.20.2

4 release files

0.20.1

4 release files

0.20.0

4 release files

0.19.0

4 release files

0.18.0

4 release files

0.17.9

4 release files

0.17.8

4 release files

0.17.7

4 release files

0.17.6

4 release files

0.17.5

4 release files

0.17.4

4 release files

0.17.3

4 release files

0.17.2

4 release files

0.17.1

4 release files

0.17.0

4 release files

0.16.1

4 release files

0.16.0

4 release files

0.15.1

4 release files

0.15.0

4 release files

0.14.7

4 release files

0.14.6

4 release files

0.14.5

4 release files

0.14.4

4 release files

0.14.3

4 release files

0.14.1

4 release files

0.14.0

4 release files

0.13.1

4 release files

0.13.0

4 release files

0.12.6

4 release files

0.12.4

4 release files

0.12.3

4 release files

0.12.2

4 release files

0.12.1

4 release files

0.12.0

4 release files

0.11.7

4 release files

0.11.6

4 release files

0.11.5

4 release files

0.11.4

4 release files

0.9.2

3 release files

0.9.1

3 release files

0.9.0

3 release files

0.8.2

3 release files

0.8.1

3 release files

0.8.0

3 release files

0.7.0

3 release files

0.3.1

3 release files

0.2.9

3 release files

0.2.7

3 release files

0.2.5

3 release files

0.2.1

3 release files

0.1.0

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page