Chain of Draft Prompt Tool MCP server

Organizes prompts into structured, multi-step workflows through a chain execution system where outputs from one step become inputs for subsequent steps, enabling progressive refinement for complex tasks like research, code review, and documentation generation.
Back to servers
Setup instructions
Provider
Brendan Copley
Release date
Mar 20, 2025
Language
TypeScript
Stats
15 stars

The MCP Chain of Draft (CoD) Prompt Tool is a powerful server that enhances LLM reasoning by transforming standard prompts into structured Chain of Draft or Chain of Thought formats. This approach significantly improves reasoning quality while reducing token usage and maintaining high accuracy.

Installation

Prerequisites

  • Python 3.10+ (for Python implementation)
  • Node.js 22+ (for JavaScript implementation)

Python Installation

# Clone the repository
git clone https://github.com/brendancopley/mcp-chain-of-draft-prompt-tool.git
cd mcp-chain-of-draft-prompt-tool

# Install dependencies
pip install -r requirements.txt

# Configure API key in .env file
echo "ANTHROPIC_API_KEY=your_api_key_here" > .env

# Run the server
python server.py

JavaScript/TypeScript Installation

# Clone the repository
git clone https://github.com/brendancopley/mcp-chain-of-draft-prompt-tool.git
cd mcp-chain-of-draft-prompt-tool

# Install dependencies
npm install

# Configure API key in .env file
echo "ANTHROPIC_API_KEY=your_api_key_here" > .env

# Build and run the server
npm run nx build
npm start

# For development with auto-reload
npm run dev

Using Your Own LLM

This tool supports a "Bring Your Own LLM" approach:

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_here

Local Models with Ollama

# First install Ollama
curl https://ollama.ai/install.sh | sh

# Pull your preferred model
ollama pull llama2
# or
ollama pull mistral

# Configure the tool to use Ollama
export MCP_LLM_PROVIDER=ollama
export MCP_OLLAMA_MODEL=llama2  # or your chosen model

Custom Local Models

# Point to your local model API
export MCP_LLM_PROVIDER=custom
export MCP_CUSTOM_LLM_ENDPOINT=http://localhost:your_port

Claude Desktop Integration

  1. Install Claude Desktop from claude.ai/download

  2. Create or edit the Claude Desktop config file:

    ~/Library/Application Support/Claude/claude_desktop_config.json
    
  3. Add 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"
                }
            }
        }
    }
    
  4. Restart Claude Desktop

You can also use the Claude CLI:

# For Python implementation
claude mcp add chain-of-draft-prompt-tool -e ANTHROPIC_API_KEY="your_api_key_here" "python3 /absolute/path/to/cod/server.py"

# For JavaScript implementation
claude mcp add chain-of-draft-prompt-tool -e ANTHROPIC_API_KEY="your_api_key_here" "node /absolute/path/to/cod/index.js"

Using with Dive GUI

  1. Download and install Dive from their releases page

  2. Configure the Chain of Draft tool in Dive's MCP settings:

{
  "mcpServers": {
    "chain-of-draft-prompt-tool": {
      "command": "/path/to/mcp-chain-of-draft-prompt-tool",
      "enabled": true,
      "env": {
        "ANTHROPIC_API_KEY": "your_api_key_here"
      }
    }
  }
}

For the non-SEA version:

{
  "mcpServers": {
    "chain-of-draft-prompt-tool": {
      "command": "node",
      "args": ["/path/to/dist/index.js"],
      "enabled": true,
      "env": {
        "ANTHROPIC_API_KEY": "your_api_key_here"
      }
    }
  }
}

Available Tools

The following tools are available:

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

Using the API in Your Code

Python Client

from client import ChainOfDraftClient

# Create client with specific LLM provider
cod_client = ChainOfDraftClient(
    llm_provider="ollama",  # or "anthropic", "openai", "mistral", "custom"
    model_name="llama2"     # specify your model
)

# 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']}")

JavaScript/TypeScript Client

import { ChainOfDraftClient } from './lib/chain-of-draft-client';

// Create client with your preferred LLM
const client = new ChainOfDraftClient({
  provider: 'ollama',           // or 'anthropic', 'openai', 'mistral', 'custom'
  model: 'llama2',             // your chosen model
  endpoint: 'http://localhost:11434'  // for custom endpoints
});

// Use the client
async function solveMathProblem() {
  const result = await client.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();

Testing with MCP Inspector

You can use the MCP Inspector for testing and debugging:

# Start the MCP Inspector with the tool
npm run test-inspector

# Or run it manually
npx @modelcontextprotocol/inspector -e ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY -- node dist/index.js

The Inspector will be available at http://localhost:5173 by default.

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "chain-of-draft-prompt-tool" '{"command":"node","args":["/absolute/path/to/cod/index.js"],"env":{"ANTHROPIC_API_KEY":"your_api_key_here"}}'

See the official Claude Code MCP documentation for more details.

For Cursor

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.

Adding an MCP server to Cursor globally

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-prompt-tool": {
            "command": "node",
            "args": [
                "/absolute/path/to/cod/index.js"
            ],
            "env": {
                "ANTHROPIC_API_KEY": "your_api_key_here"
            }
        }
    }
}

Adding an MCP server to a project

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.

How to use the MCP server

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.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "chain-of-draft-prompt-tool": {
            "command": "node",
            "args": [
                "/absolute/path/to/cod/index.js"
            ],
            "env": {
                "ANTHROPIC_API_KEY": "your_api_key_here"
            }
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later