Skip to main content

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.

94% recall on LongMemEval — the standard benchmark for long-term memory in AI assistants.

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

  1. 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.

  2. 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.

  3. 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.

  4. 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

MIT — github.com/kunal12203/swafra

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

swafra-0.1.3.tar.gz (15.8 kB view details)

Uploaded Source

Built Distribution

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

swafra-0.1.3-py3-none-any.whl (15.1 kB view details)

Uploaded Python 3

File details

Details for the file swafra-0.1.3.tar.gz.

File metadata

  • Download URL: swafra-0.1.3.tar.gz
  • Upload date:
  • Size: 15.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for swafra-0.1.3.tar.gz
Algorithm Hash digest
SHA256 9c2be295af12aa960aa9ae4f5a61cc84673eac26ea7cddd9b3416c1e38c3ac24
MD5 b74c9dc53f8ce1f162dca1bdba8293a2
BLAKE2b-256 f5dd2af3878c5771995f328008a4c0e0438d32f2e9c00f5be4c6384206dbabf9

See more details on using hashes here.

File details

Details for the file swafra-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: swafra-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 15.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for swafra-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ca56f6d5e8cf13cbbf75c3dc18d43a40b975fb36530b80effae656c904acea52
MD5 3a9891629d1d7f7bd2e0966caa1d4193
BLAKE2b-256 63b5407fcec09f0a5eb9c6f076bd3572701ba97c09466a7d5313b5d88c003386

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