Persistent semantic memory for AI agents. Local-first, SQLite, embeddings.
Project description
spectrum-memory
Persistent semantic memory for AI agents — Python edition.
Give your AI memory that survives between sessions. Local-first. SQLite. Embeddings. Zero cloud dependency.
Install
pip install spectrum-memory
For semantic search (optional):
pip install spectrum-memory[semantic]
For MCP server (Claude, Gemini, Codex):
pip install spectrum-memory[mcp]
Everything:
pip install spectrum-memory[all]
Usage
As a library
from spectrum_memory import Spectrum, MemoryInput
memory = Spectrum()
# save
memory.save(MemoryInput(
scope="project:my-app",
key="architecture",
value="PostgreSQL for ACID. Redis for caching. Next.js 15 frontend.",
tags=["stack", "database"]
))
# retrieve
arch = memory.get("project:my-app", "architecture")
# keyword search
results = memory.search("database", scope="project:my-app")
# semantic search (finds by meaning, not just words)
similar = memory.search_semantic("which database did we choose?")
# list all memories in a scope
all_mems = memory.list("project:my-app")
# list all scopes
scopes = memory.list_scopes()
# done
memory.close()
CLI
spm save user/name "Claudio, backend dev, TypeScript strict"
spm save project:app/stack "Next.js 15, PostgreSQL, Redis"
spm get project:app/stack
spm search "database"
spm search "which database" --semantic
spm list project:app
spm scopes
spm stats
MCP Server
For Claude Code (~/.claude.json):
{
"mcpServers": {
"spectrum": {
"command": "spectrum-mcp-py"
}
}
}
Or with uvx:
{
"mcpServers": {
"spectrum": {
"command": "uvx",
"args": ["spectrum-memory[mcp]", "--", "spectrum-mcp-py"]
}
}
}
API
memory = Spectrum(
db_path=None, # default: ~/.spectrum/spectrum.db
storage=None, # custom StorageProvider
embeddings=None, # custom EmbeddingProvider
semantic=True, # False = no embeddings
)
| Method | Returns | Description |
|---|---|---|
save(input) |
Memory |
Upsert by scope+key |
get(scope, key) |
Memory | None |
Retrieve by key |
list(scope, opts?) |
list[Memory] |
List with optional prefix/limit |
delete(scope, key) |
bool |
Delete a memory |
search(query, scope?, limit?) |
list[SearchResult] |
Keyword search |
search_semantic(query, scope?, limit?, threshold?) |
list[SearchResult] |
Semantic search |
list_scopes() |
list[ScopeInfo] |
All scopes with count |
stats() |
Stats |
DB statistics |
close() |
None |
Close connection |
Shared Database
Python and Node.js Spectrum share the same SQLite database (~/.spectrum/spectrum.db). Save from Node, read from Python, and vice versa.
Ecosystem
| Package | What |
|---|---|
| spectrum-memory | Python library + CLI + MCP (you are here) |
| @natiwo/spectrum | Node.js core library |
| @natiwo/spectrum-cli | Node.js CLI (spm) |
| @natiwo/spectrum-mcp | Node.js MCP server |
License
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 Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file spectrum_memory-0.1.0.tar.gz.
File metadata
- Download URL: spectrum_memory-0.1.0.tar.gz
- Upload date:
- Size: 10.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
27be28846ffac38233fa3fd5cbcb14c728748108777dcf4c4e019c130a0537d4
|
|
| MD5 |
dc30776a44d72f3acdf679a8ef56193d
|
|
| BLAKE2b-256 |
fb4f670302e81220201e9ca55e201c284b2f96488731d83bf6f0f5c08098afe2
|
File details
Details for the file spectrum_memory-0.1.0-py3-none-any.whl.
File metadata
- Download URL: spectrum_memory-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd78720589af2e1ef09bc51ff373c2aaf42540339d432cdd5587a9cdf7de584b
|
|
| MD5 |
397208e92ecb0ec193790cb814cfe079
|
|
| BLAKE2b-256 |
86ea53073e3d68467de2e39680a28feb3eb0c165d761b5fde4a3216459e12cf8
|