Skip to main content
Glama

playwright_navigate

Automate browser navigation by visiting a specified URL with a session automatically created, ideal for web testing and interaction tasks within browser automation workflows.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYes

Implementation Reference

  • The NavigateToolHandler class provides the core implementation for the 'playwright_navigate' tool. It ensures an active browser session exists (creating one if necessary), navigates the page to the specified URL, fetches the page's text content using another tool, and returns a confirmation with a preview of the text content.
    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]}")]
  • Defines the tool schema returned by list_tools(), including name, description, and JSON input schema 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"] } ),
  • Registers the NavigateToolHandler instance in the tool_handlers dictionary, which is used by the @server.call_tool() handler to dispatch tool calls to the appropriate implementation.
    tool_handlers = { "playwright_navigate": NavigateToolHandler(), "playwright_screenshot": ScreenshotToolHandler(), "playwright_click": ClickToolHandler(), "playwright_fill": FillToolHandler(), "playwright_evaluate": EvaluateToolHandler(), "playwright_click_text": ClickTextToolHandler(), "playwright_get_text_content": GetTextContentToolHandler(), "playwright_get_html_content": GetHtmlContentToolHandler(), "playwright_new_session":NewSessionToolHandler(), }

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

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