Skip to main content

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.

PyPI License: MIT


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

MIT

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

spectrum_memory-0.1.0.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

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

spectrum_memory-0.1.0-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

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

Hashes for spectrum_memory-0.1.0.tar.gz
Algorithm Hash digest
SHA256 27be28846ffac38233fa3fd5cbcb14c728748108777dcf4c4e019c130a0537d4
MD5 dc30776a44d72f3acdf679a8ef56193d
BLAKE2b-256 fb4f670302e81220201e9ca55e201c284b2f96488731d83bf6f0f5c08098afe2

See more details on using hashes here.

File details

Details for the file spectrum_memory-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for spectrum_memory-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dd78720589af2e1ef09bc51ff373c2aaf42540339d432cdd5587a9cdf7de584b
MD5 397208e92ecb0ec193790cb814cfe079
BLAKE2b-256 86ea53073e3d68467de2e39680a28feb3eb0c165d761b5fde4a3216459e12cf8

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