history-archive
by Pescorr
README.md
# AI History Hub
**English** | [日本語](README_ja.md)
A local-first **unified conversation history archive**, **browser viewer GUI**, and **MCP search server** for multiple AI coding tools.
AI History Hub incrementally indexes conversation logs from Claude Code, Codex CLI, Antigravity CLI, Zoo Code, SyncStrata, and more into a single local SQLite database (`history/history.db`) **strictly read-only on your original logs** — so you can search and browse your entire cross-tool history from either the local web console or any MCP-compatible AI agent.
> **The GUI is optional — the MCP server works completely standalone.** You never have to leave or replace the AI tools you already love.

---
## Screenshots
Captured using synthetic dummy data (switch between 4 themes anytime from `COLOR` in the top-right bar).
### R4 AMBER (Full-text Search & Snippets)

### CREAM (Light Theme & Cross-Tool Viewer)

---
## Highlights
- **Non-invasive & read-only on source logs**: Never modifies or deletes original tool logs. Archived conversations remain searchable even if cleared inside the original app.
- **Fast incremental sync**: Uses file size + `mtime_ns` signatures so subsequent syncs only re-parse newly added or modified conversations.
- **Zero third-party dependencies for core features**: Both the viewer GUI (`gui/server.py`) and core history sync (`history/history_store.py`) run on **Python 3.11+ standard library only**.
- **Built-in stdio MCP server** (`history/server.py`): Exposes `search_history`, `list_conversations`, `read_conversation`, and `sync_history` to any MCP client.
- **R4-style local viewer GUI** (`gui/`): 4 themes (`DARK AMBER` / `R4 AMBER` / `CHARCOAL` / `CREAM`), instant full-text search (SQLite FTS5 trigram with automatic `LIKE` fallback), and one-click `SYNC` from the browser.
- **Cross-platform**: Windows / macOS / Linux.
---
## Supported History Sources
| Source key (`hub.json`) | Tool | Notes |
|---|---|---|
| `claude_code` | Claude Code | Reads `~/.claude/projects` |
| `codex` | Codex CLI | Reads `~/.codex/sessions` |
| `antigravity` | Antigravity CLI | Reads `~/.gemini/antigravity-cli` |
| `zoocode` | Zoo Code / Roo-compatible | Reads VS Code globalStorage `tasks` |
| `strata` | SyncStrata | Optional `zstandard` package required (skipped automatically if not installed) |
Any source whose directory does not exist on your machine is safely skipped.
---
## Requirements
- **Python 3.11+**
- Optional packages (`pip install -r requirements.txt` only if needed):
- `mcp>=1.0.0` — required only for running the MCP server (`history/server.py`)
- `zstandard>=0.22.0` — required only for importing SyncStrata (`.zstd`) logs
---
## Quick Start
### 1. Open the Local Viewer GUI
Download/extract this folder and launch the GUI for your OS. On first launch (empty archive), click **`⟳ SYNC`** in the top-right corner to import your local logs:
- **Windows**: Double-click `gui/open_gui.bat` (or run `python gui/server.py`)
- **macOS**: Double-click `gui/Open_GUI.command` (or run `bash gui/open_gui.sh`)
- **Linux**: Run `bash gui/open_gui.sh` (automatically prints the URL on headless machines)
CLI options:
```bash
python gui/server.py --port 8765 # Custom port (default: 8765)
python gui/server.py --no-open # Do not auto-open browser
python gui/server.py --no-sync # Disable SYNC button (strictly read-only server)
```
### 2. Sync via CLI (Without Opening the GUI)
- **Windows**: `history/sync_history.bat` (or `python history/history_store.py`)
- **macOS / Linux**: `bash history/sync_history.sh`
Quick CLI search test:
```bash
python history/history_store.py search "your keyword"
```
### 3. Use as an MCP Server (GUI Optional)
Install the MCP SDK once:
```bash
pip install mcp
```
Then register `history/server.py` in your preferred AI client.
*(On Windows, use forward slashes like `C:/path/to/ai-history-hub/history/server.py` or escaped backslashes `C:\\path\\to\\...` in JSON/TOML.)*
#### Claude Code
Via CLI:
```bash
claude mcp add history-archive -- python /path/to/ai-history-hub/history/server.py
```
Or in `~/.claude.json`:
```json
{
"mcpServers": {
"history-archive": {
"type": "stdio",
"command": "python",
"args": ["/path/to/ai-history-hub/history/server.py"]
}
}
}
```
#### Codex CLI (`~/.codex/config.toml`)
```toml
[mcp_servers.history-archive]
command = "python"
args = ["/path/to/ai-history-hub/history/server.py"]
# Optional: place history.db anywhere you like
# [mcp_servers.history-archive.env]
# AI_HISTORY_HUB_DB = "/path/to/history.db"
```
#### Antigravity CLI (`~/.gemini/config/mcp_config.json`)
```json
{
"mcpServers": {
"history-archive": {
"command": "python",
"args": ["/path/to/ai-history-hub/history/server.py"]
}
}
}
```
#### Claude Desktop / Cursor / Roo Code / Zoo Code (Generic `mcpServers` JSON)
```json
{
"mcpServers": {
"history-archive": {
"command": "python",
"args": ["/path/to/ai-history-hub/history/server.py"],
"env": {
"AI_HISTORY_HUB_DB": "/optional/path/to/history.db"
}
}
}
}
```
#### Exposed MCP Tools
- `search_history(query, source="", include_tools=True, limit=20)` — Full-text search across all archived conversations
- `list_conversations(source="", keyword="", limit=30)` — List recent conversations filtered by source or title/workspace keyword
- `read_conversation(conversation_id, offset=0, limit=40, include_tools=False)` — Read conversation messages page by page
- `sync_history()` — Run incremental log import into `history.db`
---
## Environment Variable Overrides
| Variable | Default | Purpose |
|---|---|---|
| `AI_HISTORY_HUB_DB` | `<folder>/history/history.db` | Override the SQLite database location (supports `~` and env expansion; parent folders are created automatically) |
| `AI_HISTORY_HUB_CONFIG` | `<folder>/hub.json` | Override the `hub.json` config path |
---
## Customizing `hub.json`
Edit `history_sources` in `hub.json` to toggle sources (`enabled`) or adjust paths.
Each entry resolves in order: **`env` -> `path_windows` / `path_macos` / `path_linux` -> `path`**. Missing directories are skipped without error.
---
## Security & Privacy
- The GUI server binds strictly to `127.0.0.1` (localhost only).
- `POST /api/sync` requires both the `X-Hub-Action: sync` header and a local `Origin` check to prevent cross-site triggers.
- `history/history.db` stores your personal conversation history — never upload or share it (excluded by `.gitignore`).
---
## License
MIT License — see [LICENSE](LICENSE) for details.
This server cannot be deployed
Maintenance
ActivityNo data
ResponsivenessOutdated data