MCP Claude Code Conversation History
Enables Claude Code to search, browse, and read its own past conversation history across all projects using BM25 keyword search.
README
MCP Claude Code Conversation History
A Model Context Protocol (MCP) server that gives Claude Code access to its own conversation history. Search, browse, and read past conversations across all projects using BM25 keyword search.
Overview
Every Claude Code session starts fresh — you can't ask "what did we discuss about auth last week?" or "show me that refactoring conversation". Your conversation history sits in JSONL files on disk, invisible to Claude.
MCP Claude Code Conversation History indexes those files and exposes them through a single MCP tool, so Claude can search and read its own past conversations.
Key Features:
- BM25 Search - Keyword search with relevance ranking via MiniSearch
- Cross-Project - Search across all Claude Code projects at once
- Background Indexing - Server starts immediately, indexes in the background
- Zero Config - Reads directly from
~/.claude/projects/, no setup needed
Installation
Via npm (Recommended)
npm install -g mcp-claude-code-conversation-history
From Source
git clone https://github.com/Stefan-Nitu/mcp-claude-code-conversation-history.git
cd mcp-claude-code-conversation-history
bun install
bun run build
Requires Bun v1.3.8+ (development) and Node.js v20+ (runtime)
Add a CLAUDE.md hint
MCP tools are deferred (loaded on-demand), so Claude may not use them automatically. Add this to your project's CLAUDE.md to ensure it does:
## Conversation History
You have access to past conversation history via MCP. Always use it when the user asks about previous work, past sessions, or anything from a prior conversation.
Quick Start
With Claude Code
Add to ~/.claude.json:
{
"mcpServers": {
"mcp-claude-code-conversation-history": {
"command": "npx",
"args": ["-y", "mcp-claude-code-conversation-history"]
}
}
}
Or if installed globally:
{
"mcpServers": {
"mcp-claude-code-conversation-history": {
"command": "mcp-claude-code-conversation-history"
}
}
}
Restart Claude Code to pick up the new server.
With Claude Desktop
Add to your Claude Desktop configuration file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"mcp-claude-code-conversation-history": {
"command": "npx",
"args": ["-y", "mcp-claude-code-conversation-history"]
}
}
}
With MCP Inspector
Test the server interactively:
npx @modelcontextprotocol/inspector npx -y mcp-claude-code-conversation-history
Available Actions
The server exposes 1 tool (claude_code_conversation_history) with 4 actions:
| Action | Description | Required Params | Optional Params |
|---|---|---|---|
| stats | Overview of all conversations and projects | — | — |
| list | Browse conversations by project/date | — | project, after, before, limit |
| search | BM25 keyword search across all history | query |
project, limit |
| read | Read full conversation by session ID | session_id |
offset, limit |
Parameters Reference
| Parameter | Type | Description |
|---|---|---|
action |
string |
Required. One of: search, list, read, stats |
query |
string |
Search keywords (required for search) |
session_id |
string |
Session ID from search/list results (required for read) |
project |
string |
Filter by project name (partial match) |
after |
string |
Only show conversations after this ISO date |
before |
string |
Only show conversations before this ISO date |
limit |
number |
Maximum number of results |
offset |
number |
Skip first N messages (for read pagination) |
Example Usage
Get an overview
{ "action": "stats" }
Returns total conversations, messages, and per-project breakdown.
Browse recent conversations in a project
{ "action": "list", "project": "my-app", "limit": 5 }
Search for a topic
{ "action": "search", "query": "authentication migration", "limit": 5 }
Returns ranked results with matching message snippets.
Read a full conversation
{ "action": "read", "session_id": "abc-123-def", "limit": 20 }
Use session_id from search or list results. Supports pagination with offset/limit.
Response Format
All actions return structured JSON:
{
"action": "search",
"query": "auth",
"results": [
{
"sessionId": "abc-123",
"project": "-Users-me-Projects-my-app",
"cwd": "/Users/me/Projects/my-app",
"score": 42.5,
"matches": [
{
"type": "user",
"content": "fix the authentication bug...",
"timestamp": "2026-03-20T10:00:00.000Z"
}
]
}
]
}
How It Works
- On startup, reads Claude Code's JSONL conversation files from
~/.claude/projects/ - Parses user and assistant messages, filtering noise (thinking blocks, tool calls, system messages, meta content)
- Deduplicates streamed assistant messages
- Indexes all messages with MiniSearch (BM25 ranking)
- Server starts immediately — indexing happens in the background
- If called before indexing completes, returns progress status
Development
Project Structure
mcp-claude-code-conversation-history/
├── src/
│ ├── index.ts # MCP server entry point
│ ├── types.ts # Shared type definitions
│ ├── core/
│ │ ├── conversation-parser.ts # JSONL parsing and content extraction
│ │ ├── conversation-store.ts # Conversation discovery and loading
│ │ └── search-index.ts # BM25 search via MiniSearch
│ ├── tools/
│ │ ├── definitions.ts # Zod schema for tool parameters
│ │ └── handler.ts # Action routing and response formatting
│ └── utils/
│ └── logger.ts # Pino logger (stderr only)
├── tests/
│ ├── conversation-parser.test.ts
│ ├── conversation-store.test.ts
│ ├── search-index.test.ts
│ └── tools.test.ts
└── docs/ # Architecture & testing docs
Testing
# Run all tests
bun test
# Run in watch mode
bun test --watch
# Type checking
bun run typecheck
# Linting
bun run lint
# Full check (typecheck + lint)
bun run check
Requirements
- Node.js >= 20.0.0
- Claude Code conversation files in
~/.claude/projects/
Troubleshooting
Server Not Starting
If the tool doesn't appear in Claude Code:
- Check
~/.claude.jsonhas the correct MCP server configuration - Restart Claude Code after adding the configuration
- Check stderr logs for error messages
No Conversations Found
If stats shows 0 conversations:
- Verify
~/.claude/projects/exists and contains JSONL files - Check that you have Claude Code conversation history
- The server only indexes top-level JSONL files (subagent files are skipped)
Search Not Finding Expected Results
BM25 search works best with specific nouns and terms:
- Use specific keywords, not generic phrases
- Try different terms that might appear in the conversation
- Use the
projectfilter to narrow results - Check
listaction to confirm the conversation exists
Contributing
- Fork the repository
- Create a feature branch
- Write tests first (TDD approach)
- Implement the feature
- Ensure all tests pass (
bun test) - Run linting (
bun run lint) - Submit a pull request
License
MIT
Related Projects
- Model Context Protocol - MCP specification and documentation
- MCP TypeScript SDK - SDK used by this server
- MCP Refactor TypeScript - MCP server for TypeScript refactoring
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
mcp-server-qdrant
这个仓库展示了如何为向量搜索引擎 Qdrant 创建一个 MCP (Managed Control Plane) 服务器的示例。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器