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.

Metadata

Release files for memblock 0.13.2

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

Source distribution (sdist)

Source distribution for memblock 0.13.2
File Size Uploaded
memblock-0.13.2.tar.gz 224.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for memblock 0.13.2
File Interpreter ABI Platform
memblock-0.13.2-py3-none-any.whl Python 3 none any Details

Total release size: 382.9 kB

Release files / memblock-0.13.2.tar.gz

Download URL memblock-0.13.2.tar.gz
Size 224.1 kB
Tags Source
SHA-256 checksum
How to use checksums
6e63cad59b6bdfcd1ee051c1d768ca5fdc0d74be7218d56892435b17e4d7f6fb
BLAKE2b-256 checksum
How to use checksums
d0d1ef55417703baf488b1a89695f50e6bf8d8723f60735f3238abf56e01b6c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release files / memblock-0.13.2-py3-none-any.whl

Download URL memblock-0.13.2-py3-none-any.whl
Size 158.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
47e388a8ca545c3dadffb0f2adbb586f43d0abbfaa6a72a7c2f73723ea165a19
BLAKE2b-256 checksum
How to use checksums
d1b3eabb8a9dcddba4c252d948071e78dc7c927ec7363fccd122e5ab4cf86189
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release history Release notifications | RSS feed

This release

0.13.2 This release

2 release files

0.13.0

2 release files

0.12.1

2 release files

0.12.0

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.2

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 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