Skip to main content

The mind database for AI agents

Project description

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.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

mentedb-0.27.2-cp39-abi3-win_amd64.whl (5.9 MB view details)

Uploaded CPython 3.9+Windows x86-64

mentedb-0.27.2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (9.6 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ x86-64

mentedb-0.27.2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (9.8 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

mentedb-0.27.2-cp39-abi3-macosx_11_0_arm64.whl (6.1 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

File details

Details for the file mentedb-0.27.2-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: mentedb-0.27.2-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 5.9 MB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for mentedb-0.27.2-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 e127ad8f760441249557e658b2a1f5a1ee6d63c3e63f2761e841c4480328ba74
MD5 68a27c892ffb8dd8fb34ee9e0a027905
BLAKE2b-256 e3cbb56da47e4bb5a51209d8725c0f16365a8d43f72567c0fbc04c9210fb6590

See more details on using hashes here.

Provenance

The following attestation bundles were made for mentedb-0.27.2-cp39-abi3-win_amd64.whl:

Publisher: publish-sdks.yml on nambok/mentedb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mentedb-0.27.2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mentedb-0.27.2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 57561d7bdf4debdfd00f14793ff3298f541705e5a26eb42c7f7d79ff67c3a7fd
MD5 f04db50b7b641a4810aca3acb93ad68c
BLAKE2b-256 63a7652636213bda6515db1437202dfd6a9c76454b10ba2c4a5a35928ae6d2a2

See more details on using hashes here.

Provenance

The following attestation bundles were made for mentedb-0.27.2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish-sdks.yml on nambok/mentedb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mentedb-0.27.2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for mentedb-0.27.2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 ebe72216c1d8631f364536e74e034983f3bd596dc17a456fc2243d925a7d5784
MD5 303840f95f9b8668e559cb914d6fe74d
BLAKE2b-256 284d2d2135dbce2811161f1a20e66c450f0aab16e77c8dde736b6061e7f053fe

See more details on using hashes here.

Provenance

The following attestation bundles were made for mentedb-0.27.2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: publish-sdks.yml on nambok/mentedb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mentedb-0.27.2-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for mentedb-0.27.2-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 806c7351ff0e8e84a8b942fceb18899d7689407e1e33bcc959b831afcd99dabd
MD5 0cd97bb88beda36d5a4b7a361f013bdc
BLAKE2b-256 9c24f7dd37116e3b2a9c03327d80b4e0283de6eb7c49f47c48bcaa4a70db8a40

See more details on using hashes here.

Provenance

The following attestation bundles were made for mentedb-0.27.2-cp39-abi3-macosx_11_0_arm64.whl:

Publisher: publish-sdks.yml on nambok/mentedb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page