spectrum-mcp-py
by Natiwo
README.md
<div align="center">
# 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.
[](https://pypi.org/project/spectrum-memory/)
[](https://github.com/Natiwo/spectrum/blob/main/LICENSE)
</div>
---
## Install
```bash
pip install spectrum-memory
```
For semantic search (optional):
```bash
pip install spectrum-memory[semantic]
```
For MCP server (Claude, Gemini, Codex):
```bash
pip install spectrum-memory[mcp]
```
Everything:
```bash
pip install spectrum-memory[all]
```
**Setting up with an AI agent?** Point it at [AGENT.md](AGENT.md) — a step-by-step playbook the agent follows to install Spectrum, register the MCP server, and teach itself how to use persistent memory.
## Usage
### As a library
```python
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
```bash
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`):
```json
{
"mcpServers": {
"spectrum": {
"command": "spectrum-mcp-py"
}
}
}
```
Or with uvx:
```json
{
"mcpServers": {
"spectrum": {
"command": "uvx",
"args": ["spectrum-memory[mcp]", "--", "spectrum-mcp-py"]
}
}
}
```
## API
```python
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](https://www.npmjs.com/package/@natiwo/spectrum) | Node.js core library |
| [@natiwo/spectrum-cli](https://www.npmjs.com/package/@natiwo/spectrum-cli) | Node.js CLI (`spm`) |
| [@natiwo/spectrum-mcp](https://www.npmjs.com/package/@natiwo/spectrum-mcp) | Node.js MCP server |
## License
[MIT](https://github.com/Natiwo/spectrum/blob/main/LICENSE)
This server cannot be deployed
Maintenance
ActivityInactive
ResponsivenessNo recent community issues