claude-session-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@claude-session-mcpsearch for database schema discussions in my claude session history"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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-mcpThis creates an isolated environment and puts claude-session-mcp on your PATH. Update with:
uv tool upgrade claude-session-mcpAlternative: run without installing
uvx --from git+https://github.com/Gunther-Schulz/claude-session-mcp claude-session-mcpThis 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 JSONLCompact boundary stitching: System records with
logicalParentUuidare stitched back into the tree, reconnecting compacted conversationsFork 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
Available Tools
6 toolsget_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.
| Name | Required | Description | Default |
|---|---|---|---|
| project | No | ||
| fork_uuid | No | ||
| session_id | Yes |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the burden. It explains that fork points represent branchings from retries/edits and identifies primary vs. abandoned branches. However, it does not disclose potential side effects, required permissions, or output structure, though the tool appears read-only by name.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is concise, front-loaded with the main purpose, and includes a clear Args section. Every sentence serves a purpose without excessive verbosity.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the existence of an output schema, return value descriptions are unnecessary. The tool's purpose, branch behavior, and parameter roles are sufficiently described. Slight gap: no usage guidance relative to siblings, but that is covered under the usage dimension.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema has 0% description coverage, but the description provides meaningful explanations for all three parameters: session_id (UUID or prefix), project (optional slug), and fork_uuid (specific fork point or all). This fully compensates for the schema's lack of descriptions.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
Description clearly states 'Get fork points in a session with diverging branch details' with a specific verb and resource. It distinguishes from siblings by focusing on branch/fork history rather than session lists, trees, or threads.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Describes what the tool does and shows branch details, implying use when fork information is needed, but does not explicitly state when it should be used over alternatives or when to avoid it. No exclusion criteria or comparison to sibling tools like get_thread or get_tree.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
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.
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | ||
| offset | No | ||
| project | No | ||
| leaf_uuid | No | ||
| session_id | Yes | ||
| include_tool_calls | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full burden. It discloses useful behaviors: 'Only includes user and assistant messages', 'Supports pagination for long threads', and explains the include_tool_calls option. However, it does not explicitly state read-only safety, error handling, or whether messages are returned in chronological order (though 'root-to-leaf path' implies structural order).
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is well-structured with a front-loaded purpose, followed by behavioral notes and a clearly formatted Args list. It is appropriately sized given the need to document 6 parameters, and every sentence contributes value without redundancy.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The description covers the tool's core function, filtering behavior, pagination, and parameter semantics. Given an output schema exists (so return format is handled) and no annotations are provided, it includes enough context for an agent to select and invoke the tool, though it could add a note about sorting order or error cases.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, but the description's Args section thoroughly explains every parameter with added meaning: limit has 'max 200', offset is 'Skip first N messages', leaf_uuid 'Empty for the primary (latest) thread', session_id 'UUID (or prefix)', project 'Optional project slug', and include_tool_calls 'Show tool names used in assistant messages'.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states 'Get a conversation thread (root-to-leaf path through the tree)', providing a specific verb, resource, and scope. It distinguishes itself from sibling tools like get_tree (which likely returns the entire tree) by emphasizing 'root-to-leaf path' and 'Only includes user and assistant messages'.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies usage for retrieving a single conversation thread, with details like 'leaf_uuid empty for the primary (latest) thread'. However, it does not explicitly compare against alternatives such as get_tree or get_forks, or state when to prefer this tool over them.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
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.
| Name | Required | Description | Default |
|---|---|---|---|
| project | No | ||
| session_id | Yes |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the burden. It discloses meaningful behavioral details: the tool returns a tree with fork points, branch summaries, compaction boundaries, and leaf nodes, and session_id accepts a UUID or prefix. While it does not explicitly state it is read-only, the 'get' verb and structural focus strongly imply a safe, non-mutating operation.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is concise and well-structured. It leads with a clear purpose sentence, adds relevant details, includes usage guidance, and lists parameters in a clean format. Every sentence earns its place with no redundant content.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's moderate complexity (2 parameters, no enums) and the presence of an output schema, the description is complete. It explains what the tool shows, when to use it, and clarifies each parameter. The mention of 'before navigating with get_thread or get_forks' provides necessary context within the sibling toolset, and the output schema presumably covers return value structure.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema has no descriptions (0% coverage), but the description fully explains both parameters: 'session_id: Session UUID (or prefix)' and 'project: Optional project slug to narrow lookup.' This adds crucial format and purpose information beyond the schema, compensating entirely for the lack of schema descriptions.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose with a specific verb and resource: 'Get the conversation tree structure for a session.' It further distinguishes itself from sibling tools by listing what it shows (fork points, branch summaries, compaction boundaries, leaf nodes) and explicitly references get_thread and get_forks as navigation tools.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Provides explicit usage guidance: 'Use this to understand the structure before navigating with get_thread or get_forks.' This states when to use (before navigating) and names the alternative tools, making the decision boundary clear.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
list_projectsA
List all Claude Code projects that have session history.
Returns project slugs (derived from directory paths), session counts, and total size.
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the burden of disclosing behavior. It adds useful context (only projects with session history, return fields) beyond the tool name. However, it does not explicitly state that the operation is read-only, nor does it mention any potential limitations (e.g., pagination, permissions), which would be more important for tools with side effects. For a simple list, this is acceptable but not exhaustive.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is two sentences, front-loaded with the primary action, and includes only relevant details about return values. No filler or redundant phrases.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The tool is simple with no parameters and an output schema. The description explains what the tool returns and its filtering condition, which is complete for this level of complexity. The existence of an output schema covers detailed return structure, so the description doesn't need to enumerate every field.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The tool has zero parameters, so the schema already fully covers the inputs. The description adds nothing about parameters, but there is nothing to add. Per the rubric, a baseline of 4 applies for zero-parameter tools.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description begins with a specific verb ('List'), resource ('Claude Code projects'), and scope ('that have session history'). It also enumerates the return fields (slugs, session counts, total size), clearly distinguishing it from sibling tools like list_sessions or get_tree, which operate at different levels.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description gives clear context by specifying it lists projects with session history, which implicitly tells the agent when to use it (project-level overview). However, it does not explicitly mention alternatives or exclusions, so it falls short of a 5. The context is clear enough that no other tool would be mistaken for this one.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
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.
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | ||
| offset | No | ||
| project | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full burden for behavioral transparency. It discloses the sorting order and pagination behavior, but does not mention whether the operation is read-only, potential side effects, or error handling. It is adequate but not comprehensive.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is concise and well-structured, with a one-sentence purpose followed by a clear parameter list. Every line serves a purpose, and there is no redundant or unclear text.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a simple list operation, the description covers the purpose, ordering, and all parameters. The output schema documents return values. It lacks explicit mention of edge cases or when to use alternatives, but it is sufficiently complete for invocation.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema provides no parameter descriptions (0% coverage), but the description compensates fully by explaining each parameter's meaning: project slug filtering, limit for max results, and offset for pagination. It adds clear value beyond the schema's types and defaults.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states 'List sessions for a project, sorted by most recent first' with a specific verb and resource, and it distinguishes from sibling tools like list_projects by focusing on sessions. It could be more explicit about how sessions are defined, but the core purpose is clear.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies usage for listing sessions but does not explicitly state when to use this tool over alternatives like search or get_thread. There is no mention of exclusions or conditionals, making the usage guidance implicit rather than explicit.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
searchA
Full-text search across Claude Code session history.
Searches conversation text (user and assistant messages) with fork awareness. Returns matches with surrounding conversational context and branch info.
Args: query: Search text (case-insensitive substring match). project: Project slug to filter by. Empty for all projects. max_results: Maximum results (default 10, max 50). include_subagents: Also search subagent session files.
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | ||
| project | No | ||
| max_results | No | ||
| include_subagents | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full burden. It discloses case-insensitive substring matching, fork awareness, max result limits, optional subagent inclusion, and the return of surrounding conversational context and branch info. While it does not explicitly state read-only behavior, it is evident from 'search' that no side effects occur.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is concise: a one-line purpose, a sentence on scope/return value, and a clear Args list. No filler or repetition. It is front-loaded with the most important information and every sentence adds value.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The tool is moderately complex with four parameters and an output schema. The description covers search scope, return format, fork awareness, parameter behavior, and constraints (max 50 results). Since an output schema exists, not detailing return fields is appropriate. This is complete enough for an agent to invoke correctly.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema provides no property descriptions, but the description's Args section explains every parameter: query (search text, case-insensitive), project (filter, empty for all), max_results (default 10, max 50), and include_subagents (search subagent files). This fully compensates for the 0% schema coverage.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The opening sentence 'Full-text search across Claude Code session history' uses a specific verb (search) plus a clear resource (session history), and the description clarifies that it searches conversation text with fork awareness and returns context/branch info. This clearly distinguishes it from sibling tools that list projects/sessions or retrieve threads/trees.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description gives clear context: this is the tool for searching text across sessions, with optional filtering by project and subagents. It does not explicitly mention alternatives or when not to use it, but the context is unambiguous enough that an agent would use it for free-text search rather than listing or retrieval tasks.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
6 tool updates
v0.1.0- First observed
get_forks - First observed
get_thread - First observed
get_tree - First observed
list_projects - First observed
list_sessions - First observed
search
TDQS
Scored across 6 tools
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.
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.
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.
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.
Maintenance
Related MCP Connectors
Search your AI chat history (ChatGPT, Claude, Codex) from any MCP client. Remote, private, read-only
MCP server for querying Forkast documentation
Repository knowledge graph MCP server for codebase understanding and debugging.
Related MCP Servers
- AlicenseBqualityDmaintenanceMCP server that lets you search your Claude Code conversation history to find past solutions, track file changes, and learn from previous work.8157 npm178MIT
- AlicenseNot gradedqualityDmaintenanceA local MCP server that indexes and searches your Claude Code conversation history with both keyword and semantic search, fully private and running locally.MIT
- AlicenseNot gradedqualityBmaintenanceCapture, index, and search your Claude Code conversation history. Provides an MCP server for Claude Code to query its own past conversations.6 npm1MIT
- AlicenseAqualityBmaintenanceMCP server that indexes Claude.ai chats and local Claude Code sessions, enabling semantic and keyword search across all your conversations with Claude.66MIT