Chain of Draft (CoD) MCP Server
草案链(CoD)MCP 服务器
概述
该 MCP 服务器实现了研究论文《Chain of Draft: Thinking Faster by Writing Less》中描述的 Chain of Draft (CoD) 推理方法。CoD 是一种新颖的范式,它允许 LLM 在解决任务时生成简洁但信息丰富的中间推理输出,从而显著减少 token 的使用,同时保持准确性。
Related MCP server: Visum Thinker MCP Server
主要优点
效率:显著减少代币使用量(仅为标准 CoT 的 7.6%)
速度:由于生成时间较短,响应速度更快
节省成本:降低 LLM 调用的 API 成本
保持精度:与 CoT 相比,精度相似甚至更高
灵活性:适用于各种推理任务和领域
特征
草案实施的核心链
简洁的推理步骤(通常 5 个字或更少)
格式强制执行
答案提取
性能分析
代币使用情况追踪
解决方案准确性监控
执行时间测量
特定领域的性能指标
自适应字数限制
自动复杂度评估
动态调整字数限制
特定领域校准
综合示例数据库
CoT 到 CoD 的转换
特定领域的示例(数学、代码、生物、物理、化学、谜题)
基于问题相似度的示例检索
格式执行
后期处理以确保遵守字数限制
台阶结构保存
依从性分析
混合推理方法
自动选择 CoD 和 CoT
特定领域优化
基于历史绩效的选择
OpenAI API 兼容性
标准 OpenAI 客户端的直接替代品
支持完成和聊天界面
轻松集成到现有工作流程中
设置和安装
先决条件
Python 3.10+(用于 Python 实现)
Node.js 18+(用于 JavaScript 实现)
人类学 API 密钥
Python 安装
克隆存储库
安装依赖项:
pip install -r requirements.txt在
.env文件中配置 API 密钥:ANTHROPIC_API_KEY=your_api_key_here运行服务器:
python server.py
JavaScript 安装
克隆存储库
安装依赖项:
npm install在
.env文件中配置 API 密钥:ANTHROPIC_API_KEY=your_api_key_here运行服务器:
node index.js
Claude 桌面集成
与 Claude Desktop 集成:
从claude.ai/download安装 Claude Desktop
创建或编辑 Claude Desktop 配置文件:
~/Library/Application Support/Claude/claude_desktop_config.json添加服务器配置(Python版本):
{ "mcpServers": { "chain-of-draft": { "command": "python3", "args": ["/absolute/path/to/cod/server.py"], "env": { "ANTHROPIC_API_KEY": "your_api_key_here" } } } }或者对于 JavaScript 版本:
{ "mcpServers": { "chain-of-draft": { "command": "node", "args": ["/absolute/path/to/cod/index.js"], "env": { "ANTHROPIC_API_KEY": "your_api_key_here" } } } }重启Claude桌面
您还可以使用 Claude CLI 添加服务器:
# 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"可用工具
Chain of Draft 服务器提供以下工具:
工具 | 描述 |
| 使用 Chain of Draft 推理解决问题 |
| 使用 CoD 解决数学问题 |
| 使用 CoD 解决编码问题 |
| 使用 CoD 解决逻辑问题 |
| 获取 CoD 与 CoT 的性能统计数据 |
| 获取 token 减少统计数据 |
| 分析问题复杂性 |
开发人员使用情况
Python客户端
如果您想在 Python 代码中直接使用 Chain of Draft 客户端:
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']}")JavaScript 客户端
对于 JavaScript/Node.js 应用程序:
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();实现细节
该服务器有 Python 和 JavaScript 两种实现,均由几个集成组件组成:
Python 实现
AnalyticsService :跟踪不同问题领域和推理方法的性能指标
ComplexityEstimator :分析问题以确定适当的字数限制
ExampleDatabase :管理和检索示例,将 CoT 示例转换为 CoD 格式
FormatEnforcer :确保推理步骤符合字数限制
ReasoningSelector :根据问题特征在 CoD 和 CoT 之间进行智能选择
JavaScript 实现
analyticsDb :用于跟踪性能指标的内存数据库
complexityEstimator :分析问题以确定复杂性和适当的字数限制
formatEnforcer :确保推理步骤符合字数限制
reasoningSelector :根据问题特征和历史表现自动在 CoD 和 CoT 之间进行选择
两种实现都遵循相同的核心原则并提供相同的 MCP 工具,使得它们在大多数用例中可以互换。
执照
该项目是开源的,并根据 MIT 许可证提供。
Available Tools
7 toolsanalyze_problem_complexityC
Analyze the complexity of a problem
Inputs: problem (required), domain.
chain_of_draft_solveC
Solve a reasoning problem using Chain of Draft approach
Inputs: problem (required), domain, max_words_per_step, approach, +2 more.
code_solveC
Solve a coding problem using Chain of Draft reasoning
Inputs: problem (required), approach, max_words_per_step.
get_performance_statsC
Get performance statistics for CoD vs CoT approaches
Inputs: domain.
get_token_reductionB
Get token reduction statistics for CoD vs CoT
Inputs: no named parameters.
logic_solveC
Solve a logic problem using Chain of Draft reasoning
Inputs: problem (required), approach, max_words_per_step.
math_solveC
Solve a math problem using Chain of Draft reasoning
Inputs: problem (required), approach, max_words_per_step.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 7 tools
The tools have clear distinctions in problem domains (math, logic, code, general reasoning) but there is significant overlap between 'chain_of_draft_solve' and the domain-specific solvers (math_solve, logic_solve, code_solve), which could cause confusion about when to use the general versus specific versions. The analysis and statistics tools are clearly distinct from the solving tools.
Most tools follow a consistent snake_case pattern with descriptive names (e.g., 'analyze_problem_complexity', 'get_performance_stats'), but there's a minor inconsistency with 'chain_of_draft_solve' using a longer prefix while others use simpler domain names. The verb usage is reasonably consistent with 'solve', 'analyze', and 'get' patterns.
With 7 tools, this is well-scoped for a server focused on Chain of Draft problem-solving and analysis. The count covers solving across multiple domains plus performance analytics, without being overwhelming or too sparse for the apparent purpose.
The toolset provides good coverage for solving problems (math, logic, code, general) and analyzing performance/token usage, which aligns well with the CoD domain. A minor gap exists in not having tools for configuring or customizing the CoD approach (e.g., setting parameters), but core workflows are well supported.
Maintenance
Related MCP Connectors
Reduces AI Agent token usage by 40% via three-stage SOP workflow.
Deterministic verifier: LLM proposes, graph verifies. Sub-ms, offline, 0 tokens.
Cuts coding agent token burn up to 72% continuously via contradiction-free memory & verification.
Agent-to-agent reasoning-as-a-service: chain-of-thought, analysis, and decision support.
Related MCP Servers
- AlicenseBqualityDmaintenanceEnhances AI model capabilities with structured, retrieval-augmented thinking processes that enable dynamic thought chains, parallel exploration paths, and recursive refinement cycles for improved reasoning.124MIT
- AlicenseBqualityNot gradedmaintenanceProvides structured sequential thinking capabilities for AI assistants to break down complex problems into manageable steps, revise thoughts, and explore alternative reasoning paths.29-
- AlicenseNot gradedqualityDmaintenanceTransforms 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.35 npm19MIT
- AlicenseBqualityNot gradedmaintenanceEnables AI assistants to perform structured, step-by-step reasoning by breaking down complex problems into numbered thoughts, with support for revising previous steps and exploring alternative reasoning paths.5-