Skip to main content
Glama
stat-guy

Chain of Draft (CoD) MCP Server

by stat-guy

math_solve

Solve math problems using Chain of Draft reasoning to generate minimal intermediate steps, reducing token usage while maintaining accuracy.

Instructions

Solve a math problem using Chain of Draft reasoning

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
problemYesThe math problem to solve
approachNoForce 'CoD' or 'CoT' approach
max_words_per_stepNoMaximum words per reasoning step

Implementation Reference

  • Primary handler for the 'math_solve' MCP tool. Registered via @app.tool() decorator in FastMCP. Delegates to chain_of_draft_solve with domain set to 'math'.
    @app.tool()
    async def math_solve(
        problem: str,
        approach: str = None,
        max_words_per_step: int = None
    ) -> str:
        """Solve a math problem using Chain of Draft reasoning.
        
        Args:
            problem: The math problem to solve
            approach: Force "CoD" or "CoT" approach (default: auto-select)
            max_words_per_step: Maximum words per step (default: adaptive)
        """
        return await chain_of_draft_solve(
            problem=problem,
            domain="math",
            approach=approach,
            max_words_per_step=max_words_per_step
        )
  • Core helper function implementing the Chain of Draft reasoning logic, used by math_solve and other domain tools.
    @app.tool()
    async def chain_of_draft_solve(
        problem: str,
        domain: str = "general",
        max_words_per_step: int = None,
        approach: str = None,
        enforce_format: bool = True,
        adaptive_word_limit: bool = True
    ) -> str:
        """Solve a reasoning problem using Chain of Draft approach.
        
        Args:
            problem: The problem to solve
            domain: Domain for context (math, logic, code, common-sense, etc.)
            max_words_per_step: Maximum words per reasoning step (default: adaptive)
            approach: Force "CoD" or "CoT" approach (default: auto-select)
            enforce_format: Whether to enforce the word limit (default: True)
            adaptive_word_limit: Adjust word limits based on complexity (default: True)
        """
        # Track execution time
        start_time = time.time()
        
        # Process the request with the client
        result = await cod_client.solve_with_reasoning(
            problem=problem,
            domain=domain,
            max_words_per_step=max_words_per_step,
            approach=approach,
            enforce_format=enforce_format,
            adaptive_word_limit=adaptive_word_limit
        )
        
        # Calculate execution time
        execution_time = (time.time() - start_time) * 1000  # ms
        
        # Format the response
        formatted_response = (
            f"Chain of {result['approach']} reasoning ({result['word_limit']} word limit):\n\n"
            f"{result['reasoning_steps']}\n\n"
            f"Final answer: {result['final_answer']}\n\n"
            f"Stats: {result['token_count']} tokens, {execution_time:.0f}ms, "
            f"complexity score: {result['complexity']}"
        )
        
        return formatted_response
  • Explicit input schema definition for the math_solve tool in the JavaScript MCP server.
    const MATH_TOOL = {
      name: "math_solve",
      description: "Solve a math problem using Chain of Draft reasoning",
      inputSchema: {
        type: "object",
        properties: {
          problem: {
            type: "string",
            description: "The math problem to solve"
          },
          approach: {
            type: "string",
            description: "Force 'CoD' or 'CoT' approach"
          },
          max_words_per_step: {
            type: "number",
            description: "Maximum words per reasoning step"
          }
        },
        required: ["problem"]
      }
    };
  • Handler block for 'math_solve' tool execution in the JavaScript MCP server call handler.
    if (name === "math_solve") {
      const result = await chainOfDraftClient.solveWithReasoning({
        ...args,
        domain: "math"
      });
      
      const formattedResponse = 
        `Chain of ${result.approach} reasoning (${result.word_limit} word limit):\n\n` +
        `${result.reasoning_steps}\n\n` +
        `Final answer: ${result.final_answer}\n\n` +
        `Stats: ${result.token_count} tokens, ${result.execution_time_ms.toFixed(0)}ms, ` +
        `complexity score: ${result.complexity}`;
      
      return {
        content: [{
          type: "text",
          text: formattedResponse
        }]
      };
    }
  • index.js:581-591 (registration)
    Registration of math_solve tool (as MATH_TOOL) in the ListTools request handler for the JS MCP server.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: [
        CHAIN_OF_DRAFT_TOOL,
        MATH_TOOL,
        CODE_TOOL,
        LOGIC_TOOL,
        PERFORMANCE_TOOL,
        TOKEN_TOOL,
        COMPLEXITY_TOOL
      ],
    }));
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions 'Chain of Draft reasoning' but does not explain what this means in practice, such as how it processes the problem, what output to expect, or any limitations (e.g., accuracy, computational constraints). This lack of detail makes it inadequate for a tool with no annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It is front-loaded and appropriately sized, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a math-solving tool with no annotations and no output schema, the description is incomplete. It lacks details on how the tool behaves, what the output looks like, or any error conditions. This makes it insufficient for an agent to understand the tool's full context and usage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all parameters ('problem', 'approach', 'max_words_per_step') with descriptions. The description does not add any meaning beyond this, such as clarifying the 'approach' parameter's 'CoD' or 'CoT' options or providing examples. Baseline 3 is appropriate when the schema handles parameter documentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states the tool 'Solve[s] a math problem using Chain of Draft reasoning', which provides a verb ('Solve') and resource ('math problem') but is vague about what 'Chain of Draft reasoning' entails. It distinguishes from some siblings like 'code_solve' or 'logic_solve' by specifying 'math problem', but the distinction from 'chain_of_draft_solve' is unclear, as both mention 'Chain of Draft'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No explicit guidance is provided on when to use this tool versus alternatives. The description mentions 'Chain of Draft reasoning' but does not explain when this approach is preferred over other methods or tools like 'analyze_problem_complexity' or 'chain_of_draft_solve'. This leaves the agent without clear usage context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/stat-guy/chain-of-draft'

If you have feedback or need assistance with the MCP directory API, please join our Discord server