Skip to main content
Glama
parmarjh

MCP Reasoner

by parmarjh

mcp-reasoner

Facilitates complex problem-solving using advanced reasoning strategies like Beam Search and Monte Carlo Tree Search to analyze and progress through multiple logical steps.

Instructions

Advanced reasoning tool with multiple strategies including Beam Search and Monte Carlo Tree Search

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nextThoughtNeededYesWhether another step is needed
strategyTypeNoReasoning strategy to use (beam_search or mcts)
thoughtYesCurrent reasoning step
thoughtNumberYesCurrent step number
totalThoughtsYesTotal expected steps

Implementation Reference

  • src/index.ts:49-83 (registration)
    Registers the 'mcp-reasoner' tool for ListTools requests, including name, description, and input schema.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: [{
        name: "mcp-reasoner",
        description: "Advanced reasoning tool with multiple strategies including Beam Search and Monte Carlo Tree Search",
        inputSchema: {
          type: "object",
          properties: {
            thought: {
              type: "string",
              description: "Current reasoning step"
            },
            thoughtNumber: {
              type: "integer",
              description: "Current step number",
              minimum: 1
            },
            totalThoughts: {
              type: "integer",
              description: "Total expected steps",
              minimum: 1
            },
            nextThoughtNeeded: {
              type: "boolean",
              description: "Whether another step is needed"
            },
            strategyType: {
              type: "string",
              enum: Object.values(ReasoningStrategy),
              description: "Reasoning strategy to use (beam_search or mcts)"
            }
          },
          required: ["thought", "thoughtNumber", "totalThoughts", "nextThoughtNeeded"]
        }
      }]
    }));
  • Executes the 'mcp-reasoner' tool: validates input, delegates to Reasoner.processThought, augments response with stats and returns JSON.
    server.setRequestHandler(CallToolRequestSchema, async (request) => {
      if (request.params.name !== "mcp-reasoner") {
        return {
          content: [{
            type: "text",
            text: JSON.stringify({ error: "Unknown tool", success: false })
          }],
          isError: true
        };
      }
    
      try {
        // Process and validate input
        const step = processInput(request.params.arguments);
    
        // Process thought with selected strategy
        const response = await reasoner.processThought({
          thought: step.thought,
          thoughtNumber: step.thoughtNumber,
          totalThoughts: step.totalThoughts,
          nextThoughtNeeded: step.nextThoughtNeeded,
          strategyType: step.strategyType
        });
    
        // Get reasoning stats
        const stats = await reasoner.getStats();
    
        // Return enhanced response
        const result = {
          thoughtNumber: step.thoughtNumber,
          totalThoughts: step.totalThoughts,
          nextThoughtNeeded: step.nextThoughtNeeded,
          thought: step.thought,
          nodeId: response.nodeId,
          score: response.score,
          strategyUsed: response.strategyUsed,
          stats: {
            totalNodes: stats.totalNodes,
            averageScore: stats.averageScore,
            maxDepth: stats.maxDepth,
            branchingFactor: stats.branchingFactor,
            strategyMetrics: stats.strategyMetrics
          }
        };
    
        return {
          content: [{
            type: "text",
            text: JSON.stringify(result)
          }]
        };
      } catch (error) {
        return {
          content: [{
            type: "text",
            text: JSON.stringify({
              error: error instanceof Error ? error.message : String(error),
              success: false
            })
          }],
          isError: true
        };
      }
    });
  • Helper function to validate and type-coerce tool input parameters.
    function processInput(input: any) {
      const result = {
        thought: String(input.thought || ""),
        thoughtNumber: Number(input.thoughtNumber || 0),
        totalThoughts: Number(input.totalThoughts || 0),
        nextThoughtNeeded: Boolean(input.nextThoughtNeeded),
        strategyType: input.strategyType as ReasoningStrategy | undefined
      };
    
      // Validate
      if (!result.thought) {
        throw new Error("thought must be provided");
      }
      if (result.thoughtNumber < 1) {
        throw new Error("thoughtNumber must be >= 1");
      }
      if (result.totalThoughts < 1) {
        throw new Error("totalThoughts must be >= 1");
      }
    
      return result;
    }
  • Core reasoning handler in Reasoner class: selects strategy and delegates processing, adds strategy info to response.
    public async processThought(request: ReasoningRequest): Promise<ReasoningResponse> {
      // Switch strategy if requested
      if (request.strategyType && this.strategies.has(request.strategyType as ReasoningStrategy)) {
        this.currentStrategy = this.strategies.get(request.strategyType as ReasoningStrategy)!;
      }
    
      // Process thought using current strategy
      const response = await this.currentStrategy.processThought(request);
    
      // Add strategy information to response
      return {
        ...response,
        strategyUsed: this.getCurrentStrategyName()
      };
    }
  • Factory for creating reasoning strategy instances (Beam Search or MCTS) used by the Reasoner.
    export class StrategyFactory {
      static createStrategy(
        type: ReasoningStrategy,
        stateManager: StateManager
      ): BaseStrategy {
        switch (type) {
          case ReasoningStrategy.BEAM_SEARCH:
            return new BeamSearchStrategy(stateManager);
          case ReasoningStrategy.MCTS:
            return new MonteCarloTreeSearchStrategy(stateManager);
          default:
            throw new Error(`Unknown strategy type: ${type}`);
        }
      }
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. It mentions 'Advanced reasoning' and strategies, but doesn't disclose behavioral traits such as whether it's read-only or destructive, performance characteristics, error handling, or output format. This leaves significant gaps in understanding how the tool behaves beyond its basic function.

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

Conciseness4/5

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

The description is a single, efficient sentence that front-loads key information ('Advanced reasoning tool') and includes strategy examples. It avoids unnecessary details, but could be slightly more structured by explicitly stating the tool's output or use case to improve clarity without adding length.

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 reasoning tool with multiple strategies and no output schema, the description is incomplete. It doesn't explain what the tool returns (e.g., reasoning results, next steps), how strategies affect outcomes, or any limitations. With no annotations and rich parameters, more context is needed for effective use by an AI agent.

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 thoroughly. The description adds no additional meaning about parameters beyond what's in the schema, such as explaining the relationship between thought steps or strategy implications. Baseline 3 is appropriate as the schema handles parameter documentation adequately.

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 this is an 'Advanced reasoning tool with multiple strategies' which provides a general purpose, but it's vague about what specific reasoning it performs (e.g., problem-solving, decision-making) and lacks a clear verb+resource combination. It mentions strategies like Beam Search and Monte Carlo Tree Search, which gives some context but doesn't specify the domain or output of the reasoning process.

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?

There is no guidance on when to use this tool versus alternatives, as no sibling tools are listed, and the description doesn't provide context for its application (e.g., for complex problems, iterative reasoning). It implies usage through strategy mentions but lacks explicit when/when-not instructions or prerequisites.

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

Related 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/parmarjh/mcp-reasoner'

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