reason_mcts
Solve complex problems by applying Monte Carlo Tree Search reasoning to analyze tasks and generate optimal solutions.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | The problem or task to reason about using MCTS |
Implementation Reference
- src/tools/reasoning-wrapper.ts:16-64 (handler)The handler function for 'reason_mcts' tool that simulates automatic 3-step MCTS reasoning process and returns structured JSON output.async ({ query }) => { try { // Initialize first thought const totalThoughts = 3; let currentThought = `MCTS Reasoning (Step 1/${totalThoughts}): Initial analysis of the problem "${query}":\n\n` + `First, let me understand what we're trying to solve here. ${query}\n\n` + `[This would be the initial MCTS-based reasoning]`; let thoughtNumber = 1; let complete = false; let allThoughts = [currentThought]; // Automatically iterate through all thoughts while (!complete && thoughtNumber < totalThoughts) { // Simulate next thought generation thoughtNumber++; const nextThought = `MCTS Reasoning (Step ${thoughtNumber}/${totalThoughts}): ` + `Based on previous analysis "${currentThought.slice(0, 50)}...", ` + `further exploration with 50 simulations suggests...\n\n` + `[This would be the next step of MCTS-based reasoning for: ${query}]`; allThoughts.push(nextThought); currentThought = nextThought; // Check if we've reached the final thought if (thoughtNumber >= totalThoughts) { complete = true; } } // Final result with all thoughts return { content: [ { type: "text", text: JSON.stringify({ strategy: "mcts", originalPrompt: query, allThoughts: allThoughts, thoughtNumber: thoughtNumber, totalThoughts: totalThoughts, complete: true }, null, 2) } ] }; } catch (error) { throw new ReasoningError(`MCTS reasoning command failed: ${error instanceof Error ? error.message : String(error)}`); } }
- src/tools/reasoning-wrapper.ts:13-15 (schema)Zod schema defining the input 'query' parameter for the reason_mcts tool.{ query: z.string().describe("The problem or task to reason about using MCTS") },
- src/tools/reasoning-wrapper.ts:11-65 (registration)Registers the 'reason_mcts' tool on the MCP server within the registerCommandWrappers function.server.tool( "reason_mcts", { query: z.string().describe("The problem or task to reason about using MCTS") }, async ({ query }) => { try { // Initialize first thought const totalThoughts = 3; let currentThought = `MCTS Reasoning (Step 1/${totalThoughts}): Initial analysis of the problem "${query}":\n\n` + `First, let me understand what we're trying to solve here. ${query}\n\n` + `[This would be the initial MCTS-based reasoning]`; let thoughtNumber = 1; let complete = false; let allThoughts = [currentThought]; // Automatically iterate through all thoughts while (!complete && thoughtNumber < totalThoughts) { // Simulate next thought generation thoughtNumber++; const nextThought = `MCTS Reasoning (Step ${thoughtNumber}/${totalThoughts}): ` + `Based on previous analysis "${currentThought.slice(0, 50)}...", ` + `further exploration with 50 simulations suggests...\n\n` + `[This would be the next step of MCTS-based reasoning for: ${query}]`; allThoughts.push(nextThought); currentThought = nextThought; // Check if we've reached the final thought if (thoughtNumber >= totalThoughts) { complete = true; } } // Final result with all thoughts return { content: [ { type: "text", text: JSON.stringify({ strategy: "mcts", originalPrompt: query, allThoughts: allThoughts, thoughtNumber: thoughtNumber, totalThoughts: totalThoughts, complete: true }, null, 2) } ] }; } catch (error) { throw new ReasoningError(`MCTS reasoning command failed: ${error instanceof Error ? error.message : String(error)}`); } } );
- src/index.ts:22-23 (registration)Top-level registration where registerCommandWrappers is called to add the reason_mcts tool to the server.registerReasoningTools(server); registerCommandWrappers(server);