claude-session-mcp

claude-session-mcp

Fork-aware MCP server for searching and navigating Claude Code session history.

Category
Visit Server

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 → Record and parentUuid → [child UUIDs] indexes from JSONL
  • Compact boundary stitching: System records with logicalParentUuid are 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_sessions avoids 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

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
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

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