Leiden-chunked, graph-linked semantic memory as an MCP server for Claude, Copilot, and any MCP-compatible AI
Project description
swafra
Semantic memory for AI — ingest anything, retrieve what matters.
94.7% recall_all@10 on LongMemEval — the standard benchmark for long-term memory in AI assistants.
Works as an MCP server with Claude Desktop, Claude Code, VS Code Copilot, and any MCP-compatible AI.
Install
pip install swafra
Or with Node.js:
npm install -g swafra
Connect to Claude Desktop
Add to ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"swafra": {
"command": "swafra"
}
}
}
Restart Claude Desktop — the tools appear automatically.
Connect to Claude Code
claude mcp add swafra swafra
Connect to VS Code (Copilot)
Add to .vscode/mcp.json in your project:
{
"servers": {
"swafra": {
"command": "swafra"
}
}
}
What you can do
Once connected, Claude can use swafra to remember and retrieve anything:
"Remember this meeting transcript: ..."
"What did we decide about the API design?"
"What are my editor preferences?"
"Forget everything from the project X sessions"
Tools
| Tool | What it does |
|---|---|
add_knowledge |
Store text — chunked, embedded, and graph-linked |
search_knowledge |
Find relevant chunks by natural language query |
get_context |
Search + graph walk combined (recommended) |
graph_walk |
Explore connected chunks from a starting point |
list_sources |
See everything stored |
delete_source |
Remove a source and all its data |
How it works
1. Chunking Text is split into semantically coherent chunks using Leiden community detection — a graph algorithm that groups sentences by topic. Falls back to conversation-aware chunking if Leiden deps aren't available (Python 3.13+).
2. Local embeddings
Uses fastembed (ONNX, CPU-only, no API key) with BAAI/bge-small-en-v1.5. Falls back to deterministic hash vectors if fastembed isn't installed.
3. Hybrid retrieval 4-signal fused scoring: BM25 + vector cosine + entity/date overlap + character n-gram. Returns the best chunk per source so you get diverse, non-redundant context.
4. Knowledge graph Chunks are connected with sequential (next/prev), similarity, and entity co-occurrence edges. Graph walk expands retrieval beyond what search alone finds.
5. Storage
JSON files in ~/.scimap/. No database, no server, no cloud.
Benchmark
94.7% recall_all@10 on LongMemEval-S — 500 questions across 6 categories, 53 sessions each.
| Category | recall_all@10 |
|---|---|
| knowledge-update | 100.0% |
| single-session-user | 100.0% |
| single-session-preference | 100.0% |
| single-session-assistant | 100.0% |
| temporal-reasoning | 99.2% |
| multi-session | 93.3% |
Full benchmark details and reproduction steps →
Environment variables
| Variable | Default | Description |
|---|---|---|
SCIMAP_DATA_DIR |
~/.scimap |
Where knowledge is stored |
SCIMAP_EMBED_MODEL |
BAAI/bge-small-en-v1.5 |
Embedding model |
License
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
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 swafra-0.1.5.tar.gz.
File metadata
- Download URL: swafra-0.1.5.tar.gz
- Upload date:
- Size: 22.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
842bf1e90aa6b4172489b6ee20ddcd6dd249e95e0a703180e07861338fd1ea7e
|
|
| MD5 |
193e394d55b7e71781107eea58663817
|
|
| BLAKE2b-256 |
7220cd16600a15aa1a98d94d2594eaf61a8e43d22ba633da2b728ee9a953883e
|
File details
Details for the file swafra-0.1.5-py3-none-any.whl.
File metadata
- Download URL: swafra-0.1.5-py3-none-any.whl
- Upload date:
- Size: 15.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
236fa7077f83e03e1c145f8456d0c9fe5888e1aaad79b3fcb8d3c06e408bde49
|
|
| MD5 |
5f7631f2a981744a35c8926b77e0ad1a
|
|
| BLAKE2b-256 |
d649399532768e890cc73728b4ec87d43516a6b8d720d12ad9d6b07ee288d284
|