Skip to main content
Glama
chatlab-mcp

chatlab-mcp

by gamesme

chatlab-mcp

English | 简体中文 | 繁體中文 | 日本語

MCP server that connects ChatLab to AI assistants (Claude Desktop, Cursor, custom agents). Query your local chat history with natural language.

Tracks ChatLab v0.19.0

Requirements

  • ChatLab installed and running

  • API enabled in ChatLab Settings → API, with a token generated

  • Node.js 18+

Related MCP server: mcp-copilotcli-history

Installation

No installation needed. Configure your AI client directly:

{
  "mcpServers": {
    "chatlab": {
      "command": "npx",
      "args": ["-y", "chatlab-mcp"],
      "env": {
        "CHATLAB_TOKEN": "clb_xxxxxxxxxxxx",
        "CHATLAB_URL": "http://127.0.0.1:5200"
      }
    }
  }
}

From source

git clone https://github.com/gamesme/chatlab-mcp
cd chatlab-mcp
npm install && npm run build

Claude Desktop

Edit ~/Library/Application Support/Claude/claude_desktop_config.json:

With npx:

{
  "mcpServers": {
    "chatlab": {
      "command": "npx",
      "args": ["-y", "chatlab-mcp"],
      "env": {
        "CHATLAB_TOKEN": "clb_xxxxxxxxxxxx",
        "CHATLAB_URL": "http://127.0.0.1:5200"
      }
    }
  }
}

From source (use your Homebrew node to avoid version issues):

{
  "mcpServers": {
    "chatlab": {
      "command": "/opt/homebrew/bin/node",
      "args": ["/absolute/path/to/chatlab-mcp/dist/index.js"],
      "env": {
        "CHATLAB_TOKEN": "clb_xxxxxxxxxxxx",
        "CHATLAB_URL": "http://127.0.0.1:5200"
      }
    }
  }
}

Restart Claude Desktop after saving. The chatlab tools will appear in the tools list.

Tools

Core (6)

Tool

Description

list_sessions

List all imported chat sessions with name, platform, and message count

get_session

Get details of a single session by ID

get_messages

Retrieve messages with filters: keyword, time range, sender, pagination (max 100/call)

get_members

List all members in a session with their platformId and message count

get_stats_overview

Statistical overview: message counts, member activity, type distribution, time range

execute_sql

Run aggregation queries (COUNT/GROUP BY) against the session database

Analytics (v0.19.0+, 9)

Tool

Description

get_message_context

N messages before/after one or more target message IDs

get_conversation_between

Interleaved messages between two specific members (numeric IDs)

get_session_summaries

AI-generated chat sub-session summaries (from the chat_session table)

deep_search_messages

FTS5 keyword search with surrounding context window

get_time_stats

Hourly / weekday / daily distribution, timezone-aware

get_member_activity

Top-N members by message count with percentage of total

get_member_name_history

Historical account name / nickname entries for a member

get_response_time_analysis

Reply intervals between sender pairs (LAG window function)

keyword_frequency

Stub — returns guidance (NLP segmentation not bundled in MCP)

Notes

  • get_messages returns at most 100 messages per call. Use the page parameter to paginate. Responses include has_more and a hint when more results exist.

  • execute_sql is for statistical aggregation only. Use get_messages or get_message_context to read message content.

  • Analytics tools issue their own SQL through the same /sql endpoint (no 200-row LIMIT injection).

  • All avatar/binary fields are stripped from responses to minimize context usage.

CLI Options

node dist/index.js --token <token> --url <url>
# or via env vars
CHATLAB_TOKEN=clb_xxx CHATLAB_URL=http://127.0.0.1:5200 node dist/index.js

CHATLAB_URL defaults to http://127.0.0.1:5200.

Development

npm test             # run all tests
npm run test:watch   # watch mode
npm run dev          # run with ts-node (no build step)
npm run build        # compile TypeScript → dist/

Available Tools

17 tools
deep_search_messagesA

Full-text search messages via FTS5, then expand each hit with surrounding context messages. Use for "did anyone mention X" style queries where conversation context matters.

Inputs: session_id (required), keywords (required), sender_id, start_time, +6 more.

execute_sqlA

For statistical aggregation ONLY (COUNT, GROUP BY, SUM, AVG). Do NOT use to fetch message content — use get_messages for that. Max 200 rows returned. Available tables: message, member.

Inputs: session_id (required), query (required).

get_conversation_betweenA

Get messages between two specific members (interleaved by time). Use when the user asks "what did A and B talk about". Members must be referenced by their numeric DB id; call get_members first to look them up.

Inputs: session_id (required), member_id_1 (required), member_id_2 (required), start_time, +4 more.

get_conversation_textA

Get conversation in plain text format with filtering and compression. Returns compact text optimized for LLM context (saves tokens vs JSON).

Inputs: session_id (required), start_time, end_time, sender_id, +3 more.

get_full_conversationA

Get full conversation across multiple pages, returns compact text format. Use for small to medium sessions only.

Inputs: session_id (required), max_total_messages, merge_consecutive, filter_invalid.

get_member_activityA

Top members ranked by message count with percentage of total. Use for "who talks the most" or "most active members" type questions. Supports top_n and time filters.

Inputs: session_id (required), top_n, start_time, end_time, +1 more.

get_member_name_historyA

Get the historical name changes (account name, nickname) for a single member. Useful for tracking identity changes over time.

Inputs: session_id (required), member_id (required), format, timezone.

get_membersA

Lists all members in a session with their platformId, name, and role. Returns plain text by default (set format=json for JSON).

Inputs: session_id (required), format.

get_message_contextA

Get N messages before and after one or more specific message IDs. Use when the user references "what was being said around message X" or wants to see the conversation surrounding a specific message.

Inputs: session_id (required), message_ids (required), context_size, format, +1 more.

get_messagesA

The primary tool for reading message content. Retrieves up to 500 messages per call with filters for keyword, time range, and sender. Use page to paginate. Returns plain text by default (set format=json for JSON, format=text for compact format). Always prefer this over execute_sql when reading messages.

Inputs: session_id (required), keyword, start_time, end_time, +8 more.

get_response_time_analysisA

Reply intervals between consecutive messages from different senders, grouped by (from, to) pair. Excludes same-sender continuations and gaps over 1 hour. Use for "who responds fastest" type questions.

Inputs: session_id (required), top_n, start_time, end_time, +1 more.

get_sessionA

Gets full details of a single session by ID. Returns plain text by default (set format=json for JSON).

Inputs: id (required), format.

get_session_summariesA

Get AI-generated summaries of chat sub-sessions from the chat_session table. Use to quickly survey what topics have been discussed. Supports keyword filtering and time range. Returns text by default.

Inputs: session_id (required), keywords, limit, start_time, +3 more.

get_stats_overviewA

Returns statistical overview of a session: message counts, active members, time distribution. Returns plain text by default (set format=json for JSON).

Inputs: session_id (required), format.

get_time_statsA

Get message count distribution bucketed by hour, weekday, or day. Use for "when are people most active" type questions. Timezone-aware bucketing.

Inputs: session_id (required), type (required), start_time, end_time, +2 more.

keyword_frequencyA

Word/keyword frequency analysis. Currently not implemented in the MCP server due to NLP dependency size; returns a stub message with alternative approaches.

Inputs: session_id (required), format.

list_sessionsB

Lists all imported chat sessions with name, platform, message count, and time range. Returns plain text by default (set format=json for JSON).

Inputs: format.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.9/5.0

    Scored across 17 tools

    Disambiguation4/5

    Most tools have clearly distinct purposes, but there is slight overlap between get_messages, get_conversation_text, and get_full_conversation. However, descriptions clarify when to use each, so ambiguity is low.

    Naming Consistency5/5

    All tools follow a consistent verb_noun pattern with snake_case. Most use 'get_' prefix, except deep_search_, execute_sql, keyword_frequency, and list_sessions, which are still clear and consistent with their verb choice.

    Tool Count4/5

    17 tools is slightly above the typical well-scoped range (3-15), but each tool serves a distinct analytical purpose for chat sessions, so it feels appropriate rather than bloated.

    Completeness4/5

    The tool set covers all major aspects of chat analysis (listing, messages, members, activity, time stats, context, summaries). The only gap is the stub keyword_frequency tool, which is acknowledged but not implemented.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables querying, searching, and analyzing Cursor IDE conversation history from SQLite workspaceStorage databases. Supports exporting chat data in multiple formats and provides workspace utilities for managing conversation data across projects.
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      Enables searching and analyzing GitHub Copilot's conversation history stored locally, providing tools for full-text search, session listing, statistics, and file-based retrieval.
      6
      16 PyPI
      4
      MIT
    • F
      license
      Not graded
      quality
      C
      maintenance
      Enables read-only access to Kilo Code and Opencode conversation history stored in a local SQLite database, allowing users to list projects and sessions, read messages, and perform full-text keyword searches across all messages.
      -