new_page
Launch a new browser page with a specified ID for automation tasks using Playwright MCP, enabling precise control over browser interactions.
Instructions
Create a new browser page
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| page_id | Yes |
Input Schema (JSON Schema)
{
"properties": {
"page_id": {
"type": "string"
}
},
"required": [
"page_id"
],
"type": "object"
}
Implementation Reference
- src/playwright_mcp/server.py:291-303 (handler)Handler implementation for the 'new_page' tool within the @server.call_tool() function. Validates the page_id argument, creates a new Playwright BrowserContext page, stores it in the global 'pages' dictionary, sets it as the current page, and returns a success message.elif name == "new_page": page_id = arguments.get("page_id") if not page_id: raise ValueError("Page ID is required") if page_id in pages: raise ValueError(f"Page ID '{page_id}' already exists") new_page = await context.new_page() pages[page_id] = new_page current_page_id = page_id return [types.TextContent(type="text", text=f"Created new page with ID: {page_id}")]
- src/playwright_mcp/server.py:155-165 (schema)Schema definition and registration of the 'new_page' tool in the @server.list_tools() response. Specifies the tool name, description, and input schema requiring a 'page_id' string.types.Tool( name="new_page", description="Create a new browser page", inputSchema={ "type": "object", "properties": { "page_id": {"type": "string"}, }, "required": ["page_id"], }, ),