Skip to main content
Glama
ashley-ha

MCP Browser Agent

by ashley-ha

get_planner_state

Retrieves current browser state and planning context to determine next actions for web automation tasks.

Instructions

Get the current browser state and planning context. This tool must be executed before execute_actions tool.

Must return a JSON string in the format:
{
    "current_state": {
        "evaluation_previous_goal": "Success|Failed|Unknown - Analysis of previous actions",
        "memory": "Description of what has been done and what to remember",
        "next_goal": "What needs to be done with the next immediate action"
    },
    "action": [
        {"action_name": {"param1": "value1", ...}},
        ...
    ]
}

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function for the 'get_planner_state' tool. Decorated with @mcp.tool() for registration. Retrieves browser context, state, interactive elements, and available actions, then formats and returns a JSON string with planning context and browser state information.
    async def get_planner_state(ctx: Context) -> str:
        """Get the current browser state and planning context.
        This tool must be executed before execute_actions tool.
        
        Must return a JSON string in the format:
        {
            "current_state": {
                "evaluation_previous_goal": "Success|Failed|Unknown - Analysis of previous actions",
                "memory": "Description of what has been done and what to remember",
                "next_goal": "What needs to be done with the next immediate action"
            },
            "action": [
                {"action_name": {"param1": "value1", ...}},
                ...
            ]
        }
        """
        try:
            browser_context = await browser_initialized_check()
            controller = ctx.request_context.lifespan_context.get("controller")
            
            if controller is None:
                controller = Controller()
                ctx.request_context.lifespan_context["controller"] = controller
            
            state = await browser_context.get_state()
            elements_text = state.element_tree.clickable_elements_to_string() # dom to html step -- basically gets elements on the page and returns for text representation input to llm
            
            # Get available actions from the controller's registry
            available_actions = controller.registry.get_prompt_description() # gets the action descriptions from the controller
            
            # Format the response according to system prompt
            response = {
                "current_state": {
                    "evaluation_previous_goal": "Unknown - No previous actions to evaluate",
                    "memory": "Starting new browser session",
                    "next_goal": "Ready to execute browser actions"
                },
                "action": []  # Empty action list - actions will be specified by the caller
            }
            
            # Add browser state information
            state_info = f"""
                Current URL: {state.url}
                Title: {state.title}
                Available tabs: {[tab.model_dump() for tab in state.tabs]}
                Interactive elements:
                {elements_text}
    
                Available Actions:
                {available_actions}
    
                Note: Actions should be executed using the execute_actions tool with the following format:
                {{
                    "name": "action_name",
                    "params": {{
                        "param1": "value1",
                        ...
                    }}
                }}
                """
            return json.dumps(response, indent=2) + "\n\nBrowser State:\n" + state_info
        except Exception as e:
            logger.error(f"Error getting planner state: {str(e)}")
            return f"Error getting planner state: {str(e)}"
Behavior4/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 effectively describes key behavioral traits: it's a read operation ('Get'), it returns specific structured data (a JSON string with defined format), and it has a prerequisite relationship with another tool. It doesn't cover aspects like error handling or performance, but for a zero-parameter tool with no annotations, this is reasonably comprehensive.

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

Conciseness3/5

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

The description is front-loaded with the core purpose and usage guideline in the first two sentences, which is good. However, it includes a detailed JSON format specification that might be better suited for an output schema. While this adds value, it makes the description longer than necessary for conciseness, as the output details could be separated into structured data.

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

Completeness4/5

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

Given the tool has 0 parameters, no annotations, and no output schema, the description provides good contextual completeness. It explains the purpose, usage guidelines, and output format in detail. The only gap is the lack of an output schema, but the description compensates by specifying the return format explicitly, making it sufficient for the agent to understand how to use the tool.

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

Parameters4/5

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

The tool has 0 parameters with 100% schema description coverage, so the baseline is 4. The description doesn't need to add parameter information, and it doesn't attempt to, which is appropriate. No parameters are present to document, so this score reflects that the description doesn't introduce confusion or redundancy regarding inputs.

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

Purpose4/5

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

The description clearly states the tool's purpose: 'Get the current browser state and planning context.' It specifies the verb ('Get') and resource ('browser state and planning context'), making it easy to understand what the tool does. However, it doesn't explicitly differentiate from its sibling tool 'execute_actions' beyond stating a prerequisite relationship, which is more about usage than purpose distinction.

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

Usage Guidelines5/5

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

The description provides explicit usage guidance: 'This tool must be executed before execute_actions tool.' It clearly states when to use this tool (as a prerequisite for 'execute_actions') and implies an alternative (use 'execute_actions' after this). This is a strong, directive guideline that helps the agent understand the tool's role in the workflow.

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/ashley-ha/mcp-manus'

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