Skip to main content

MemBlock

Structured memory SDK for AI agents.

Typed blocks · Knowledge graph · Hybrid search · Encryption · Decay engine — all local, all yours.

memblock.xyz

PyPI version License: MIT Python versions


AI agents forget everything between sessions. Vector databases give you search but no structure. Cloud memory APIs lock you in and store your users' data on someone else's servers. MemBlock is the alternative: typed memory blocks, a built-in knowledge graph, hybrid search, encryption, and intelligent decay — all running on your infrastructure with pip install and one line of Python. No Docker, no Neo4j, no subscriptions. Your data never leaves your machine.

Install

pip install memblock

Quick Start

from memblock import MemBlock, BlockType

mem = MemBlock(storage="sqlite:///memory.db")

# Store structured memories
mem.store("User prefers Python", type=BlockType.PREFERENCE)
mem.store("User works at Acme Corp", type=BlockType.FACT, confidence=0.95)

# Query with hybrid search
results = mem.query(text_search="programming", type=BlockType.PREFERENCE)

# Build LLM-ready context
context = mem.build_context(query="user preferences", token_budget=4000)

# Knowledge graph
mem.link(results[0].id, other.id, relation="related_to")

# Tamper detection
mem.verify()

Async (asyncio)

from memblock import AsyncMemBlock, BlockType

# Native asyncpg path — non-blocking storage I/O
mem = AsyncMemBlock(storage="postgresql+asyncpg://user@host/db")

await mem.store("User prefers Python", type=BlockType.PREFERENCE)
results = await mem.query(text_search="programming", limit=10)

# Multi-tenant isolation: each tenant gets its own Postgres schema.
mem = AsyncMemBlock(
    storage="postgresql+asyncpg://user@host/db",
    schema="tenant_xyz",  # bootstraps + isolates on first use
)

AsyncMemBlock accepts plain postgresql:// URLs too — those use the legacy thread-pool wrapper. Use postgresql+asyncpg:// to opt into the native async backend.

Optional Extras

pip install "memblock[postgres]"            # PostgreSQL backend (sync + async + pgvector)
pip install "memblock[embeddings]"          # Local vector embeddings (FastEmbed)
pip install "memblock[llm]"                 # LLM extraction (OpenAI, Anthropic, Gemini)
pip install "memblock[reranker-cohere]"     # Cohere reranker
pip install "memblock[reranker-cross-encoder]"  # HuggingFace reranker
pip install "memblock[all-cloud]"           # Everything without onnxruntime (Python 3.13+)
pip install "memblock[all]"                 # Everything including local embeddings

Documentation

Full docs, API reference, and examples: memblock.xyz

Contributing

Contributions are welcome! MemBlock is open source and community-driven.

  • Found a bug or have a feature idea? Open an issue.
  • Want to contribute code? Fork the repo, create a branch, and open a pull request.
  • Please make sure tests pass and follow the existing code style.

The main branch is protected, so all changes go through pull requests and review.

License

Released under the MIT License. Copyright (c) 2025-2026 iexcalibur.

Download files

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

Source Distribution

memblock-0.13.1.tar.gz (191.1 kB view details)

Uploaded Source

Built Distribution

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

memblock-0.13.1-py3-none-any.whl (149.8 kB view details)

Uploaded Python 3

File details

Details for the file memblock-0.13.1.tar.gz.

File metadata

  • Download URL: memblock-0.13.1.tar.gz
  • Upload date:
  • Size: 191.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for memblock-0.13.1.tar.gz
Algorithm Hash digest
SHA256 9c8432531469eb3a1fc67ca7ec4880d84ec1955d1bb33d4091eb3346db75fa10
MD5 cfe62d2f3f5679ddc869e0176b7936c6
BLAKE2b-256 ffea518dba5cd1e1e2197389df904e5180dae1e29f0e2210d954984c3c4a2f85

See more details on using hashes here.

File details

Details for the file memblock-0.13.1-py3-none-any.whl.

File metadata

  • Download URL: memblock-0.13.1-py3-none-any.whl
  • Upload date:
  • Size: 149.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for memblock-0.13.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1c069c92b33ee1c7c49870cae53a080a8f2a3014eba3a9697edc3821da6cecf7
MD5 dea61ed85de0eec85ef50c392090f232
BLAKE2b-256 4f8fd741199401cf646ab21eba542baa51eed981b7e9223735505138f68c0619

See more details on using hashes here.

Supported by

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