MCP Claude Context Continuity

MCP Claude Context Continuity

An MCP server that maintains conversation context for the Claude CLI across multiple invocations using its built-in resume feature. It enables users to save, restore, and branch sessions to manage continuous AI interactions effectively.

Category
访问服务器

README

MCP Claude Context Continuity

npm version License: MIT

An MCP (Model Context Protocol) server that maintains conversation context for Claude CLI across multiple invocations.

Features

  • 🔄 Conversation Continuity: Leverages Claude CLI's --resume feature to maintain conversation context across multiple calls
  • 📝 Session Management: Save, restore, and branch conversations
  • 🖥️ Cross-platform: Supports Windows (via WSL), Linux, and macOS
  • Simple Implementation: All functionality in a single Python file

Requirements

  • Python 3.8+
  • Claude CLI (must be installed in WSL for all platforms)
  • FastMCP (pip install fastmcp)
  • WSL2 for Windows environments
  • Windows: Python must be installed on Windows (not in WSL)

Installation

Option 1: Using npm (Recommended)

npm install -g mcp-claude-context-continuity

After installation, the server will be available as a global command.

Option 2: Manual Installation

  1. Clone the repository:
git clone https://github.com/tethiro/mcp-claude-context-continuity.git
cd mcp-claude-context-continuity
  1. Install dependencies:
pip install -r requirements.txt

Configuration

Gemini CLI (Recommended)

Add the following to your Gemini configuration file:

Using npm global install (Simplest)

All platforms (~/.gemini/settings.json or %USERPROFILE%\.gemini\settings.json):

{
  "mcpServers": {
    "claude-cli-server": {
      "command": "mcp-claude-context-continuity"
    }
  }
}

Manual installation

Windows (%USERPROFILE%\.gemini\settings.json):

{
  "mcpServers": {
    "claude-cli-server": {
      "command": "wsl",
      "args": [
        "-e",
        "python3",
        "/mnt/c/path/to/mcp-claude-context-continuity/src/claude_cli_server.py"
      ]
    }
  }
}

WSL/Linux/macOS (~/.gemini/settings.json):

{
  "mcpServers": {
    "claude-cli-server": {
      "command": "python3",
      "args": [
        "/path/to/mcp-claude-context-continuity/src/claude_cli_server.py"
      ]
    }
  }
}

Claude Desktop

Add similar configuration to your Claude Desktop settings file.

Usage

Basic Usage

  1. Simple conversation:
execute_claude(prompt="Hello, I'm John")
  1. Continue conversation:
execute_claude(prompt="Do you remember my name?")
→ "Yes, you're John"

Session Management

  1. Save current session:
session_id = get_current_session()
  1. Start new session:
reset_session()
  1. Restore saved session:
set_current_session(session_id="saved_id")

Available Tools

Tool Description
execute_claude Execute Claude CLI with conversation continuity
execute_claude_with_context Execute with file context
get_execution_history Get execution history
get_current_session Get current session ID
set_current_session Set session ID
reset_session Reset session
clear_execution_history Clear history
test_claude_cli Test functionality

How Session Management Works

Using Claude CLI's --resume feature, you can return to any point in a conversation using session IDs:

Conversation 1: "I'm Alice" → session_id: AAA
Conversation 2: "I like reading" (--resume AAA) → session_id: BBB
Conversation 3: "My favorite book is..." (--resume BBB) → session_id: CCC

Later:
set_current_session("AAA") → State where only "Alice" is known
set_current_session("BBB") → State where "Alice" and "reading" are known

Troubleshooting

Claude CLI Not Found

Set the CLAUDE_PATH environment variable:

export CLAUDE_PATH=/path/to/claude

Windows Environment Notes

  • WSL2 is required
  • Install Claude CLI inside WSL
  • Use WSL format paths (/mnt/c/...)

License

MIT License


MCP Claude Context Continuity

Claude CLIの会話コンテキストを保持するMCP(Model Context Protocol)サーバーです。

特徴

  • 🔄 会話の継続性: Claude CLIの--resume機能を活用し、複数の呼び出し間で会話コンテキストを保持
  • 📝 セッション管理: 会話の保存、復元、分岐が可能
  • 🖥️ クロスプラットフォーム: Windows(WSL経由)、Linux、macOS対応
  • シンプルな実装: 単一のPythonファイルで全機能を提供

必要条件

  • Python 3.8以上
  • Claude CLI(WSL内にインストール必須)
  • FastMCP(pip install fastmcp
  • Windows環境の場合はWSL2
  • Windows: PythonはWindows側にインストール(WSL内ではなく)

インストール

方法1: npmを使用(推奨)

npm install -g mcp-claude-context-continuity

インストール後、グローバルコマンドとして利用可能になります。

方法2: 手動インストール

  1. リポジトリをクローン:
git clone https://github.com/tethiro/mcp-claude-context-continuity.git
cd mcp-claude-context-continuity
  1. 依存関係をインストール:
pip install -r requirements.txt

設定

Gemini CLI(推奨)

Geminiの設定ファイルに以下を追加:

npmグローバルインストールを使用(最も簡単)

全環境共通 (~/.gemini/settings.json または %USERPROFILE%\.gemini\settings.json):

{
  "mcpServers": {
    "claude-cli-server": {
      "command": "mcp-claude-context-continuity"
    }
  }
}

手動インストールの場合

Windows環境 (%USERPROFILE%\.gemini\settings.json):

{
  "mcpServers": {
    "claude-cli-server": {
      "command": "wsl",
      "args": [
        "-e",
        "python3",
        "/mnt/c/path/to/mcp-claude-context-continuity/src/claude_cli_server.py"
      ]
    }
  }
}

WSL/Linux/macOS (~/.gemini/settings.json):

{
  "mcpServers": {
    "claude-cli-server": {
      "command": "python3",
      "args": [
        "/path/to/mcp-claude-context-continuity/src/claude_cli_server.py"
      ]
    }
  }
}

Claude Desktop

Claude Desktopの設定ファイルに同様の設定を追加します。

使用方法

基本的な使い方

  1. 通常の会話:
execute_claude(prompt="こんにちは、私は山田です")
  1. 会話の継続:
execute_claude(prompt="私の名前を覚えていますか?")
→ "はい、山田さんですね"

セッション管理

  1. 現在のセッションを保存:
session_id = get_current_session()
  1. 新しいセッションを開始:
reset_session()
  1. 保存したセッションに戻る:
set_current_session(session_id="保存したID")

利用可能なツール

ツール 説明
execute_claude Claude CLIを実行(会話継続)
execute_claude_with_context ファイルコンテキスト付きで実行
get_execution_history 実行履歴を取得
get_current_session 現在のセッションIDを取得
set_current_session セッションIDを設定
reset_session セッションをリセット
clear_execution_history 履歴をクリア
test_claude_cli 動作確認

セッション管理の仕組み

Claude CLIの--resume機能を活用し、セッションIDによって会話の任意の時点に戻ることができます:

会話1「私は太郎です」 → session_id: AAA
会話2「趣味は読書です」(--resume AAA) → session_id: BBB
会話3「好きな本は...」(--resume BBB) → session_id: CCC

後から:
set_current_session("AAA") → "太郎"のみ知っている状態
set_current_session("BBB") → "太郎"と"読書"を知っている状態

トラブルシューティング

Claude CLIが見つからない場合

環境変数CLAUDE_PATHを設定:

export CLAUDE_PATH=/path/to/claude

Windows環境での注意点

  • WSL2が必要です
  • Claude CLIはWSL内にインストールしてください
  • ファイルパスはWSL形式(/mnt/c/...)で指定

ライセンス

MIT License

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选