Skip to main content
Glama
claude-session-mcp

claude-session-mcp

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.

Related MCP server: conversation-history-mcp

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

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

Available Tools

6 tools
get_forksA

Get fork points in a session with diverging branch details.

Shows where conversations branched (retries, edits) and which branch the user continued with (primary) vs abandoned.

Args: session_id: Session UUID (or prefix). project: Optional project slug. fork_uuid: Show only this specific fork point. Empty for all forks.

Inputs: session_id (required), project, fork_uuid. Returns: result

get_threadA

Get a conversation thread (root-to-leaf path through the tree).

Only includes user and assistant messages. Supports pagination for long threads.

Args: session_id: Session UUID (or prefix). leaf_uuid: UUID of the leaf node. Empty for the primary (latest) thread. project: Optional project slug. offset: Skip first N messages for pagination. limit: Max messages to return (default 50, max 200). include_tool_calls: Show tool names used in assistant messages.

Inputs: session_id (required), limit, offset, project, +2 more. Returns: result

get_treeA

Get the conversation tree structure for a session.

Shows fork points, branch summaries, compaction boundaries, and leaf nodes. Use this to understand the structure before navigating with get_thread or get_forks.

Args: session_id: Session UUID (or prefix). project: Optional project slug to narrow lookup.

Inputs: session_id (required), project. Returns: result

list_projectsA

List all Claude Code projects that have session history.

Returns project slugs (derived from directory paths), session counts, and total size.

Inputs: no named parameters. Returns: result

list_sessionsA

List sessions for a project, sorted by most recent first.

Args: project: Project slug to filter by. Empty for all projects. limit: Maximum sessions to return (default 20). offset: Skip first N sessions for pagination.

Inputs: limit, offset, project. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.3/5.0

    Scored across 6 tools

    Disambiguation5/5

    Each tool has a clearly distinct focus: listing projects, listing sessions, full-text search, tree structure, thread retrieval, and fork details. get_tree and get_forks are complementary per the descriptions, with get_tree explicitly positioned as a precursor to get_thread and get_forks. No two tools appear to perform the same action.

    Naming Consistency4/5

    Names follow a predictable verb_noun pattern for most tools (list_projects, list_sessions, get_tree, get_thread, get_forks). The 'search' tool deviates by lacking an explicit object, but this is minor and does not cause confusion. Overall, the naming is readable and consistent in style.

    Tool Count5/5

    Six tools is well within the ideal range for a focused session-history viewer. Each tool covers a necessary aspect of the domain without redundancy or bloat. The count feels appropriately scoped for the server's purpose.

    Completeness5/5

    The tool surface covers the full read-only lifecycle of exploring session history: discover projects, list sessions, search across content, inspect the conversation tree, retrieve specific threads, and analyze forks. No obvious gaps are apparent for the stated purpose.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Capture, index, and search your Claude Code conversation history. Provides an MCP server for Claude Code to query its own past conversations.
      1
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      MCP server that indexes Claude.ai chats and local Claude Code sessions, enabling semantic and keyword search across all your conversations with Claude.
      6
      53 PyPI
      5
      MIT