cortex-memory-client
Python client SDK for the Cortex graph memory engine. The distribution is named cortex-memory-client; the import package remains cortex_memory.
Installation
pip install cortex-memory-client
Quick start
from cortex_memory import Cortex
# Connect to a running server
with Cortex("localhost:9090") as cx:
# Store knowledge
node_id = cx.store(
"decision",
"Use FastAPI for the backend",
body="Chose FastAPI over Flask for async support and type hints",
tags=["backend", "python"],
importance=0.8,
)
# Semantic search
results = cx.search("backend technology choices", limit=5)
for r in results:
print(f"{r.score:.2f} — {r.title}")
# Get a briefing
briefing = cx.briefing("my-agent")
print(briefing) # Ready-to-inject markdown
Library mode (embedded server)
cx = Cortex.open("./memory.redb")
# Works identically — starts a local server subprocess
Testing
from cortex_memory.testing import mock_cortex
def test_my_agent():
with mock_cortex() as cx:
cx.store("fact", "test data")
results = cx.search("test")
assert len(results) == 1
cx.assert_stored("fact", "test data")
pytest fixture
import pytest
from cortex_memory.testing import mock_cortex
@pytest.fixture
def cortex():
with mock_cortex() as cx:
yield cx
def test_store_and_search(cortex):
cortex.store("decision", "Use FastAPI", body="Async support", importance=0.8)
results = cortex.search("FastAPI")
assert results[0].title == "Use FastAPI"
Proto generation
The cortex_pb2.py and cortex_pb2_grpc.py stubs are pre-generated from
crates/cortex-proto/proto/cortex.proto. To regenerate after a proto change:
pip install grpcio-tools
./scripts/generate_protos.sh
Metadata
Release files for cortex-memory-client 0.3.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| cortex_memory_client-0.3.2.tar.gz | 16.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cortex_memory_client-0.3.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 32.6 kB
Release files / cortex_memory_client-0.3.2.tar.gz
| Download URL | cortex_memory_client-0.3.2.tar.gz |
|---|---|
| Size | 16.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fc842836f3d8d0329a4164cb7360c914f92b9d88a20111e3427228dece2c16b8
|
|
BLAKE2b-256 checksum How to use checksums |
fc49a40776a5b4ba30d300543a4d0c8c9d9f9af55a705b00548965da042761a4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.13
|
Release files / cortex_memory_client-0.3.2-py3-none-any.whl
| Download URL | cortex_memory_client-0.3.2-py3-none-any.whl |
|---|---|
| Size | 16.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4e79aba8a954b78ed7198c0f4d1b2fa140cadd28f2cd298c5ba15739d59b45fb
|
|
BLAKE2b-256 checksum How to use checksums |
720a075002a28dca6a7ca59a29afd144235d61fe827a38e5ff03011124b55e8c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.13
|