# playwright-mcp: Browser Automation via Accessibility Tree for LLMs

> playwright-mcp is an MCP Server that enables LLMs to interact with web pages using Playwright's accessibility tree. It solves the problem of web automation for agents by providing fast, lightweight, and deterministic browser control without vision models. Developers building LLM-driven web agents should consider it.

**Published:** 2026-10-08T12:02:28.321+00:00

**Keywords:** playwright-mcp,mcp-server,playwright-automation,llm-web-agents

# playwright-mcp: Browser Automation via Accessibility Tree for LLMs

The `playwright-mcp` MCP Server provides a direct pathway for LLMs to interact with web pages, leveraging Playwright's accessibility tree for fast, lightweight, and deterministic browser automation. This approach bypasses the need for vision models, offering a structured data interface for agents.

## Structured Interaction with Web Pages

`playwright-mcp` is designed to be LLM-friendly, operating on structured data derived from Playwright's accessibility tree. This means LLMs can receive and process web page context without relying on pixel-based input or screenshots, leading to more deterministic tool application. The server supports both headless and headed browser modes, with SSE transport configurable via a specified port.

The core functionality revolves around two tool modes:

*   **Snapshot Mode (default):** Utilizes accessibility snapshots to provide structured data.
*   **Vision Mode:** Employs screenshots for scenarios where visual context might be necessary.

This dual-mode capability allows developers to choose the most appropriate interaction method based on their agent's requirements.

## Available Tools for LLM Agents

`playwright-mcp` exposes a set of tools that allow LLMs to perform common browser actions. These tools are categorized by their underlying mode:

**Snapshot Mode Tools:**

*   `browser_navigate`: Directs the browser to a specified URL.
*   `browser_go_back`: Navigates to the previous page in the browser history.
*   `browser_go_forward`: Moves to the next page in the browser history.
*   Other tools for clicking, typing, and snapshot capture are detailed in the project's README.

This suite of tools enables LLMs to perform tasks such as web navigation, form filling, and data extraction from structured content. The emphasis on the accessibility tree makes these operations inherently more reliable and less prone to the ambiguities often associated with screenshot-based methods.

## Setting Up `playwright-mcp` in VS Code

Integrating `playwright-mcp` into your development environment, particularly with GitHub Copilot agents in VS Code, is straightforward.

To install the server via the VS Code CLI:

```bash
code --add-mcp '{"name":"playwright","command":"npx","args":["@playwright/mcp@latest"]}'
```

For VS Code Insiders:

```bash
code-insiders --add-mcp '{"name":"playwright","command":"npx","args":["@playwright/mcp@latest"]}'
```

Once installed, the `playwright-mcp` server becomes available for use with your GitHub Copilot agent. The server launches a Chrome browser with a new profile. For headless operation, configure `mcpServers` with the `--headless` flag. This setup streamlines the process of connecting LLM agents to a live browser environment.

## Use Cases for LLM-Driven Browser Interaction

The capabilities of `playwright-mcp` lend themselves to several practical applications:

*   **Automated Testing:** LLMs can drive automated testing workflows by navigating web pages, filling forms, and validating content, all based on structured accessibility data.
*   **Data Extraction:** Agents can extract specific data points from web pages, leveraging the deterministic nature of accessibility snapshots for precise targeting.
*   **General-Purpose Browser Interaction:** For agents requiring versatile web interaction, `playwright-mcp` provides a robust interface for navigating and manipulating web content without relying on computationally intensive vision models.

The focus on Playwright's accessibility tree makes `playwright-mcp` a compelling choice for developers aiming to build efficient and reliable LLM-driven web agents.

## References
- [playwright-mcp on GitHub](https://github.com/microsoft/playwright-mcp)
- [Model Context Protocol Documentation](https://modelcontextprotocol.io/introduction)
- [playwright-mcp on model-context-protocol.com](https://model-context-protocol.com/servers/)

## Related Repository

- [playwright-llm-accessibility-tree-browser-automation](https://model-context-protocol.com/servers/playwright-llm-accessibility-tree-browser-automation)

**Source:** https://model-context-protocol.com/blog/playwright-mcp-browser-automation-via-accessibility-tree-for-mcp-server-guide-1791450148603
