An MCP python server using Playwright for browser automation,more suitable for llm
This document details a powerful MCP server that seamlessly integrates the Playwright web automation library, enabling Large Language Models (LLMs) to interact with and extract information from dynamic web content. By leveraging the Model Context Protocol, this server provides a standardized interface for LLMs to access Playwright's capabilities, opening up a world of possibilities for AI-powered web applications.
This Playwright MCP server is structured around three key components: resources, prompts, and tools, each designed to enhance the LLM's ability to understand and interact with web environments.
The server incorporates a simple note storage system, providing a persistent memory for the LLM. This system utilizes a custom note://
URI scheme for accessing individual notes, each containing:
text/plain
.The server offers a single, powerful prompt: summarize-notes
. This prompt enables the LLM to generate summaries of all stored notes, providing a consolidated view of the available information.
style
argument (optional) allows control over the level of detail in the summary (brief
or detailed
).The heart of this MCP server lies in its comprehensive suite of Playwright tools, enabling the LLM to perform a wide range of web interactions:
playwright_navigate
: Navigates to a specified URL. Automatically creates a new session if none exists.
url
(string) - The URL to navigate to.playwright_screenshot
: Captures a screenshot of the current page or a specific element.
name
(string) - The filename for the screenshot.selector
(string) - A CSS selector for the element to screenshot. If omitted, a full-page screenshot is taken.playwright_click
: Clicks an element on the page using a CSS selector.
selector
(string) - The CSS selector for the element to click.playwright_fill
: Fills out an input field.
selector
(string) - The CSS selector for the input field.value
(string) - The value to fill the input field with.playwright_evaluate
: Executes JavaScript code in the browser console.
script
(string) - The JavaScript code to execute.playwright_click_text
: Clicks an element on the page by its text content.
text
(string) - The text content of the element to click.playwright_get_text_content
: Retrieves the text content of all visible elements on the page.playwright_get_html_content
: Retrieves the HTML content of a specific element on the page.
selector
(string) - The CSS selector for the element.[TODO: Add configuration details specific to your implementation]
To integrate this MCP server with your LLM application, you'll need to configure it within your LLM environment. Here's how to configure it for Claude Desktop:
~/Library/Application\ Support/Claude/claude_desktop_config.json
%APPDATA%/Claude/claude_desktop_config.json
"mcpServers": { "playwright-server": { "command": "uv", "args": [ "--directory", "C:\\path\\to\\your\\playwright-server", "run", "playwright-server" ] } }
Note: Replace C:\\path\\to\\your\\playwright-server
with the actual path to your Playwright server directory.
"mcpServers": { "playwright-server": { "command": "uvx", "args": [ "playwright-server" ] } }
To contribute to the development of this MCP server or to publish your own version, follow these steps:
Sync Dependencies and Update Lockfile:
uv sync
Build Package Distributions:
uv build
This will generate source and wheel distributions in the dist/
directory.
Publish to PyPI:
uv publish
Note: You'll need to configure your PyPI credentials using environment variables or command flags:
--token
or UV_PUBLISH_TOKEN
--username
/UV_PUBLISH_USERNAME
and --password
/UV_PUBLISH_PASSWORD
Debugging MCP servers that communicate over standard input/output (stdio) can be challenging. To streamline the debugging process, we highly recommend using the MCP Inspector.
You can launch the MCP Inspector using npm
:
npx @modelcontextprotocol/inspector uv --directory C:\Users\YUNYING\Documents\project\python\mcp\playwright-server run playwright-server
After launching, the Inspector will provide a URL that you can access in your browser to begin debugging your Playwright MCP server. This tool provides invaluable insights into the communication between your LLM and the server, enabling you to quickly identify and resolve any issues.
๐ โ๏ธ The Scrapeless Model Context Protocol service acts as an MCP server connector to the Google SERP API, enabling web search within the MCP ecosystem without leaving it.
๐ Search ArXiv research papers
๐ โ๏ธ Web search capabilities using Brave's Search API
๐ โ๏ธ MCP to search and read medical / life sciences papers from PubMed.