Skip to main content
Glama
Chain of Draft (CoD) MCP Server

Chain of Draft (CoD) MCP Server

by stat-guy

チェーン・オブ・ドラフト(CoD)MCPサーバー

概要

このMCPサーバーは、研究論文「Chain of Draft:より少ない文章でより速く考える」で説明されているChain of Draft(CoD)推論アプローチを実装しています。CoDは、LLMがタスクを解決しながら最小限ながらも有益な中間推論出力を生成することを可能にする新しいパラダイムであり、トークンの使用量を大幅に削減しながら精度を維持します。

Related MCP server: Visum Thinker MCP Server

主なメリット

  • 効率性: トークン使用量が大幅に削減されます (標準 CoT のわずか 7.6%)

  • 速度: 生成時間が短いため応答が速い

  • コスト削減: LLM呼び出しのAPIコストの削減

  • 維持された精度: CoTと比較して同等またはそれ以上の精度

  • 柔軟性:さまざまな推論タスクやドメインに適用可能

特徴

  1. ドラフト実装のコアチェーン

    • 簡潔な推論手順(通常 5 語以下)

    • フォーマットの強制

    • 回答抽出

  2. パフォーマンス分析

    • トークン使用状況の追跡

    • ソリューション精度の監視

    • 実行時間の測定

    • ドメイン固有のパフォーマンスメトリック

  3. 適応型単語制限

    • 自動複雑度推定

    • 単語数制限の動的調整

    • ドメイン固有のキャリブレーション

  4. 包括的なサンプルデータベース

    • CoTからCoDへの変換

    • 分野固有の例(数学、コード、生物学、物理学、化学、パズル)

    • 問題の類似性に基づく例の検索

  5. フォーマットの強制

    • 文字数制限を遵守するための後処理

    • ステップ構造の保存

    • 遵守分析

  6. ハイブリッド推論アプローチ

    • CoDとCoTの自動選択

    • ドメイン固有の最適化

    • 過去の実績に基づく選抜

  7. OpenAI APIの互換性

    • 標準の OpenAI クライアントの代替品

    • 補完とチャットインターフェースの両方をサポート

    • 既存のワークフローへの簡単な統合

セットアップとインストール

前提条件

  • Python 3.10+ (Python実装用)

  • Node.js 18+(JavaScript実装用)

  • アントロピックAPIキー

Pythonのインストール

  1. リポジトリをクローンする

  2. 依存関係をインストールします:

    pip install -r requirements.txt
  3. .envファイルで API キーを設定します。

    ANTHROPIC_API_KEY=your_api_key_here
  4. サーバーを実行します。

    python server.py

JavaScriptのインストール

  1. リポジトリをクローンする

  2. 依存関係をインストールします:

    npm install
  3. .envファイルで API キーを設定します。

    ANTHROPIC_API_KEY=your_api_key_here
  4. サーバーを実行します。

    node index.js

クロードデスクトップ統合

Claude Desktop と統合するには:

  1. claude.ai/downloadからClaude Desktopをインストールします。

  2. Claude Desktop 構成ファイルを作成または編集します。

    ~/Library/Application Support/Claude/claude_desktop_config.json
  3. サーバー構成を追加します (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"
                }
            }
        }
    }
  4. 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_solve

ドラフトの連鎖推論を使って問題を解決する

math_solve

CoDで数学の問題を解く

code_solve

CoDでコーディングの問題を解決する

logic_solve

CoDで論理問題を解く

get_performance_stats

CoDとCoTのパフォーマンス統計を取得する

get_token_reduction

トークン削減統計を取得する

analyze_problem_complexity

問題の複雑さを分析する

開発者の使用

Pythonクライアント

Chain of Draft クライアントを Python コード内で直接使用する場合:

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実装

  1. AnalyticsService : さまざまな問題領域と推論アプローチにわたるパフォーマンス指標を追跡します

  2. ComplexityEstimator : 問題を分析して適切な単語数制限を決定する

  3. ExampleDatabase : CoT の例を CoD 形式に変換して、例を管理および取得します。

  4. FormatEnforcer : 推論ステップが単語数制限を遵守していることを確認する

  5. ReasoningSelector : 問題の特性に基づいて CoD と CoT をインテリジェントに選択します

JavaScript実装

  1. analyticsDb : パフォーマンスメトリックを追跡するためのインメモリデータベース

  2. 複雑さ推定器: 問題を分析して複雑さと適切な単語制限を決定します

  3. formatEnforcer : 推論ステップが単語数制限を遵守していることを確認する

  4. 推論セレクター: 問題の特性と過去のパフォーマンスに基づいて、CoD と CoT を自動的に選択します。

どちらの実装も同じコア原則に従い、同一の MCP ツールを提供するため、ほとんどのユースケースで互換性があります。

ライセンス

このプロジェクトはオープンソースであり、MIT ライセンスの下で利用できます。

Available Tools

7 tools
analyze_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

    B3.1/5.0

    Scored across 7 tools

    Disambiguation3/5

    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.

    Naming Consistency4/5

    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.

    Tool Count5/5

    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.

    Completeness4/5

    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

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers