home / mcp / mcp chain of draft server

MCP Chain of Draft Server

MCP prompt tool applying Chain-of-Draft (CoD) reasoning - BYOLLM

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "brendancopley-mcp-chain-of-draft-prompt-tool": {
      "command": "python3",
      "args": [
        "/absolute/path/to/cod/server.py"
      ],
      "env": {
        "OPENAI_API_KEY": "sk-...",
        "MISTRAL_API_KEY": "your_key_here",
        "MCP_LLM_PROVIDER": "ollama",
        "MCP_OLLAMA_MODEL": "llama2",
        "ANTHROPIC_API_KEY": "your_api_key_here",
        "MCP_CUSTOM_LLM_ENDPOINT": "http://localhost:11434"
      }
    }
  }
}

You can deploy and use the MCP Chain of Draft (CoD) Tool to transform prompts into concise CoD or CoT reasoning, route them through your chosen language model, and get back structured results. This MCP enables you to leverage Bring Your Own LLM workflows with both cloud and local models, optimizing reasoning quality, speed, and cost while maintaining accuracy across math, code, logic, and domain-specific problems.

How to use

Use a compatible MCP client to connect to the Chain of Draft tool. Choose your LLM provider from cloud options like Anthropic Claude, OpenAI GPT, Mistral AI, or run a local model through Ollama or a custom local endpoint. Begin a session with an input problem and let the tool transform your prompt into a guided reasoning format. The tool processes the prompt step by step, then returns a clear final answer along with the reasoning steps and token usage data. You can compare CoD to standard Chain of Thought (CoT) and fine-tune prompts or model choices based on performance.

How to install

Prerequisites You need Node.js and/or Python installed depending on which implementation you plan to run. Ensure you have a compatible environment to execute the provided commands.

# Prerequisites check
node --version
python --version
```

# Local model setup options (choose one)

# Option A: Use Ollama for local models
# Install Ollama (instructions may vary by platform)
curl https://ollama.ai/install.sh | sh

# Pull a local model
ollama pull llama2
# or another model such as mistral

# Configure to use Ollama
export MCP_LLM_PROVIDER=ollama
export MCP_OLLAMA_MODEL=llama2

# Option B: Use a custom local model endpoint
export MCP_LLM_PROVIDER=custom
export MCP_CUSTOM_LLM_ENDPOINT=http://localhost:your_port

# Option C: Cloud-based LLMs (set your keys in the environment)
export ANTHROPIC_API_KEY=your_key_here
export OPENAI_API_KEY=your_key_here
export MISTRAL_API_KEY=your_key_here

Configuration and running the server

The tool supports both Python and JavaScript implementations. Start the server using the approach you chose during installation.

# Python implementation
python3 /absolute/path/to/cod/server.py

# JavaScript/TypeScript implementation
node /absolute/path/to/cod/index.js

Explicit MCP server configurations

The following local, stdio-based configurations run the MCP Chain of Draft tool as separate servers. Each entry uses a complete command with arguments and an environment placeholder for API keys.

{
  "type": "stdio",
  "name": "cod_python",
  "command": "python3",
  "args": ["/absolute/path/to/cod/server.py"],
  "env": {
    "ANTHROPIC_API_KEY": "your_api_key_here"
  }
}

Explicit MCP server configurations (JavaScript)

{
  "type": "stdio",
  "name": "cod_js",
  "command": "node",
  "args": ["/absolute/path/to/cod/index.js"],
  "env": {
    "ANTHROPIC_API_KEY": "your_api_key_here"
  }
}

Using with Claude Desktop and Dive

If you use Claude Desktop or Dive to manage MCP tools, you can integrate these local servers by pointing Claude Desktop to the Python or JavaScript entry points and passing the necessary API keys in the environment. Dive provides MCP hosting and a GUI for testing tool calls, including real-time visualization, request/response history, and performance metrics.

Tools and endpoints

The MCP Chain of Draft tool exposes several capabilities you can call through your MCP client. These include solving problems with CoD reasoning, analyzing performance, and retrieving token-reduction statistics.

Security and environment

Keep API keys secure by using environment variables and restricting access to your MCP server. Do not hard-code secrets in code or configuration files that may be shared. Use separate keys per environment and rotate them periodically.

Troubleshooting

If you encounter connectivity issues, verify that the MCP server is running, the command and arguments are correct, and the environment variables are set as shown. Check for incompatible model providers and ensure network access for cloud-based LLM services.

Available tools

chain_of_draft_solve

Solve a problem using Chain of Draft reasoning with concise steps and format enforcement.

math_solve

Solve mathematical problems using CoD reasoning with domain-aware calibration.

code_solve

Solve coding problems with CoD reasoning and output structured results.

logic_solve

Reason about logical problems using CoD with adaptive word limits.

get_performance_stats

Retrieve performance metrics comparing CoD and CoT across domains.

get_token_reduction

Provide token reduction statistics when using CoD versus standard CoT.

analyze_problem_complexity

Analyze problem complexity to calibrate word limits automatically.