MCP server for swafra — Leiden-chunked, graph-linked semantic memory for Claude AI and ChatGPT
Project description
swafra
Leiden-chunked, graph-linked semantic memory as an MCP server — for Claude, Codex, and any MCP-compatible AI.
Install
pip install swafra
Attach to Claude Desktop
Add to ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"swafra": {
"command": "swafra"
}
}
}
Restart Claude Desktop — the tools appear automatically.
Attach to Claude Code
claude mcp add swafra swafra
Attach to VS Code (Copilot/Codex)
Add to .vscode/mcp.json in your project:
{
"servers": {
"swafra": {
"command": "swafra"
}
}
}
Tools
| Tool | Description |
|---|---|
add_knowledge |
Ingest text → Leiden chunk → embed → build knowledge graph |
search_knowledge |
Semantic vector search over stored knowledge |
graph_walk |
Traverse chunk edges from a starting point |
get_context |
Combined search + graph walk (recommended for retrieval) |
list_sources |
List all ingested knowledge sources |
delete_source |
Remove a source and its graph |
How It Works
-
Leiden Chunking — Text is split into sentences, a hybrid graph is built (semantic similarity + entity co-occurrence + positional proximity), and the Leiden algorithm finds topically coherent communities. Each community becomes one chunk.
-
Local Embeddings — Uses fastembed (ONNX, no cloud) with
BAAI/bge-small-en-v1.5(384-dim). Falls back to a deterministic hash-based embedder if fastembed is unavailable. -
Knowledge Graph — Chunks are connected with sequential edges (next/prev), similarity edges (cosine > 0.7), and community membership. Graph-walk retrieval traverses these edges for broader context.
-
Storage — JSON files in
~/.scimap/. No database required.
Environment Variables
| Variable | Default | Description |
|---|---|---|
SCIMAP_DATA_DIR |
~/.scimap |
Where knowledge is stored |
SCIMAP_EMBED_MODEL |
BAAI/bge-small-en-v1.5 |
Embedding model (fastembed) |
Requirements
- Python >= 3.10
- Dependencies installed automatically:
fastembed,igraph,leidenalg,numpy,mcp
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.2.tar.gz.
File metadata
- Download URL: swafra-0.1.2.tar.gz
- Upload date:
- Size: 15.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f95f7dd7fb05a91e4054350505148461d07a29c6e7c691159bedb67784d15bf4
|
|
| MD5 |
2a5f753cd46344e045d2c0f66f6b6adc
|
|
| BLAKE2b-256 |
4dc8b20e4c108471f34eb96c219ad3b33b9c9a7826eff6e4b321c4135447654d
|
File details
Details for the file swafra-0.1.2-py3-none-any.whl.
File metadata
- Download URL: swafra-0.1.2-py3-none-any.whl
- Upload date:
- Size: 15.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c4c7a3846daf49ace06aa4df1265473c7a68a1ac7c69457f8cc91dab81b6b98a
|
|
| MD5 |
91d8052b089ba0efd6e1f6712ffe05fd
|
|
| BLAKE2b-256 |
059668a8231d5ccd058ed36433d42cb2a7e5f923b987999414e6e6a3689b64f7
|