Playwright MCP Server Python
A Python Model Context Protocol (MCP) server that provides browser automation capabilities using Playwright. This server exposes a set of tools for navigating, interacting with, and extracting data from web pages.
Note: This is an independent, community-maintained Python implementation. It is not affiliated with, endorsed by, or derived from Microsoft's official Playwright MCP server (which is a Node.js/TypeScript project using accessibility snapshots). This project uses Playwright's standard Python API directly.
Features
- Navigation: Navigate to URLs, go back/forward, reload pages
- Interaction: Click elements, type text, wait for selectors
- Extraction: Get text content, page HTML, page title, URL
- Screenshots: Take full-page or element screenshots (base64 PNG via MCP resources)
- Multi-page: Create and switch between multiple browser pages
- JavaScript Evaluation: Execute arbitrary JS in page context
Installation
Obtain development version from https://github.com/themanyone/playwright-mcp-server-python.git
git clone https://github.com/themanyone/playwright-mcp-server-python.git
cd playwright-mcp-server-python
# From source
pip install -e .
# Or install with dev dependencies
pip install -e ".[dev]"
# Install Playwright browsers
playwright install chromium
Usage
As an MCP Server (stdio)
# Run with default settings (headless chromium)
playwright-mcp
# Run with custom options
playwright-mcp --headed --browser firefox --timeout 60000
# With additional browser args
playwright-mcp --browser-arg "--disable-web-security" --browser-arg "--no-sandbox"
As a Library
from playwright_mcp import create_server, ServerConfig, BrowserConfig
# Custom configuration
config = ServerConfig(
browser=BrowserConfig(
headless=True,
browser_type="chromium",
),
default_timeout=30000,
)
server = create_server(config)
await server.run_stdio()
Available Tools
| Tool | Description |
|---|---|
navigate |
Navigate to a URL |
click |
Click on an element by selector |
type |
Type text into an input element |
get_text |
Get text content from an element |
get_page_content |
Get the current page HTML content |
take_screenshot |
Take a screenshot of page or element |
new_page |
Create a new browser page |
switch_page |
Switch to a different browser page |
get_pages |
List all available browser pages |
wait_for_selector |
Wait for an element to be visible |
evaluate |
Evaluate JavaScript in page context |
get_title |
Get the page title |
get_url |
Get the current page URL |
go_back |
Navigate back in history |
go_forward |
Navigate forward in history |
reload |
Reload the current page |
Resources
The server exposes screenshot resources at URIs like screenshot://{page_id}.
Configuration
BrowserConfig
| Option | Type | Default | Description |
|---|---|---|---|
headless |
bool | True |
Run browser in headless mode |
browser_type |
str | "chromium" |
Browser engine (chromium, firefox, webkit) |
args |
tuple[str] | () |
Additional browser launch arguments |
slow_mo |
float | 0.0 |
Slow down operations by ms |
devtools |
bool | False |
Open DevTools on launch |
ServerConfig
| Option | Type | Default | Description |
|---|---|---|---|
name |
str | "playwright-mcp" |
Server name |
version |
str | "0.2.0" |
Server version |
browser |
BrowserConfig | BrowserConfig() |
Browser configuration |
default_timeout |
float | 30000.0 |
Default timeout in ms |
Development
# Run tests
pytest
# Type checking
mypy playwright_mcp
# Linting
ruff check playwright_mcp
# Format
ruff format playwright_mcp
Architecture
playwright_mcp/
├── config.py # Configuration dataclasses
├── browser.py # Browser lifecycle management
├── tools.py # Tool definitions (MCP schema)
├── executor.py # Tool execution logic
├── handlers.py # MCP request handlers
├── server.py # Main server class
├── cli.py # Command-line interface
└── __main__.py # Entry point
Relationship to Other Projects
| Project | Language | Approach | MCP Transport |
|---|---|---|---|
| This project | Python | Direct Playwright API | stdio |
| microsoft/playwright-mcp | Node.js/TypeScript | Accessibility snapshots | stdio / SSE |
| microsoft/playwright-cli | Node.js | CLI + Skills | N/A (CLI) |
License
Playwright® is a trademark of Microsoft Corporation. This project is an independent implementation using the Playwright Python library under its Apache 2.0 license.
This project includes the Playwright library (also Apache 2.0 licensed by Microsoft Corporation). See NOTICE for attribution details.
Blame
Mostly vibe-coded "from scratch" with crush agent using NVIDIA: Nemotron 3 Ultra. And without consulting the original Node.js/TypeScript that had no Fedora package at the time, and could not be fixed to work with crush. Some bits contributed by themanyone. Examine source code before running. Use at your own risk.
- Fork this project on GitHub
- YouTube https://www.youtube.com/themanyone
- Mastodon https://mastodon.social/@themanyone
- Linkedin https://www.linkedin.com/in/henry-kroll-iii-93860426/
- Buy me a coffee https://buymeacoffee.com/isreality
- TheNerdShow.com
Thanks for trying out Playwright MCP Server Python!
Metadata
Release files for playwright-mcp-server-hellork 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| playwright_mcp_server_hellork-0.2.0.tar.gz | 18.6 kB | Without provenance | Details for playwright_mcp_server_hellork-0.2.0.tar.gz |
Release files / playwright_mcp_server_hellork-0.2.0.tar.gz
| Download URL | playwright_mcp_server_hellork-0.2.0.tar.gz |
|---|---|
| Size | 18.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9bc0600e6c9598eb1a5b519c44701dcbe797842c8f4f7121307d1748ccc38eba
|
|
BLAKE2b-256 checksum How to use checksums |
fe1d2224e79d46bc81e080910f24b036faecca3da8b1dee81694b8462b240710
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.10
|
Security for playwright-mcp-server-hellork 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.