🚀 Cursor Chat History MCP
このプロジェクトは、Cursor、ClaudeなどのAIアシスタントにCursorのチャット履歴を読み取らせ、分析させることができるModel Context Protocol (MCP)サーバーです。これにより、実際の開発パターンや履歴に基づいたパーソナライズされたコーディング支援が可能になります。
✨ 主な機能
このプロジェクトが可能にすること
AIアシスタントに以下のことを依頼できます。
- チャット履歴を分析して、コーディングパターンや使用統計を把握する
- 実際の開発ディスカッションに基づいて、プロジェクト固有のルールを生成する
- 過去の問題解決セッションから洞察を抽出し、関連する会話を見つける
- コードに関する実際の会話に基づいて、ドキュメントを作成する
- チャットデータをエクスポートして、外部での分析や可視化を行う
- すでに解決した問題の解決策を見つけて適用する
主な利点
- パーソナライズされたルールの生成:一般的なベストプラクティスではなく、実際の開発パターンに基づいてコーディング標準を作成します。
- 過去の履歴から学習:過去のチャットから洞察を抽出して、将来の開発を改善します。
- コンテキスト認識型支援:特定のプロジェクトやコーディングスタイルを考慮した支援を受けます。
- パターン認識:開発作業における繰り返しのテーマや解決策を特定します。
🚀 クイックスタート
1. MCPの設定
.cursor/mcp.jsonに以下を追加します。
{
"mcpServers": {
"cursor-chat-history": {
"command": "npx",
"args": ["-y", "--package=cursor-chat-history-mcp", "cursor-chat-history-mcp"]
}
}
}
2. 使用開始
"Analyze my React conversations and create component guidelines"
"Find debugging patterns in my chat history"
"Generate TypeScript coding standards from my actual usage"
"What are the main themes in my recent coding discussions?"
💻 使用例
基本的な使用法
設定
{
"mcpServers": {
"cursor-chat-history": {
"command": "npx",
"args": ["-y", "--package=cursor-chat-history-mcp", "cursor-chat-history-mcp"]
}
}
}
コマンド例
"Analyze my React conversations and create component guidelines"
"Find debugging patterns in my chat history"
"Generate TypeScript coding standards from my actual usage"
"What are the main themes in my recent coding discussions?"
📦 インストール
開発用
git clone https://github.com/vltansky/cursor-chat-history-mcp
cd cursor-chat-history-mcp
yarn install
yarn build
使用用
上記のnpx設定により、自動的にインストールが行われます。
📚 ドキュメント
利用可能なツール
コアツール
list_conversations - フィルタリングオプションとオプションのプロジェクト関連性スコアで会話を閲覧します。
get_conversation - コードとファイル参照を含む完全な会話内容を取得します。
search_conversations - マルチキーワード、LIKEパターン、テキスト検索による拡張検索を行います。
分析とデータ抽出ツール
get_conversation_analytics - 使用パターン、ファイルアクティビティ、プログラミング言語分布、時間的トレンドなどの包括的な分析を行います。
find_related_conversations - 共有ファイル、フォルダ、言語、サイズ、または時間的近接性によって関連する会話を見つけます。
extract_conversation_elements - 柔軟なグルーピングでファイル、コードブロック、言語、メタデータ、および会話構造を抽出します。
export_conversation_data - JSON、CSV、またはグラフ形式でチャットデータをエクスポートして、外部での分析や可視化を行います。
一般的なユースケース
コーディングルールの生成
"Create TypeScript interface naming conventions from my conversations"
"Extract error handling patterns and create guidelines"
"Find all my discussions about testing and create best practices"
ベストプラクティスの抽出
"Show me how I typically use React hooks in my projects"
"Find patterns in my state management discussions"
"Analyze my class inheritance usage and create guidelines"
高度な分析
"Find conversations where I discussed specific functions or patterns"
"Search for file-specific discussions across my projects"
"Compare how I've approached similar problems over time"
プロジェクトドキュメントの作成
"Generate API documentation from my service discussions"
"Create technical docs from my auth module conversations"
過去の解決策から学習
"Find similar debugging sessions and extract solutions"
"Analyze my performance optimization discussions"
データ分析と洞察
"Get comprehensive analytics on my coding patterns over the last 3 months"
"Export all conversations with React code to CSV for analysis"
"Find conversations similar to this database migration discussion"
ツールリファレンス
出力形式
すべてのツールは、outputModeパラメータを介してJSON出力形式をサポートします。
json (デフォルト) - 読みやすさのために適切なインデントが付けられたフォーマット済みのJSON
compact-json - 最小サイズのためにフォーマットが削除されたミニファイされたJSON
コアツール
list_conversations
limit (デフォルト: 10) - 返される会話の数
includeAiSummaries (デフォルト: true) - 効率的な閲覧のためにAI生成の要約を含める
projectPath - プロジェクトパスでフィルタリング
includeRelevanceScore (デフォルト: false) - projectPathでフィルタリングするときに関連性スコアを含める
hasCodeBlocks - コードの有無で会話をフィルタリング
keywords - キーワードで検索
filePattern - ファイルパターンでフィルタリング
get_conversation
conversationId (必須) - 取得する会話
summaryOnly (デフォルト: false) - コンテキストを節約するために、完全な内容ではなく拡張要約を取得する
includeMetadata (デフォルト: false) - 追加のメタデータを含める
search_conversations - 複数の方法による拡張検索
- シンプルクエリ:
query - 基本的なテキスト検索 (下位互換性)
- マルチキーワード:
keywords配列とkeywordOperator ('AND'/'OR')
- LIKEパターン:
likePattern - SQL LIKEパターン (% = 任意の文字、_ = 単一文字)
searchType (デフォルト: 'all') - 'all', 'project', 'files', 'code'
maxResults (デフォルト: 10) - 最大結果数
includeCode (デフォルト: true) - コードブロックを含める
分析とデータ抽出ツール
get_conversation_analytics
scope (デフォルト: 'all') - 'all', 'recent', 'project'
projectPath - 特定のプロジェクトに焦点を当てる (scope='project'のとき必須)
recentDays (デフォルト: 30) - 最近のスコープの時間ウィンドウ
includeBreakdowns (デフォルト: ['files', 'languages']) - 分析タイプ: 'files', 'languages', 'temporal', 'size'
find_related_conversations
referenceConversationId (必須) - 起点となる会話
relationshipTypes (デフォルト: ['files']) - 'files', 'folders', 'languages', 'size', 'temporal'
maxResults (デフォルト: 10) - 結果の数
minScore (デフォルト: 0.1) - 最小類似度スコア (0-1)
includeScoreBreakdown (デフォルト: false) - 個々の関係性スコアを表示する
extract_conversation_elements
conversationIds - 特定の会話 (オプション、空の場合はすべての会話を処理する)
elements (デフォルト: ['files', 'codeblocks']) - 'files', 'folders', 'languages', 'codeblocks', 'metadata', 'structure'
includeContext (デフォルト: false) - 周囲のメッセージテキストを含める
groupBy (デフォルト: 'conversation') - 'conversation', 'element', 'none'
filters - コード長、ファイル拡張子、または言語でフィルタリング
export_conversation_data
conversationIds - 特定の会話 (オプション、空の場合はすべての会話をエクスポートする)
format (デフォルト: 'json') - 'json', 'csv', 'graph'
includeContent (デフォルト: false) - 完全なメッセージテキストを含める
includeRelationships (デフォルト: false) - ファイル/フォルダの接続を計算する
flattenStructure (デフォルト: false) - CSV互換性のために構造を平坦化する
filters - サイズ、コードブロック、またはプロジェクトパスでフィルタリング
データベースパス
自動検出される場所は以下の通りです。
- macOS:
~/Library/Application Support/Cursor/User/globalStorage/state.vscdb
- Windows:
%APPDATA%/Cursor/User/globalStorage/state.vscdb
- Linux:
~/.config/Cursor/User/globalStorage/state.vscdb
🔧 技術詳細
- レガシーおよび最新のCursor会話形式の両方をサポートしています。
- SQLiteを使用してCursorのチャットデータベースにアクセスします。
- データベースのロック問題を避けるために、実行前にCursorを閉じてください。
- 空の会話を除外するために、サイズでフィルタリングされた会話 (>1000バイト) を使用します。
- 時系列順に並べるためにROWIDを使用します (UUIDは時系列順ではありません)。
🤝 コントリビューション
- リポジトリをフォークします。
- 機能ブランチを作成します。
- 変更を加えます。
- 適用可能な場合はテストを追加します。
- プルリクエストを送信します。
📄 ライセンス
MITライセンスの下で公開されています。