Skip to main content

Official Python SDK for Cube Memory — semantic search with 100% exact recall

Project description

cubememory

Official Python SDK for Cube Memory — semantic search with 100% exact recall, isolated multi-tenant islands, and native MCP support.

PyPI npm License: MIT

Install

pip install cubememory          # sync (uses requests)
pip install cubememory[async]   # + async support (uses httpx)

Quick Start

from cubememory import CubeClient

cube = CubeClient(
    base_url="https://cubememory.com.br/gateway",
    api_key="cm_live_YOUR_KEY",
    project_id="proj_YOUR_PROJECT",
)

# Semantic search — 100% exact cosine recall (no ANN approximation)
results = cube.index("my-docs").search("wireless headphones", limit=10)
for r in results:
    print(f"[{r.score:.2f}] {r.text_preview}")

# Index a document
cube.index("my-docs").insert(
    id="doc-001",
    text="Noise cancelling Sony WH-1000XM5",
    metadata={"price": 349, "brand": "Sony"},
)

# LLM Memory (agent remembers between sessions)
cube.memory.store("User prefers dark mode and speaks Portuguese")
ctx = cube.memory.search("user preferences")

# PKM Notes
cube.notes.upsert(
    title="Meeting Q3",
    text="Discussed the roadmap and timeline.",
    tags=["meeting", "q3"],
)
notes = cube.notes.search("roadmap")

Async Usage

import asyncio
from cubememory.client import AsyncCubeClient

async def main():
    cube = AsyncCubeClient(
        base_url="https://cubememory.com.br/gateway",
        api_key="cm_live_YOUR_KEY",
        project_id="proj_YOUR_PROJECT",
    )
    results = await cube.index("my-docs").search("wireless headphones")
    memories = await cube.memory.search("user preferences")

asyncio.run(main())

API Reference

CubeClient(base_url, api_key, project_id, timeout=30.0)

Param Type Description
base_url str Gateway URL, e.g. https://cubememory.com.br/gateway
api_key str Your API key (cm_live_xxx)
project_id str Your project ID (proj_xxx)

cube.index(name)

Method Description
.insert(id, text, metadata?) Index a document
.insert_many(docs[]) Batch index
.search(query, limit?, threshold?, filter?) Semantic search → List[SearchResult]
.get(id) Fetch by ID
.delete(id) Remove document
.stats() Index statistics

SearchResult fields: id, score, text_preview, metadata


cube.memory

Agent memory — persists LLM context between sessions.

Method Description
.store(text, layer?) Save memory ("long-term" or "short-term")
.search(query, limit?) Semantic search → List[SearchResult]
.list(limit?) List all memories
.delete(id) Delete a memory

cube.notes

PKM Notes — Obsidian-style knowledge base with AI auto-connections.

Method Description
.upsert(title, text, id?, tags?) Create or update a note
.list() List all notes → List[Note]
.get(id) Full note with related notes → NoteDetail
.search(query, limit?) Semantic search → List[Note]
.delete(id) Delete note and its chunks

MCP Integration

Connect Claude, GPT, Cursor, or any MCP-compatible LLM:

{
  "mcpServers": {
    "cube-memory": {
      "type": "http",
      "url": "https://cubememory.com.br/gateway/v1/mcp",
      "headers": {
        "Authorization": "Bearer cm_live_YOUR_KEY",
        "X-Project-Id": "proj_YOUR_PROJECT"
      }
    }
  }
}

Available MCP tools: search_memory, store_memory, list_memories, search_notes, get_note.


LangChain / Agent Integration

from cubememory import CubeClient

cube = CubeClient(base_url, api_key, project_id)

# Use as a LangChain retriever-style tool
def retrieve(query: str) -> list[str]:
    results = cube.index("knowledge-base").search(query, limit=5)
    return [r.text_preview for r in results]

# Agent memory tool
def remember(text: str) -> str:
    cube.memory.store(text)
    return f"Stored: {text[:60]}..."

def recall(query: str) -> str:
    results = cube.memory.search(query, limit=3)
    return "\n".join(r.text_preview for r in results)

Why Cube Memory?

Cube Memory pgvector / Pinecone / Qdrant
100% exact recall ✅ cosine float32 ❌ ANN approximation
Multi-tenant isolation ✅ island per project ⚠️ shared index with filters
MCP native ✅ built-in
Self-host (3 services) ✅ FastAPI + SQLite + Redis ❌ 10+ services
LGPD/GDPR ✅ data never leaves your server ❌ cloud by default

Links

Project details


Download files

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

Source Distribution

cubememory-0.1.1.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

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

cubememory-0.1.1-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file cubememory-0.1.1.tar.gz.

File metadata

  • Download URL: cubememory-0.1.1.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for cubememory-0.1.1.tar.gz
Algorithm Hash digest
SHA256 c6e943a8868bdc7b4dc29757341ab3c986ac9a9cb737ae7c0bc39988fe9998bf
MD5 0015266a1561763826d686dda494677a
BLAKE2b-256 2d978cdb84f31717c66eb8163dd84348009ff5196ee70ffd7345b1fb9327798d

See more details on using hashes here.

File details

Details for the file cubememory-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: cubememory-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for cubememory-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e566c5e5cc282f1a17d43efb0c32532618771a635e786ee49e6850f8f74aa06d
MD5 8f012acb4f96b9991e7b8d3b50008d2d
BLAKE2b-256 20fd81b05780a31ff13828591ade744c84ca8c2606e0450fecc77f2d985643b1

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 Pingdom Monitoring Sentry Error logging StatusPage Status page