README.md•12.1 kB
# IDE Chat Summarizer MCP Server
A [Model Context Protocol (MCP)](https://github.com/modelcontextprotocol/python-sdk) server designed for IDE users to summarize chat conversations with AI and automatically store them as organized markdown files in your notes directory. Perfect for VS Code, Cursor, and Visual Studio users.
## 🎯 Purpose
This MCP server transforms chat conversations into structured summaries and saves them to your configured notes directory (default: `~/Documents/ChatSummaries`) for easy reference and organization. Perfect for keeping track of important discussions, decisions, and insights from your AI conversations.
## ✨ Features
### 🔧 Tools
- **`summarize_chat`**: Summarize chat history and save as markdown
- Supports different summary styles (brief, detailed, bullet_points)
- **NEW**: Smart code detection and preservation of final solutions
- **NEW**: Options for handling large histories (include_full_history, create_separate_full_history)
- Auto-generates timestamped filenames
- Custom titles for better organization
- Smart handling: Uses collapsible sections for large conversations (>1MB)
- **`summarize_large_chat`**: Handle extremely large chat histories (NEW!)
- Automatically chunks huge conversations into manageable pieces
- Creates individual files for each chunk with overlap for context
- Generates a master summary file linking all chunks
- Configurable chunk size (default: 50,000 characters)
- Perfect for multi-hour conversations or extensive documentation
- **`list_summaries`**: View recent chat summaries
- Shows creation dates and file sizes
- Configurable limit for results
- Sorted by most recent first
- **`delete_summary`**: Remove unwanted summary files
- Safety checks to only delete chat summary files
- Confirmation messages
### 📄 Resources
- **`summary://{filename}`**: Read content of specific summary files
- **`notes://directory`**: Get information about your notes directory
### 💬 Prompts
- **`create_summary_prompt`**: Generate customized prompts for different conversation types
- Supports: general, technical, meeting, brainstorm
- Focus areas: all, decisions, action_items, insights
## 🚀 Installation and Setup
### Prerequisites
- [uv](https://docs.astral.sh/uv/) package manager
- Python 3.13+
### Install Dependencies
```bash
uv sync
```
### Run the Server
#### 1. Using MCP Inspector (Recommended for Development)
```bash
uv run mcp dev main.py
```
Opens a web interface at `http://localhost:6274` for testing.
#### 2. Direct Server Run
```bash
uv run python main.py
```
#### 3. Using MCP CLI
```bash
uv run mcp run main.py
```
## 📝 Usage Examples
### Handling Large Chat Histories
For huge chat histories, you have several options depending on your client:
#### **Option 1: Standard with Full History (Recommended)**
**In VS Code/Cursor/Visual Studio:**
1. Use the **`summarize_chat`** tool
2. **Parameters to set:**
- `chat_history`: Copy and paste your entire conversation
- `title`: "Long AI Discussion" (optional)
- `summary_style`: Choose "detailed", "brief", or "bullet_points"
- `include_full_history`: ✅ **True** (default - keeps everything!)
- `create_separate_full_history`: ❌ False
**Result:** Creates 1 file with smart organization - collapsible sections for large histories (>1MB)
#### **Option 2: Separate Files for Organization**
**In VS Code/Cursor/Visual Studio:**
1. Use the **`summarize_chat`** tool
2. **Parameters to set:**
- `chat_history`: Your huge conversation
- `title`: "Extended Coding Session"
- `summary_style`: "detailed"
- `include_full_history`: ✅ True
- `create_separate_full_history`: ✅ **True** (creates 2 files!)
**Result:** Creates 2 files: `chat_summary_*.md` + `chat_full_*.md`
#### **Option 3: Extremely Large Histories (Chunking)**
**In VS Code/Cursor/Visual Studio:**
1. Use the **`summarize_large_chat`** tool (NEW!)
2. **Parameters to set:**
- `chat_history`: Your massive conversation
- `title`: "All Day Coding Session"
- `chunk_size`: 50000 (characters per chunk)
- `overlap`: 5000 (overlap between chunks for context)
**Result:** Creates master summary + individual chunk files with preserved context
### Summarizing a Regular Chat
**In VS Code/Cursor/Visual Studio:**
1. Use the **`summarize_chat`** tool
2. **Fill in the parameters:**
- `chat_history`:
```
User: How do I optimize my Python code?
AI: Here are several optimization techniques...
User: What about memory usage?
AI: For memory optimization, consider...
```
- `title`: "Python Optimization" (optional)
- `summary_style`: "detailed" (or "brief", "bullet_points")
**Result:** Creates `chat_summary_20240115_143022_Python_Optimization.md` with summary and full conversation
### Listing Your Summaries
**In VS Code/Cursor/Visual Studio:**
1. Use the **`list_summaries`** tool
2. **Optional parameter:**
- `limit`: 10 (number of summaries to show)
**Result:** Shows recent summaries with dates, sizes, and filenames
### Reading a Summary
**In VS Code/Cursor/Visual Studio:**
1. Use the **`summary://filename`** resource
2. **Parameter:**
- `filename`: `chat_summary_20240115_143022_Python_Optimization.md`
**Result:** Returns full content of the summary file
### Managing Summaries
**In VS Code/Cursor/Visual Studio:**
1. Use the **`delete_summary`** tool
2. **Parameter:**
- `filename`: Name of the file to delete
**Result:** Safely removes the summary file
## 🎯 **Quick Start Guide for Large Histories**
### **Step-by-Step: Saving Your Huge Chat**
1. **📋 Copy your entire conversation** from your chat interface
2. **🔧 Open MCP tools** in VS Code/Cursor/Visual Studio
3. **⚙️ Choose your approach:**
**For most large chats (recommended):**
- Tool: `summarize_chat`
- Paste conversation in `chat_history`
- Set `include_full_history`: `true`
- Leave other defaults
**For extremely large chats (>100MB):**
- Tool: `summarize_large_chat`
- Paste conversation in `chat_history`
- Leave defaults (50k chunk size)
4. **🚀 Run the tool** - Your conversation is now safely stored!
### **What You Get:**
- ✅ **Complete preservation** - Nothing lost from original
- ✅ **Smart organization** - Easy to read and navigate
- ✅ **Searchable files** - Find anything quickly
- ✅ **Multiple formats** - Summary + full history options
## 📁 File Organization
Summaries are saved to your configured notes directory (default: `~/Documents/ChatSummaries`)
**Filename Pattern**: `chat_summary_YYYYMMDD_HHMMSS_[title].md`
**Example Files**:
- `chat_summary_20240115_143022_Python_Optimization.md`
- `chat_summary_20240115_150330_API_Design_Discussion.md`
- `chat_summary_20240115_162145_Untitled.md`
## 📋 Summary Styles
### Brief
- 2-3 sentence overview
- Key points only
- Quick reference
### Detailed (Default)
- Comprehensive summary
- Main topics and subtopics
- Key decisions and insights
- Structured with headings
### Bullet Points
- Organized bullet list format
- Main topics as bullets
- Easy to scan
- Action-oriented
## 💻 **Smart Code Detection**
The summarizer automatically detects and preserves important code from your conversations:
### **🎯 What It Detects:**
- **Code blocks** (```language ... ```)
- **Inline code** (`code`)
- **Final solutions** - Code that appears near keywords like "final", "solution", "working", "complete"
- **Late-conversation code** - Code blocks in the last 30% of the conversation (likely to be solutions)
### **🔍 How It Works:**
1. **Scans conversation** for all code blocks and inline code
2. **Identifies final solutions** using context analysis and position weighting
3. **Preserves in summary** with proper syntax highlighting
4. **Organizes by importance** - Final solutions first, then other code snippets
### **📋 What You Get:**
- **💻 Final Code Solutions** section with working code
- **📝 Code Snippets** section with relevant code examples
- **Language detection** and proper syntax highlighting
- **Context preservation** - knows which code is the final answer
## 🔧 Client Integration
### VS Code
When adding this MCP server to VS Code:
**Command**:
```
uv run --directory "/path/to/your/ide-chat-summarizer-mcp" python main.py
```
Replace `/path/to/your/ide-chat-summarizer-mcp` with your actual project directory path.
**Server Name**: `chat-summarizer`
### Cursor
In Cursor settings:
1. Go to **Extensions** → **MCP**
2. **Add Server** with:
- **Name**: `chat-summarizer`
- **Command**: `uv run --directory "/path/to/your/ide-chat-summarizer-mcp" python main.py`
- **Working Directory**: `/path/to/your/ide-chat-summarizer-mcp`
### Visual Studio (Full IDE)
Visual Studio has MCP support! Here's how to configure it:
#### **Native MCP Configuration**
1. Open the **Configure MCP server** dialog in Visual Studio
2. Fill out the configuration:
**Server ID**:
```
chat-summarizer
```
**Type**:
```
stdio
```
*(Keep this as default)*
**Command (with optional arguments)**:
```
uv run --directory "/path/to/your/ide-chat-summarizer-mcp" python main.py
```
*(Replace `/path/to/your/mcp-server-demo` with your actual project path)*
**Environment Variables** (Optional):
- Click **"+ Add"** if you want a custom notes directory
- **Name**: `CHAT_NOTES_DIR`
- **Value**: `/path/to/your/custom/notes/directory`
3. Click **"Save"**
4. Restart Visual Studio
## 🎯 **Typical Workflow**
### **For VS Code/Cursor/Visual Studio:**
1. 💻 **Power up computer**
2. 🚀 **Open VS Code/Cursor/Visual Studio**
3. 💬 **Start chatting with AI**
4. 🔧 **Use MCP tools directly** - server starts automatically!
### **For MCP Inspector (Testing):**
1. 💻 **Power up computer**
2. 📁 **Navigate to project directory**
3. ⚡ **Run**: `uv run mcp dev main.py`
4. 🌐 **Use web interface** at `http://localhost:6274`
> **💡 Pro Tip**: Most clients (VS Code, Cursor, Visual Studio) automatically start your MCP server when you use the tools. You only need to manually start the server for testing with MCP Inspector.
## 📊 Directory Information
The server provides insights about your notes directory:
- Total markdown files count
- Chat summaries count
- Directory size
- Last activity timestamp
## 🛠 Configuration
### Notes Directory
Default: `~/Documents/ChatSummaries` (user's Documents folder)
**Method 1: Environment Variable (Recommended)**
Set the `CHAT_NOTES_DIR` environment variable:
```bash
# Windows
set CHAT_NOTES_DIR=C:\Users\YourName\Notes\ChatSummaries
# macOS/Linux
export CHAT_NOTES_DIR="/home/username/Notes/ChatSummaries"
```
**Method 2: Edit main.py**
Modify the `NOTES_DIR` variable in `main.py`:
```python
# Examples:
NOTES_DIR = Path("your/custom/path") # Custom absolute path
NOTES_DIR = Path.home() / "Notes" / "Summaries" # User's home directory
NOTES_DIR = Path.cwd() / "summaries" # Relative to project directory
```
### Summary Templates
Customize summary styles by modifying the prompt generation in the `summarize_chat` function.
## 🔍 Project Structure
```
ide-chat-summarizer-mcp/
├── main.py # MCP server implementation
├── pyproject.toml # Project configuration
├── README.md # This documentation
├── mcp-config.json # MCP server configuration
└── uv.lock # Dependency lock file
```
## 📚 Learn More
- [Model Context Protocol Documentation](https://modelcontextprotocol.io)
- [Python SDK Documentation](https://github.com/modelcontextprotocol/python-sdk)
- [MCP Specification](https://spec.modelcontextprotocol.io)
## 🤝 Usage Tips
1. **Organize by Topic**: Use meaningful titles when summarizing
2. **Regular Cleanup**: Use `delete_summary` to remove outdated summaries
3. **Style Selection**: Choose the right summary style for your needs
4. **Batch Processing**: Use `list_summaries` to review and manage multiple summaries
---
*Transform your conversations into organized, searchable knowledge with the Chat History Summarizer MCP Server!*