Playwright MCP Cursor

Playwright MCP Cursor

Demonstrates using Playwright with the Model Context Protocol (MCP) to enable large language models to automate browser interactions, with an example of cursor-based pagination against the GitHub GraphQL API.

Category
Visit Server

README

Playwright MCP Cursor

This repository demonstrates how to use Playwright with the Model Context Protocol (MCP). MCP is a standard that exposes browser automation capabilities as structured tool calls so that large‑language models can interact with websites and APIs. The included example shows how to perform cursor‑based pagination against the GitHub GraphQL API, but you can adapt the test to any site with pagination (for example, Amazon product listings).

Project structure

  • package.json – defines the npm dependencies and test scripts.
  • playwright.config.ts – Playwright configuration (baseURL, test directory, reporter, etc.).
  • tsconfig.json – TypeScript configuration for the project.
  • tests/mcp-cursor.spec.ts – automated test demonstrating how to page through API results using cursors.

Prerequisites

  • Node.js (version 16 or higher).
  • npm or yarn.
  • A GitHub personal access token set as the environment variable GITHUB_TOKEN (only required when running the GraphQL API test).

Installation

Clone this repository and install dependencies:

npm install

Running the tests

Execute the tests locally:

npx playwright test

Playwright will run in headless mode by default and produce an HTML report. To open the report after the run:

npx playwright show-report

Running with MCP

To expose this project to an MCP client, you'll need to start an MCP server. For instructions on installing and running the MCP server, refer to the official Playwright MCP documentation. Once the server is running, point your client to the configured endpoint to send tool calls and drive Playwright under the hood.

Customizing the pagination example

The test in tests/mcp-cursor.spec.ts fetches repositories from the GitHub GraphQL API and paginates over the results using the endCursor and hasNextPage properties. If you prefer to test pagination on a web page such as Amazon, you can modify the test to navigate a search results page, click the "Next" button and assert that the correct items are loaded. Playwright's rich locator and browser APIs make it straightforward to adapt the pattern to any paginated data source.

Continuous integration

A GitHub Actions workflow is included in .github/workflows/playwright.yml to run the tests automatically on each push or pull request. The workflow installs dependencies, downloads the necessary browsers, and executes npm test on Ubuntu. It also passes through the GITHUB_TOKEN secret so the GraphQL test can authenticate against the GitHub API.

Feel free to fork this repository and experiment with other targets and protocols to expand your test coverage.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured