Skip to main content
Glama
Stefan-Nitu

MCP Claude Code Conversation History

by Stefan-Nitu

NPM Version NPM Downloads CI Status MIT Licensed

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

Related MCP server: mcp-sessions

Installation

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

  1. On startup, reads Claude Code's JSONL conversation files from ~/.claude/projects/

  2. Parses user and assistant messages, filtering noise (thinking blocks, tool calls, system messages, meta content)

  3. Deduplicates streamed assistant messages

  4. Indexes all messages with MiniSearch (BM25 ranking)

  5. Server starts immediately — indexing happens in the background

  6. 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:

  1. Check ~/.claude.json has the correct MCP server configuration

  2. Restart Claude Code after adding the configuration

  3. Check stderr logs for error messages

No Conversations Found

If stats shows 0 conversations:

  1. Verify ~/.claude/projects/ exists and contains JSONL files

  2. Check that you have Claude Code conversation history

  3. 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:

  1. Use specific keywords, not generic phrases

  2. Try different terms that might appear in the conversation

  3. Use the project filter to narrow results

  4. Check list action to confirm the conversation exists

Contributing

  1. Fork the repository

  2. Create a feature branch

  3. Write tests first (TDD approach)

  4. Implement the feature

  5. Ensure all tests pass (bun test)

  6. Run linting (bun run lint)

  7. Submit a pull request

License

MIT

Available Tools

1 tool
claude_code_conversation_historyA

Search across ALL past Claude Code conversations, not just the current one.

vs git log/memory: This searches actual conversation content across every project and session. Git log only shows commits, memory only stores what was explicitly saved.

Use when: User asks about past work, previous sessions, "what did we do", "remember when", or anything from a different Claude Code conversation. Always use this first, not git log.

Actions:

  • stats: Overview of all conversations and projects

  • list: Browse by project/date (optional: project, after, before, limit)

  • search: BM25 keyword search (requires: query, optional: project, limit)

  • read: Read conversation (requires: session_id). Browse mode: paginate with offset/limit, messages truncated to 500 chars with contentLength. Focus mode: use limit=1 for full content. Grep mode: pass query to find matching messages with ±2 surrounding context.

ParametersJSON Schema
NameRequiredDescriptionDefault
afterNoOnly show conversations after this ISO date
limitNoMaximum number of results
queryNoSearch keywords (required for search, optional for read to grep within a conversation)
actionYes
beforeNoOnly show conversations before this ISO date
offsetNoSkip first N messages (for read)
projectNoFilter by project name (partial match)
session_idNoSession ID from search/list results (required for read)

TDQS

A4.9/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description fully carries the behavioral burden. It reveals key behaviors: global search scope, BM25 keyword search, message truncation to 500 chars with contentLength, and distinct modes (browse/focus/grep) with their pagination and filtering semantics. This goes far beyond the schema.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured: it opens with the core purpose, then contrasts with alternatives, gives concrete use cases, and breaks down each action with its parameters and modes. Every sentence provides useful information, avoiding redundancy or fluff.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description covers all actions, their required and optional parameters, and special modes, making it highly usable. However, since there is no output schema, it does not fully describe the return structure for stats/list results, leaving a minor gap in expected output understanding.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Despite 88% schema coverage, the description adds contextual meaning that the schema lacks, such as 'search requires query', 'read requires session_id', and how offset/limit interact in browse mode or how limit=1 enables focus mode. This explains parameter combinations and conditional usage effectively.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Search across ALL past Claude Code conversations, not just the current one.' This uses a specific verb (Search) and resource (conversations), and immediately distinguishes it from the current conversation and from alternatives like git log and memory.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description includes a dedicated 'Use when:' section that lists concrete triggers ('User asks about past work, previous sessions, "what did we do", "remember when"'), and explicitly states 'Always use this first, not git log,' providing clear when-to-use and when-not-to-use guidance.

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. Dates show when Glama detected each change.

  1. 1 tool updatev0.2.2
    • First observedclaude_code_conversation_history

TDQS

A4.9/5.0
Disambiguation5/5

Only one tool exists, so there is no possibility of confusing it with another tool. The tool's single purpose is clearly defined as searching across all Claude Code conversations.

Naming Consistency5/5

With only one tool, there is no inconsistent naming convention. The name 'claude_code_conversation_history' is descriptive and follows a clear pattern, making it easy for an agent to understand its purpose.

Tool Count4/5

The tool count of one is slightly below the typical range, but this single tool is well-designed with multiple internal actions (stats, list, search, read) that cover the full scope of conversation history access, so it does not feel thin or under-provisioned.

Completeness5/5

The tool provides comprehensive coverage for its domain: stats for overview, list for browsing, search for finding specific content, and read for detailed retrieval. This covers the essential lifecycle of conversation history access without obvious gaps.

Maintenance

ActivityInactive
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    C
    maintenance
    Enables searching and retrieving Claude Code conversation history via hybrid semantic and keyword search, allowing the agent to access its own past interactions.
    4
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables searching and browsing past Claude Code conversations directly from within an active Claude session, with full-text search and cost tracking.
    MIT

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Stefan-Nitu/mcp-claude-code-conversation-history'

If you have feedback or need assistance with the MCP directory API, please join our Discord server