Skip to main content
Glama
ziux

Playwright Server MCP

by ziux

playwright_navigate

Automate web browser navigation to a specified URL; creates a new session if none exists. Simplify web interactions with Playwright Server MCP‘s browser control capabilities.

Instructions

浏览器导航到指定网址,如果没有活跃的浏览器会话,会自动创建一个新会话

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYes需要访问的网址,如不包含http或https前缀将自动添加https://

Implementation Reference

  • The core handler function that executes the playwright_navigate tool: checks for active session, navigates to the provided URL using page.goto(), fetches page text content, and returns success message.
    async def handle(self, name: str, arguments: dict | None) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]:
        logger.info("开始浏览器导航操作")
        if not self._sessions:
            logger.warning("没有活跃的会话,正在创建新会话")
            await NewSessionToolHandler().handle("",{})
            # return [types.TextContent(type="text", text="No active session. Please create a new session first.")]
        try:
            page = self.get_page()
            url = arguments.get("url")
            if not url.startswith("http://") and not url.startswith("https://"):
                url = "https://" + url
            logger.info(f"正在导航到 URL: {url}")
            await page.goto(url)
            logger.debug(f"导航完成, 当前URL: {page.url}")
            text_content=await GetTextContentToolHandler().handle("",{})
            return [types.TextContent(type="text", text=f"Navigated to {url}\npage_text_content[:200]:\n\n{text_content[:200]}")]
        except Exception as e:
            logger.error(f"导航失败: {str(e)}", exc_info=True)
            return [types.TextContent(type="text", text=f"导航失败: {str(e)}")]
  • Tool metadata including name, description, and inputSchema defining the 'url' parameter for the playwright_navigate tool.
    class NavigateToolHandler(ToolHandler):
        name = "playwright_navigate"
        description = "浏览器导航到指定网址,如果没有活跃的浏览器会话,会自动创建一个新会话"
        inputSchema = [
            Property(name="url", typ="string", description="需要访问的网址,如不包含http或https前缀将自动添加https://")
        ]
  • Instantiates NavigateToolHandler and registers it in tool_handler_list and tool_handlers dict, which is used in list_tools() and call_tool() for MCP server.
    tool_handler_list = [
        NavigateToolHandler(),
        # ScreenshotToolHandler(),
        EvaluateToolHandler(),
        GetTextContentToolHandler(),
        GetHtmlContentToolHandler(),
        NewSessionToolHandler(),
        ActionToolHandler()
    ]
    
    # 根据每个处理程序的 name 属性创建字典
    tool_handlers = {handler.name: handler for handler in tool_handler_list}
  • The to_tool classmethod in base ToolHandler converts handler metadata to MCP Tool object, used during registration in list_tools().
    def to_tool(cls) -> types.Tool:
        return types.Tool(
            name=cls.name,
            description=cls.description,
            inputSchema={
                "type": "object",
                "properties": {
                        property.name: {
                        "type": property.typ,
                        "description": property.description
                    }
                    for property in cls.inputSchema
                },
                "required": [property.name for property in cls.inputSchema if property.required]
            }
        )
  • MCP server endpoint that lists tools by calling to_tool() on registered handlers, exposing playwright_navigate.
    @server.list_tools()
    async def handle_list_tools() -> list[types.Tool]:
        """
        List available tools.
        Each tool specifies its arguments using JSON Schema validation.
        """
        logger.debug("处理 list_tools 请求")
        return [
            tool_handler.to_tool() for tool_handler in tool_handlers.values()
        ]
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden. It discloses key behavioral traits: automatic session creation if none exists, which is useful context beyond basic navigation. However, it lacks details on error handling, timeout behavior, or what happens after navigation (e.g., page load completion), leaving gaps for a mutation tool.

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

Conciseness5/5

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

The description is appropriately sized and front-loaded: a single, efficient sentence in Chinese that states the core action and key behavioral trait. Every part earns its place with no wasted words, making it highly concise and well-structured.

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

Completeness3/5

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

Given the tool's complexity (navigation with session management), no annotations, and no output schema, the description is minimally adequate. It covers the main action and a critical behavioral aspect (session creation), but lacks details on return values, error cases, or interaction with siblings, leaving room for improvement.

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?

The schema description coverage is 100%, with the parameter 'url' fully documented in the schema. The description adds no additional parameter semantics beyond what the schema provides (e.g., no extra syntax or format details). According to the rules, baseline is 3 when schema coverage is high (>80%).

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: '浏览器导航到指定网址' (browser navigates to specified URL). It uses a specific verb ('导航到' - navigate to) and resource ('指定网址' - specified URL). However, it doesn't explicitly distinguish from sibling tools like 'playwright_action' or 'playwright_new_session', which prevents a score of 5.

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

Usage Guidelines3/5

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

The description provides implied usage guidance: '如果没有活跃的浏览器会话,会自动创建一个新会话' (if there's no active browser session, it will automatically create a new one). This suggests when to use it (for navigation with session handling) but doesn't explicitly compare to alternatives like 'playwright_new_session' or specify when not to use it, keeping it at a 3.

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/ziux/playwright-plus-python-mcp'

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