The Chain of Draft (CoD) MCP Server implements a novel reasoning approach that enables LLMs to generate minimalistic yet informative intermediate outputs while solving tasks. This results in significantly reduced token usage while maintaining accuracy, making your interactions with LLMs faster and more cost-effective.
pip install -r requirements.txt
.env
file:
ANTHROPIC_API_KEY=your_api_key_here
python server.py
npm install
.env
file:
ANTHROPIC_API_KEY=your_api_key_here
node index.js
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.json
Add the server configuration (Python version):
{
"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:
{
"mcpServers": {
"chain-of-draft": {
"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 server:
# For Python implementation
claude mcp add chain-of-draft -e ANTHROPIC_API_KEY="your_api_key_here" "python3 /absolute/path/to/cod/server.py"
# For JavaScript implementation
claude mcp add chain-of-draft -e ANTHROPIC_API_KEY="your_api_key_here" "node /absolute/path/to/cod/index.js"
The Chain of Draft server provides the following tools:
Tool | Description |
---|---|
chain_of_draft_solve |
Solve a problem using Chain of Draft reasoning |
math_solve |
Solve a math problem with CoD |
code_solve |
Solve a coding problem with CoD |
logic_solve |
Solve a logic problem with CoD |
get_performance_stats |
Get performance stats for CoD vs CoT |
get_token_reduction |
Get token reduction statistics |
analyze_problem_complexity |
Analyze problem complexity |
from client import ChainOfDraftClient
# Create client
cod_client = ChainOfDraftClient()
# Use directly
result = await cod_client.solve_with_reasoning(
problem="Solve: 247 + 394 = ?",
domain="math"
)
print(f"Answer: {result['final_answer']}")
print(f"Reasoning: {result['reasoning_steps']}")
print(f"Tokens used: {result['token_count']}")
import { Anthropic } from "@anthropic-ai/sdk";
import dotenv from "dotenv";
// Load environment variables
dotenv.config();
// Create the Anthropic client
const anthropic = new Anthropic({
apiKey: process.env.ANTHROPIC_API_KEY,
});
// Import the Chain of Draft client
import chainOfDraftClient from './lib/chain-of-draft-client.js';
// Use the client
async function solveMathProblem() {
const result = await chainOfDraftClient.solveWithReasoning({
problem: "Solve: 247 + 394 = ?",
domain: "math",
max_words_per_step: 5
});
console.log(`Answer: ${result.final_answer}`);
console.log(`Reasoning: ${result.reasoning_steps}`);
console.log(`Tokens used: ${result.token_count}`);
}
solveMathProblem();
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "chain-of-draft" '{"command":"python3","args":["/absolute/path/to/cod/server.py"],"env":{"ANTHROPIC_API_KEY":"your_api_key_here"}}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"chain-of-draft": {
"command": "python3",
"args": [
"/absolute/path/to/cod/server.py"
],
"env": {
"ANTHROPIC_API_KEY": "your_api_key_here"
}
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"chain-of-draft": {
"command": "python3",
"args": [
"/absolute/path/to/cod/server.py"
],
"env": {
"ANTHROPIC_API_KEY": "your_api_key_here"
}
}
}
}
3. Restart Claude Desktop for the changes to take effect