claude-session-mcp
Fork-aware MCP server for searching and navigating Claude Code session history.
README
claude-session-mcp
Fork-aware MCP server for searching and navigating Claude Code session history.
Why fork-aware?
Claude Code stores session history as JSONL files in ~/.claude/projects/. These files are trees, not linear logs. Each record has a uuid and parentUuid — when a user retries or edits a prompt, two records share the same parent, creating a fork. Most tools ignore this and treat sessions as flat logs, giving incorrect results.
This server correctly parses the tree structure, detects forks, identifies primary vs abandoned branches, and stitches compaction boundaries back together.
Installation
Requires uv (available via most package managers, e.g. pacman -S uv on Arch/CachyOS, brew install uv on macOS).
Install from GitHub
uv tool install git+https://github.com/Gunther-Schulz/claude-session-mcp
This creates an isolated environment and puts claude-session-mcp on your PATH. Update with:
uv tool upgrade claude-session-mcp
Alternative: run without installing
uvx --from git+https://github.com/Gunther-Schulz/claude-session-mcp claude-session-mcp
This resolves dependencies on each launch (slower startup, but no install step).
Configuration
Add to ~/.claude/.mcp.json (global) or .mcp.json in your project root (per-project):
{
"mcpServers": {
"session-search": {
"command": "claude-session-mcp"
}
}
}
If claude-session-mcp is not on your PATH (e.g. ~/.local/bin isn't in the base PATH), use the full path instead:
{
"mcpServers": {
"session-search": {
"command": "/home/your-user/.local/bin/claude-session-mcp"
}
}
}
Then use the tools from within Claude Code conversations.
Tools
list_projects
List all Claude Code projects with session counts and sizes.
list_sessions
List sessions for a project (or all projects), sorted by most recent first. Shows record count, date range, and subagent count. Supports pagination.
Params: project, limit, offset
search
Full-text search across session history. Returns matches with 2 ancestor messages for conversational context, and indicates whether each match is on the primary branch or an abandoned fork.
Params: query, project, max_results, include_subagents
get_tree
Get the conversation tree structure for a session: fork points, branch summaries, compaction boundaries, and leaf nodes. Use this to understand session structure before navigating.
Params: session_id, project
get_thread
Get a specific conversation thread (root-to-leaf path). Filters to user/assistant messages only. Supports pagination for long threads. Empty leaf_uuid returns the primary thread.
Params: session_id, leaf_uuid, project, offset, limit, include_tool_calls
get_forks
Get fork point details with diverging branches. Shows which branch the user continued with (primary) vs abandoned, with descendant counts and preview text.
Params: session_id, project, fork_uuid
How it works
- Tree parsing: Builds
uuid → RecordandparentUuid → [child UUIDs]indexes from JSONL - Compact boundary stitching: System records with
logicalParentUuidare stitched back into the tree, reconnecting compacted conversations - Fork detection: A parent with 2+ meaningful children (user/assistant type) is a fork point
- Primary branch: At each fork, the child with the latest timestamp is the user's final choice
- Lazy loading: Session files are only parsed when a tool needs the data
- Lightweight metadata:
list_sessionsavoids full JSON parsing for speed
Acknowledgements
The core insight that Claude Code session files are trees (not linear logs) comes from claude-session-tools by aurora-thesean. That project's clear documentation of the parentUuid tree structure and fork semantics informed the design of this MCP server. Our implementation adds compact boundary stitching, primary branch detection, lazy loading, and the MCP interface, but the foundational understanding of the data model originated there.
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。