Skip to main content
Glama
blackwhite084

Playwright Server MCP

playwright_navigate

Use Playwright Server MCP to automatically create a session and navigate to a specified URL for web automation tasks, enabling efficient interaction and script execution on web pages.

Instructions

Navigate to a URL,thip op will auto create a session

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYes

Implementation Reference

  • The NavigateToolHandler class implements the core logic for the 'playwright_navigate' tool. It checks for an active session (auto-creating one if needed), navigates to the specified URL using Playwright's page.goto(), retrieves page text content, and returns a confirmation message with a preview of the page text.
    class NavigateToolHandler(ToolHandler): async def handle(self, name: str, arguments: dict | None) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]: if not self._sessions: await NewSessionToolHandler().handle("",{}) # return [types.TextContent(type="text", text="No active session. Please create a new session first.")] session_id = list(self._sessions.keys())[-1] page = self._sessions[session_id]["page"] url = arguments.get("url") if not url.startswith("http://") and not url.startswith("https://"): url = "https://" + url await page.goto(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]}")]
  • JSON Schema definition for the 'playwright_navigate' tool input, requiring a 'url' string parameter.
    types.Tool( name="playwright_navigate", description="Navigate to a URL,thip op will auto create a session", inputSchema={ "type": "object", "properties": { "url": {"type": "string"} }, "required": ["url"] } ),
  • Registration of the 'playwright_navigate' tool handler in the tool_handlers dictionary, mapping the tool name to an instance of NavigateToolHandler.
    "playwright_navigate": NavigateToolHandler(),
  • The general tool dispatcher handler that routes tool calls to the specific handler based on the tool_handlers dictionary.
    @server.call_tool() async def handle_call_tool( name: str, arguments: dict | None ) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]: """ Handle tool execution requests. Tools can modify server state and notify clients of changes. """ if name in tool_handlers: return await tool_handlers[name].handle(name, arguments) else: raise ValueError(f"Unknown tool: {name}")

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

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