code_solve
Solve coding problems using Chain of Draft reasoning to generate minimal intermediate outputs, reducing token usage while maintaining accuracy.
Instructions
Solve a coding problem using Chain of Draft reasoning
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| problem | Yes | The coding problem to solve | |
| approach | No | Force 'CoD' or 'CoT' approach | |
| max_words_per_step | No | Maximum words per reasoning step |
Implementation Reference
- server.py:102-120 (handler)Python handler for code_solve MCP tool. Registered via @app.tool() decorator. Delegates to chain_of_draft_solve with domain="code".@app.tool() async def code_solve( problem: str, approach: str = None, max_words_per_step: int = None ) -> str: """Solve a coding problem using Chain of Draft reasoning. Args: problem: The coding 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="code", approach=approach, max_words_per_step=max_words_per_step )
- index.js:639-658 (handler)JavaScript handler for code_solve tool execution within the CallToolRequestSchema handler. Delegates to chainOfDraftClient.solveWithReasoning with domain="code".// Code solver if (name === "code_solve") { const result = await chainOfDraftClient.solveWithReasoning({ ...args, domain: "code" }); 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:482-503 (schema)Input schema definition for the code_solve tool in JavaScript implementation.const CODE_TOOL = { name: "code_solve", description: "Solve a coding problem using Chain of Draft reasoning", inputSchema: { type: "object", properties: { problem: { type: "string", description: "The coding 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"] } };
- index.js:581-591 (registration)Registration of code_solve (via CODE_TOOL) in the list of tools returned by ListToolsRequestSchema.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [ CHAIN_OF_DRAFT_TOOL, MATH_TOOL, CODE_TOOL, LOGIC_TOOL, PERFORMANCE_TOOL, TOKEN_TOOL, COMPLEXITY_TOOL ], }));