Skip to main content

Semantic search MCP server for Claude Code sessions

Project description

deja

CI Python 3.10+ License: MIT MCP

Semantic search over your Claude Code session history. Ask questions about past conversations by meaning, not just keywords.

deja is an MCP server that indexes Claude Code JSONL sessions and provides hybrid search (vector + full-text) directly from Claude Code.

How it works

~/.claude/projects/*/        deja index         index.db
     *.jsonl           ──────────────►    (SQLite + vec + FTS5)
                        embeddings
                                           │
                                           │  deja serve (MCP stdio)
                                           ▼
                                      Claude Code
                                    "search past sessions"
  1. Index — parses JSONL session files, extracts conversation turns, embeds with multilingual-e5-small, stores in SQLite
  2. Serve — MCP server opens the index and answers search queries via stdio transport

Search combines vector KNN (semantic similarity) and FTS5 (keyword matching) via Reciprocal Rank Fusion.

Install

git clone https://github.com/CynepMyx/deja.git
cd deja
python -m venv .venv
.venv/Scripts/pip install -e .        # Windows
# .venv/bin/pip install -e .          # Linux/macOS

First run downloads the embedding model (~117 MB).

Usage

Build the index

deja index              # incremental — only new/changed files
deja index --reindex    # full rebuild

Scans all ~/.claude/projects/*/*.jsonl files.

Add to Claude Code

Add to ~/.claude.json under mcpServers:

"deja": {
    "type": "stdio",
    "command": "/path/to/deja/.venv/Scripts/deja.exe",
    "args": ["serve"],
    "env": {
        "PYTHONUNBUFFERED": "1"
    }
}

Restart Claude Code — deja will appear as a connected MCP server.

MCP Tools

Tool Description
search Hybrid semantic + keyword search across all sessions
get_session_chunks Get indexed chunks for a session (not raw messages)

search parameters:

  • query (string) — what to search for
  • limit (int, default 10) — max results
  • project (string, optional) — filter by project
  • date_from / date_to (string, optional) — ISO date range

Auto-indexing (optional)

Index automatically when a Claude Code session ends. Add a Stop hook to ~/.claude/settings.json:

"hooks": {
    "Stop": [
        {
            "matcher": "",
            "hooks": [
                {
                    "type": "command",
                    "command": "/path/to/deja/.venv/bin/deja index"
                }
            ]
        }
    ]
}

On Windows with Git Bash, wrap in a shell script:

#!/bin/bash
DEJA="/path/to/deja/.venv/Scripts/deja.exe"
[ -f "$DEJA" ] && "$DEJA" index >/dev/null 2>&1 &
"command": "bash /path/to/deja-index.sh"

PID lock prevents concurrent indexers — safe with multiple sessions.

Stack

  • fastembed — ONNX embeddings (intfloat/multilingual-e5-small, 384-dim)
  • sqlite-vec — vector KNN search in SQLite
  • SQLite FTS5 — full-text keyword search
  • FastMCP — MCP server framework

Performance

Metric Value
Incremental index < 30 sec
Search latency (warm) < 500 ms
First search (cold start) < 5 sec
RAM (search) ~150 MB
RAM (indexing) ~300 MB

Development

pip install -e ".[dev]"
pytest

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

dejasearch-0.3.0.tar.gz (21.8 kB view details)

Uploaded Source

Built Distribution

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

dejasearch-0.3.0-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

Details for the file dejasearch-0.3.0.tar.gz.

File metadata

  • Download URL: dejasearch-0.3.0.tar.gz
  • Upload date:
  • Size: 21.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for dejasearch-0.3.0.tar.gz
Algorithm Hash digest
SHA256 3ffd77e4cff7d6b89e3c02206930d9f3f7a59aa39839b8b77aa9e95216529858
MD5 8716c5c5e7f65aa1b4516d1ff4c50b09
BLAKE2b-256 90f98c39138983f1fb76153f5c4345e9478c635458909a7c715554e260814fc2

See more details on using hashes here.

File details

Details for the file dejasearch-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: dejasearch-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 18.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for dejasearch-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f55a68248ff82c8136103ae89cf0c857a281a5440c8f7b11f4a11fb1ce97ee19
MD5 eecf5e06f1ba6cc3832bbefd3540c45c
BLAKE2b-256 3d34b7e0a6009addc392a1b7b2ecd86d5a33b9b14e754ceef2d0e7809c7eff16

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