Supports running Chain of Draft reasoning with locally-hosted Ollama models, allowing use of Llama, Mistral, and other open-source language models.
Provides OpenAI API compatibility for Chain of Draft reasoning, supporting GPT models and other OpenAI-compatible endpoints with drop-in replacement for standard OpenAI clients.

MCP Chain of Draft (CoD) Prompt Tool
Overview
The MCP Chain of Draft (CoD) Prompt Tool is a powerful Model Context Protocol tool that enhances LLM reasoning by transforming standard prompts into either Chain of Draft (CoD) or Chain of Thought (CoT) format. Here's how it works:
Input Transformation: Your regular prompt is automatically transformed into a CoD/CoT format
LLM Processing: The transformed prompt is passed to your chosen LLM (Claude, GPT, Ollama, or local models)
Enhanced Reasoning: The LLM processes the request using structured reasoning steps
Result Transformation: The response is transformed back into a clear, concise format
This approach significantly improves reasoning quality while reducing token usage and maintaining high accuracy.
BYOLLM Support
This tool supports a "Bring Your Own LLM" approach, allowing you to use any language model of your choice:
Supported LLM Integrations
Cloud Services
Anthropic Claude
OpenAI GPT models
Mistral AI
Local Models
Ollama (all models)
Local LLama variants
Any model supporting chat completion API
Configuring Your LLM
Cloud Services
# For Anthropic Claude export ANTHROPIC_API_KEY=your_key_here # For OpenAI export OPENAI_API_KEY=your_key_here # For Mistral AI export MISTRAL_API_KEY=your_key_hereLocal Models with Ollama
# First install Ollama curl https://ollama.ai/install.sh | sh # Pull your preferred model ollama pull llama2 # or ollama pull mistral # or any other model # Configure the tool to use Ollama export MCP_LLM_PROVIDER=ollama export MCP_OLLAMA_MODEL=llama2 # or your chosen modelCustom Local Models
# Point to your local model API export MCP_LLM_PROVIDER=custom export MCP_CUSTOM_LLM_ENDPOINT=http://localhost:your_port
Credits
This project implements the Chain of Draft (CoD) reasoning approach as a Model Context Protocol (MCP) prompt tool for Claude. The core Chain of Draft implementation is based on the work by stat-guy. We extend our gratitude for their pioneering work in developing this efficient reasoning approach.
Original Repository: https://github.com/stat-guy/chain-of-draft
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 22+ (for JavaScript implementation)
Nx (for building Single Executable Applications)
Python Installation
Clone the repository
Install dependencies:
pip install -r requirements.txtConfigure API keys in
.envfile:ANTHROPIC_API_KEY=your_api_key_hereRun the server:
python server.py
JavaScript/TypeScript Installation
Clone the repository
Install dependencies:
npm installConfigure API keys in
.envfile:ANTHROPIC_API_KEY=your_api_key_hereBuild and run the server:
# Build TypeScript files using Nx npm run nx build # Start the server npm start # For development with auto-reload: npm run dev
Available scripts:
npm run nx build: Compiles TypeScript to JavaScript using Nx build systemnpm run build:sea: Creates Single Executable Applications for all platformsnpm start: Runs the compiled server fromdistnpm test: Runs the test query against the servernpm run dev: Runs the TypeScript server directly using ts-node (useful for development)
The project uses Nx as its build system, providing:
Efficient caching and incremental builds
Cross-platform build support
Integrated SEA generation
Dependency graph visualization
Consistent build process across environments
Single Executable Applications (SEA)
This project supports building Single Executable Applications (SEA) using Node.js 22+ and the @getlarge/nx-node-sea plugin. This allows you to create standalone executables that don't require Node.js to be installed on the target system.
Building SEA Executables
The project includes several scripts for building SEA executables:
SEA Build Configuration
The project uses Nx for managing the build process. The SEA configuration is handled through the nx-node-sea plugin, which provides a streamlined way to create Node.js single executable applications.
Key features of the SEA build process:
Cross-platform support (macOS, Linux, Windows)
Automatic dependency bundling
Optimized binary size
No runtime dependencies required
Using SEA Executables
Once built, the SEA executables can be found in the dist directory. These executables:
Are completely standalone
Don't require Node.js installation
Can be distributed and run directly
Maintain all functionality of the original application
For Claude Desktop integration with SEA executables, update your configuration to use the executable path:
Claude Desktop Integration
To integrate with Claude Desktop:
Install Claude Desktop from claude.ai/download
Create or edit the Claude Desktop config file:
~/Library/Application Support/Claude/claude_desktop_config.jsonAdd the tool configuration (Python version):
{ "mcpServers": { "chain-of-draft-prompt-tool": { "command": "python3", "args": ["/absolute/path/to/cod/server.py"], "env": { "ANTHROPIC_API_KEY": "your_api_key_here" } } } }Or for the JavaScript version:
{ "mcpServers": { "chain-of-draft-prompt-tool": { "command": "node", "args": ["/absolute/path/to/cod/index.js"], "env": { "ANTHROPIC_API_KEY": "your_api_key_here" } } } }Restart Claude Desktop
You can also use the Claude CLI to add the tool:
Using with Dive GUI
Dive is an excellent open-source MCP Host Desktop Application that provides a user-friendly GUI for interacting with MCP tools like this one. It supports multiple LLMs including ChatGPT, Anthropic Claude, Ollama, and other OpenAI-compatible models.
Integrating with Dive
Download and install Dive from their releases page
Configure the Chain of Draft tool in Dive's MCP settings:
If you're using the non-SEA version:
Key Benefits of Using Dive
🌐 Universal LLM Support with multiple API key management
💻 Cross-platform availability (Windows, MacOS, Linux)
🔄 Seamless MCP integration in both stdio and SSE modes
🌍 Multi-language interface
💡 Custom instructions and system prompts
🔄 Automatic updates
Using Dive provides a convenient way to interact with the Chain of Draft tool through a modern, feature-rich interface while maintaining all the benefits of the MCP protocol.
Testing with MCP Inspector
The project includes integration with the MCP Inspector tool, which provides a visual interface for testing and debugging MCP tools. This is especially useful during development or when you want to inspect the tool's behavior.
Running the Inspector
You can start the MCP Inspector using the provided npm script:
This will:
Start the MCP server in the background
Launch the MCP Inspector interface in your default browser
Connect to the running server for testing
Using the Inspector Interface
The MCP Inspector provides:
🔍 Real-time visualization of tool calls and responses
📝 Interactive testing of MCP functions
🔄 Request/response history
🐛 Debug information for each interaction
📊 Performance metrics and timing data
This makes it an invaluable tool for:
Development and debugging
Understanding tool behavior
Testing different inputs and scenarios
Verifying MCP compliance
Performance optimization
The Inspector will be available at http://localhost:5173 by default.
Available Tools
The Chain of Draft server provides the following tools:
Tool | Description |
| Solve a problem using Chain of Draft reasoning |
| Solve a math problem with CoD |
| Solve a coding problem with CoD |
| Solve a logic problem with CoD |
| Get performance stats for CoD vs CoT |
| Get token reduction statistics |
| Analyze problem complexity |
Developer Usage
Python Client
If you want to use the Chain of Draft client directly in your Python code:
JavaScript/TypeScript Client
For TypeScript/Node.js applications:
Implementation Details
The server is available in both Python and JavaScript implementations, both consisting of several integrated components:
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
Both implementations follow the same core principles and provide identical MCP tools, making them interchangeable for most use cases.
License
This project is open-source and available under the MIT license.
This server cannot be installed
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
Transforms prompts into Chain of Draft (CoD) or Chain of Thought (CoT) format to enhance LLM reasoning quality while reducing token usage by up to 92.4%, supporting multiple LLM providers including Claude, GPT, Ollama, and local models.