Chain of Draft (CoD) MCP Server
Overview
Key Benefits
- **Efficiency**: Significantly reduced token usage (as little as 7.6% of standard CoT)
- **Speed**: Faster responses due to shorter generation time
- **Cost Savings**: Lower API costs for LLM calls
- **Maintained Accuracy**: Similar or even improved accuracy compared to CoT
- **Flexibility**: Applicable across various reasoning tasks and domains
Features
- **Core Chain of Draft Implementation** - Concise reasoning steps (typically 5 words or less) - Format enforcement - Answer extraction
- **Performance Analytics** - Token usage tracking - Solution accuracy monitoring - Execution time measurement - Domain-specific performance metrics
- **Adaptive Word Limits** - Automatic complexity estimation - Dynamic adjustment of word limits - Domain-specific calibration
- **Comprehensive Example Database** - CoT to CoD transformation - Domain-specific examples (math, code, biology, physics, chemistry, puzzle) - Example retrieval based on problem similarity
- **Format Enforcement** - Post-processing to ensure adherence to word limits - Step structure preservation - Adherence analytics
- **Hybrid Reasoning Approaches** - Automatic selection between CoD and CoT - Domain-specific optimization - Historical performance-based selection
- **OpenAI API Compatibility** - Drop-in replacement for standard OpenAI clients - Support for both completions and chat interfaces - Easy integration into existing workflows
Setup and Installation
Prerequisites
- Python 3.10+ (for Python implementation)
- Node.js 18+ (for JavaScript implementation)
- Anthropic API key
Python Installation
- Clone the repository
- Install dependencies: ```bash pip install -r requirements.txt ```
- Configure API keys in `.env` file: ``` ANTHROPIC_API_KEY=your_api_key_here ```
- Run the server: ```bash python server.py ```
JavaScript Installation
- Clone the repository
- Install dependencies: ```bash npm install ```
- Configure API keys in `.env` file: ``` ANTHROPIC_API_KEY=your_api_key_here ```
- Run the server: ```bash node index.js ```
Claude Desktop Integration
- Install Claude Desktop from [claude.ai/download](https://claude.ai/download)
- Create or edit the Claude Desktop config file: ``` ~/Library/Application Support/Claude/claude_desktop_config.json ```
- Add the server configuration (Python version): ```json { "mcpServers": { "chain-of-draft": { "command": "python3", "args": ["/absolute/path/to/cod/server.py"], "env": { "ANTHROPIC_API_KEY": "your_api_key_here" } } } } ``` Or for the JavaScript version: ```json { "mcpServers": { "chain-of-draft": { "command": "node", "args": ["/absolute/path/to/cod/index.js"], "env": { "ANTHROPIC_API_KEY": "your_api_key_here" } } } } ```
- Restart Claude Desktop
Available Tools
[object Object] | [object Object] |
[object Object] | [object Object] |
[object Object] | [object Object] |
[object Object] | [object Object] |
[object Object] | [object Object] |
[object Object] | [object Object] |
[object Object] | [object Object] |
[object Object] | [object Object] |
Developer Usage
Python Client
JavaScript Client
Implementation Details
Python Implementation
- **AnalyticsService**: Tracks performance metrics across different problem domains and reasoning approaches
- **ComplexityEstimator**: Analyzes problems to determine appropriate word limits
- **ExampleDatabase**: Manages and retrieves examples, transforming CoT examples to CoD format
- **FormatEnforcer**: Ensures reasoning steps adhere to word limits
- **ReasoningSelector**: Intelligently chooses between CoD and CoT based on problem characteristics
JavaScript Implementation
- **analyticsDb**: In-memory database for tracking performance metrics
- **complexityEstimator**: Analyzes problems to determine complexity and appropriate word limits
- **formatEnforcer**: Ensures reasoning steps adhere to word limits
- **reasoningSelector**: Automatically chooses between CoD and CoT based on problem characteristics and historical performance