Microsoft Playwright MCP is a server based on the Model Context Protocol (MCP) that leverages Playwright to provide powerful browser automation capabilities for Large Language Models (LLMs). The core innovation of this project lies in interacting with web pages through structured accessibility snapshots, completely bypassing the need for traditional screenshots or visually tuned models.
This project represents a new paradigm for AI agent and web interaction, enabling LLMs to operate browsers and perform complex web automation tasks in a more efficient and precise manner.
Web Navigation and Form Filling
Structured Content Data Extraction
LLM-Driven Automated Testing
General Browser Interaction for Agents
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": [
"@playwright/mcp@latest"
]
}
}
}
# VS Code
code --add-mcp '{"name":"playwright","command":"npx","args":["@playwright/mcp@latest"]}'
# VS Code Insiders
code-insiders --add-mcp '{"name":"playwright","command":"npx","args":["@playwright/mcp@latest"]}'
Standard browser mode with a graphical interface, suitable for development and debugging:
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": ["@playwright/mcp@latest"]
}
}
}
Suitable for background or batch processing:
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": [
"@playwright/mcp@latest",
"--headless"
]
}
}
}
For display-less systems or IDE worker processes:
npx @playwright/mcp@latest --port 8931
Configuration file:
{
"mcpServers": {
"playwright": {
"url": "http://localhost:8931/sse"
}
}
}
Enable Vision Mode:
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": [
"@playwright/mcp@latest",
"--vision"
]
}
}
}
browser_click
- Performs a click operationbrowser_hover
- Hovers over an elementbrowser_drag
- Performs a drag operationbrowser_type
- Enters textbrowser_select_option
- Selects an option from a dropdownbrowser_navigate
- Navigates to a URLbrowser_navigate_back
- Goes backbrowser_navigate_forward
- Goes forwardbrowser_tab_list
- Lists all tabsbrowser_tab_new
- Creates a new tabbrowser_tab_select
- Selects a tabbrowser_tab_close
- Closes a tabbrowser_snapshot
- Accessibility snapshot (recommended)browser_take_screenshot
- Page screenshotbrowser_screen_capture
- Screen capturebrowser_file_upload
- File uploadbrowser_pdf_save
- Save as PDFbrowser_press_key
- Key press operationbrowser_handle_dialog
- Handles browser dialogsbrowser_resize
- Resizes the windowbrowser_wait
- Waits for a specified timebrowser_screen_move_mouse
- Moves the mousebrowser_screen_click
- Clicks at coordinatesbrowser_screen_drag
- Drags on the screenbrowser_screen_type
- Types on the screenbrowser_console_messages
- Gets console messagesbrowser_install
- Installs the browserPlaywright MCP creates browser profiles in the following locations:
%USERPROFILE%\AppData\Local\ms-playwright\mcp-chrome-profile
~/Library/Caches/ms-playwright/mcp-chrome-profile
~/.cache/ms-playwright/mcp-chrome-profile
All login information is stored in this profile, and you can delete it between sessions to clear offline status.
For scenarios requiring programmatic integration, you can use the following method:
import { createServer } from '@playwright/mcp';
const server = createServer({
launchOptions: { headless: true }
});
transport = new SSEServerTransport("/messages", res);
server.connect(transport);
The Microsoft Playwright MCP project is a significant innovation in the field of AI agent browser automation. It redefines the way LLMs interact with the Web through the following key advantages:
Structured Interaction Paradigm: Abandoning the traditional screenshot + visual recognition approach, adopting an accessibility tree structure to provide a more precise and efficient interaction experience.
LLM Native Design: Specifically optimized for Large Language Models, eliminating the need for additional visual processing capabilities, reducing system complexity and resource consumption.
Microsoft Official Support: As an official Microsoft project, it provides enterprise-grade reliability and continuous maintenance guarantees.
This project represents the future development direction of AI and Web interaction. As the MCP ecosystem continues to improve, it is expected to play an important role in the following areas:
Microsoft Playwright MCP is not only a technical tool, but also an important milestone in expanding the capabilities of AI agents, providing a solid technical foundation for building more intelligent and practical AI applications.