thimiko

thimiko

Enables searching and retrieving local chat history from Codex and Claude CLI sessions via BM25 full-text search and MCP tools.

Category
Visit Server

README

thimiko — local chat-history memory

thimiko (θύμηση, Greek for "memory") normalizes the JSONL session history written by two different AI CLIs into one canonical model, indexes it for ranked full-text search, and serves it to a human or an LLM through an MCP server.

Source Location Envelope
Codex ~/.codex/sessions/**/*.jsonl uniform {timestamp, type, payload}; sub-type in payload.type
Claude Code ~/.claude/projects/**/*.jsonl flat records; nested object is message (role + content[] blocks), plus auxiliary types (file-history-snapshot, ai-title, mode, attachment, …)

See ARCHITECTURE.md for the layered design (sources -> models -> storage -> indexing -> search -> CLI/MCP) and how to extend any layer.

Setup

Install once as a uv tool; the thimiko executable is then on your PATH:

uv tool install "thimiko[mcp]"    # installs the `thimiko` exe (with MCP support)

To upgrade later: uv tool upgrade thimiko. For local development from a checkout, use an editable install: uv tool install -e ".[mcp]".

Usage

thimiko build                          # full rebuild (default index: %LOCALAPPDATA%\thimiko\thimiko.sqlite)
thimiko update                         # incremental: only new/changed files
thimiko update --prune                  # also drop sessions whose source file is gone
thimiko search "database migration"     # ranked BM25 search (JSON by default)
thimiko search "permission denied" --source codex --limit 5
thimiko search "rate limit" --days 10    # only turns from the last 10 days
thimiko search "..." --text             # human-readable output instead of JSON
thimiko mcp                            # MCP server over stdio (also the bare `thimiko` default)

Every subcommand accepts an explicit path list (files or directories) in place of the default source roots, plus --source {auto,codex,claude} to force a dialect instead of auto-detecting.

Reports (scripts/)

Standalone, stdlib-only reporting tools — not part of the indexed build/update/search path:

uv run python scripts/schema_analyzer.py --out reports\schema_report.md
uv run python scripts/schema_analyzer.py --json-out reports\schema.json
uv run python scripts/session_query.py "error" --out reports\query_report.md
uv run python scripts/session_query.py "rate limit" --regex --include-tools
uv run python scripts/normalize_sessions.py --out reports\canonical.jsonl

MCP server

thimiko mcp launches a read-only MCP server over stdio exposing:

  • search_chats(query, source=None, limit=10, days=None, raw_fts=False) — ranked BM25 search; returns a JSON envelope of enriched hits (title, source, model, relative when, cleaned snippet, path+line). days restricts to the last N days.
  • get_session(session_id) — a session's header plus all of its turns.
  • get_turn(session_id, turn_id, neighbors=1) — a turn's chunks plus neighboring turns.

Register it in .mcp.json pointing at thimiko mcp, or use the MCP inspector (mcp dev src/thimiko/mcp.py) during development.

Layout

src/thimiko/
├── models/      OOP domain: Session, Turn, Event (+ Message/ToolCall/ToolResult/Reasoning/Attachment)
├── sources/     ChatSource ABC + CodexSource/ClaudeSource adapters (pluggable)
├── storage/     Store ABC + SqliteStore (FTS5, pluggable)
├── indexing/    turn -> SearchDocument chunking + Indexer (build/update)
├── search/      Retriever ABC + KeywordRetriever (BM25, pluggable)
├── cli.py       build | update | search | mcp
├── mcp.py       MCP server (semble idiom)
├── utils.py     dialect sniffing, redaction, formatting (used by scripts/)
├── config.py    default data dir / DB path
└── types.py     SearchDocument / SearchResult
scripts/         standalone report generators (schema, regex search, canonical export)
tests/           pytest
data/            scratch dir for dev (gitignored); default index actually lives in %LOCALAPPDATA%\thimiko\ (override with THIMIKO_DATA_DIR)

Dialect-adapter design

Two methods abstract over the schemas, in thimiko.utils:

  • detect_source(record) sniffs one record: a payload object → codex; message/uuid → claude. sniff_file_source() reads the first lines of a file to give a stable source for the whole file, so auxiliary record types that lack per-record markers are still attributed correctly. Each ChatSource.matches() is built on this.
  • classify(record, source) flattens either schema into one Classification(source, top_type, sub_type, sub_keys, content_block_types), used by scripts/schema_analyzer.py.

To support a third source, implement ChatSource (see ARCHITECTURE.md) — nothing else needs to change.

Redaction

Example records embedded in the schema report are redacted: string values are reduced to <str len=… preview=…>, and fields whose names match SENSITIVE_NAME_PARTS (content, message, thinking, token, key, arguments, snapshot, …) are further masked. Raw conversation text is never written into the schema report.

Canonical model and search

Session/Event deliberately don't merge the complete provider schemas — they're append-only event logs with different duplication and grouping rules. Every Event points back to the exact source file and line via Provenance; the provider logs remain the lossless source of truth.

Only ordinary user/assistant messages are searchable. Bootstrap prompts, hidden reasoning, tool arguments/results, and attachments remain available for context but stay out of the default search corpus. Codex's duplicated display events are removed when authoritative response messages exist. Claude's fragmented content blocks remain in source order, and each tool_result links to its tool_call.

Search documents are built at the turn level, not per event: searchable events are concatenated with role labels, long turns are chunked, and each document keeps session_id, source, turn_id, cwd, git_branch, and a time range. KeywordRetriever ranks with SQLite FTS5/BM25 and can expand a winning chunk to its neighboring turns (get_turn/expand).

Why not Turso?

Turso Database (pyturso, formerly Limbo) does not support SQLite FTS5 (its own compatibility doc says "use Turso FTS instead") and is still experimental — adopting it would mean rewriting this project's entire FTS5/BM25 search onto an unrelated engine. libSQL (pip install libsql) is the viable "Turso" path if this ever needs cloud sync or native vector search: it's a SQLite fork that keeps FTS5. storage.Store is the swap point — see ARCHITECTURE.md.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured