Skip to main content
Glama

initialize_mcts

Initialize Monte Carlo Tree Search (MCTS) for in-depth analysis of a specific question using a specified LLM provider and model, supporting structured conversational exploration.

Instructions

Initialize MCTS for a question

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
chat_idNoUnique identifier for this conversationdefault
modelNoModel name (optional)
providerNoLLM providergemini
questionYesThe question to analyze

Implementation Reference

  • The primary handler function that executes the initialize_mcts tool logic. Validates the input parameters, checks for required Gemini API key, initializes and updates the global server_state dictionary with the provided question, chat_id, provider, and model, resets MCTS progress counters, sets initialized flag to True, logs the initialization, and returns a status dictionary with configuration details.
    async def initialize_mcts(
        question: str,
        chat_id: str = "default",
        provider: str = "gemini",
        model: str | None = None
    ) -> dict[str, Any]:
        """
        Initialize MCTS for a question.
    
        Args:
            question: The question or topic to analyze
            chat_id: Unique identifier for this conversation session
            provider: LLM provider to use (currently only 'gemini' supported)
            model: Specific model name to use (optional, defaults to gemini-2.0-flash-lite)
    
        Returns:
            Dict containing initialization status, configuration, and any error messages
    
        Raises:
            Exception: If initialization fails due to missing API key or other errors
        """
        try:
            # Validate inputs
            if not question.strip():
                return {"error": "Question cannot be empty", "status": "error"}
    
            if provider.lower() != "gemini":
                return {"error": "Only 'gemini' provider is currently supported", "status": "error"}
    
            # Check if API key is available
            api_key = os.getenv("GEMINI_API_KEY") or os.getenv("GOOGLE_API_KEY")
            if not api_key:
                return {
                    "error": "GEMINI_API_KEY or GOOGLE_API_KEY environment variable required",
                    "status": "error",
                    "setup_help": "Set your API key with: export GEMINI_API_KEY='your-key-here'"
                }
    
            # Update state
            server_state.update({
                "current_question": question,
                "chat_id": chat_id,
                "provider": provider.lower(),
                "model": model or "gemini-2.0-flash-lite",
                "iterations_completed": 0,
                "best_score": 0.0,
                "best_analysis": "",
                "initialized": True
            })
    
            logger.info(f"Initialized MCTS for question: {question[:50]}...")
    
            return {
                "status": "initialized",
                "question": question,
                "chat_id": chat_id,
                "provider": server_state["provider"],
                "model": server_state["model"],
                "message": "MCTS initialized successfully. Use run_mcts_search to begin analysis."
            }
    
        except Exception as e:
            logger.error(f"Error initializing MCTS: {e}")
            return {"error": f"Initialization failed: {e!s}", "status": "error"}
  • MCP tool registration within the list_tools handler. Defines the tool name, description, and input schema specifying required 'question' parameter and optional 'chat_id', 'provider', 'model' fields.
    types.Tool(
        name="initialize_mcts",
        description="Initialize MCTS for a question",
        inputSchema={
            "type": "object",
            "properties": {
                "question": {"type": "string", "description": "The question to analyze"},
                "chat_id": {"type": "string", "description": "Unique identifier for this conversation", "default": "default"},
                "provider": {"type": "string", "description": "LLM provider", "default": "gemini"},
                "model": {"type": "string", "description": "Model name (optional)"}
            },
            "required": ["question"]
        }
    ),
  • Input schema definition for the initialize_mcts tool, outlining the expected JSON object structure with properties and requirements.
    inputSchema={
        "type": "object",
        "properties": {
            "question": {"type": "string", "description": "The question to analyze"},
            "chat_id": {"type": "string", "description": "Unique identifier for this conversation", "default": "default"},
            "provider": {"type": "string", "description": "LLM provider", "default": "gemini"},
            "model": {"type": "string", "description": "Model name (optional)"}
        },
        "required": ["question"]
    }
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 states 'Initialize MCTS' but doesn't explain what this does operationally (e.g., sets up state, allocates resources, requires specific permissions), what happens on failure, or any side effects. This leaves significant gaps in understanding the tool's behavior.

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 with no wasted words, making it appropriately sized. However, it lacks front-loading of critical details (e.g., purpose or key parameters), which slightly reduces its effectiveness despite its brevity.

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 initializing a system like MCTS with 4 parameters and no annotations or output schema, the description is incomplete. It fails to explain what initialization entails, what state is created, or how it interacts with sibling tools, leaving the agent with insufficient context for effective use.

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 fully documents all 4 parameters. The description adds no additional meaning beyond what's in the schema (e.g., it doesn't clarify the relationship between parameters like 'chat_id' and 'question'), resulting in a baseline score of 3 as the schema does the heavy lifting.

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 'Initialize MCTS for a question' which provides a basic verb ('Initialize') and resource ('MCTS'), but it's vague about what MCTS is and what initialization entails. It doesn't distinguish from siblings like 'run_mcts_search' or 'get_synthesis', leaving the specific purpose unclear beyond a general setup action.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites, timing (e.g., before running search), or exclusions, leaving the agent to infer usage from context without explicit direction.

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/angrysky56/mcts-mcp-server'

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