Skip to main content

Semantic search MCP server for Claude Code sessions

Project description

deja

CI PyPI Python License: MIT MCP

Semantic search over your AI coding agent session history. Ask questions about past conversations by meaning, not just keywords.

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

Supported sources

Source Path Status
Claude Code ~/.claude/projects/*/*.jsonl Supported
Codex CLI ~/.codex/sessions/YYYY/MM/DD/*.jsonl Supported (v0.4+)
Cursor / Gemini / OpenCode Planned (#8)

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

pip install dejasearch

Or from source:

git clone https://github.com/CynepMyx/deja.git
cd deja
pip install -e .

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

Usage

Build the index

deja index                       # incremental, all sources
deja index --reindex             # full rebuild
deja index --source claude-code  # only Claude Code sessions
deja index --source codex        # only Codex CLI sessions

Scans every supported source by default. Filter with --source.

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_context Get a chunk with surrounding turns (±window)
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
  • source (string, optional) — filter by source: claude-code, codex
  • 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.5.0.tar.gz (38.5 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.5.0-py3-none-any.whl (27.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dejasearch-0.5.0.tar.gz
  • Upload date:
  • Size: 38.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for dejasearch-0.5.0.tar.gz
Algorithm Hash digest
SHA256 7f457e1c4ac1bab49cbf13ea029c9629ee0a3e67e24bd4c0454ef315b26235db
MD5 838335fee0f0079d19e7b9397f07b98b
BLAKE2b-256 693c0cdc67f82f7acd9aad14947ae37ee4b75b817053dc1a380bbddbb3fada29

See more details on using hashes here.

Provenance

The following attestation bundles were made for dejasearch-0.5.0.tar.gz:

Publisher: release.yml on CynepMyx/deja

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: dejasearch-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 27.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for dejasearch-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d8a0225fa0f8f180e18addbe7919e13558364e1d7f7f68e19ee17b1a0b16ceef
MD5 c0d4dc51e4f9962c4f2b14deaf5f05a9
BLAKE2b-256 9e42b1f2bd0c74d72a2b48dbb5e0dda9547b7487e7f970136a4aa3712fa62383

See more details on using hashes here.

Provenance

The following attestation bundles were made for dejasearch-0.5.0-py3-none-any.whl:

Publisher: release.yml on CynepMyx/deja

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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