If you’ve been using Cursor IDE and want to supercharge your development workflow with AI-powered web automation, you’re in for a treat. Setting up Model Context Protocol (MCP) with Playwright in Cursor opens up incredible possibilities—from automated testing to dynamic content extraction, all driven by natural language prompts.
But here’s the thing: while the concept is powerful, the initial setup can be tricky, and knowing which prompts actually work well requires some experience. After spending weeks fine-tuning this integration and discovering the most effective prompt patterns, I’m sharing everything you need to get up and running quickly.
In this guide, I’ll walk you through the complete setup process for Cursor, show you how to troubleshoot common issues, and give you a collection of battle-tested prompts that will transform how you approach web automation tasks.
Why MCP + Playwright + Cursor is a Perfect Match
Cursor’s AI-first approach combined with MCP’s standardized tool access creates a uniquely powerful development environment. Unlike traditional IDEs where you switch between writing code and testing it manually, this setup lets you:
- Test as you code: Write a function and immediately test it on real websites using natural language
- Debug intelligently: Ask AI to reproduce bugs by automating user interactions
- Generate test cases: Describe user flows and let AI create comprehensive test suites
- Extract data dynamically: Pull information from websites without writing scraping scripts
- Validate changes: Automatically verify that your code changes work across different scenarios
The key advantage is context awareness—Cursor understands your codebase while MCP gives it browser automation superpowers, creating an AI assistant that can think about your application holistically.
Prerequisites and System Requirements
Before we dive into configuration, make sure you have:
- Cursor IDE (latest version recommended)
- Node.js 18+ for running the MCP server
- Git for cloning the MCP server repository
- Basic understanding of web automation concepts
- Familiarity with MCP fundamentals (see my Understanding Model Context Protocol post)
Note: If you haven’t built an MCP Playwright server yet, check out my previous post on Building AI-Powered Web Automation with MCP and Playwright for the complete server implementation.
Step-by-Step Cursor Configuration
Step 1: Prepare Your MCP Playwright Server
First, ensure you have a working MCP Playwright server. If you followed my previous guide, you should have a project structure like this:
mcp-playwright-server/
├── src/
│ └── index.ts
├── dist/
│ └── index.js
├── package.json
├── tsconfig.json
└── node_modules/Make sure your server is built and ready:
$ cd /path/to/your/mcp-playwright-server
$ npm run build
$ node dist/index.js
# Should output: "MCP Playwright server running on stdio"Step 2: Configure Cursor’s MCP Settings
Cursor uses a different configuration approach than Claude Desktop. You’ll need to set up MCP in Cursor’s settings:
Method 1: Using Cursor Settings UI
- Open Cursor and go to Settings (Cmd/Ctrl + ,)
- Search for “Model Context Protocol” or “MCP”
- Navigate to Features → Model Context Protocol
- Click “Add MCP Server”
- Configure your server:
{
"name": "playwright-automation",
"command": "node",
"args": ["/absolute/path/to/your/mcp-playwright-server/dist/index.js"],
"env": {
"NODE_ENV": "development"
}
}Method 2: Direct Configuration File Edit
If the UI method doesn’t work, you can edit Cursor’s configuration directly:
On macOS: ~/Library/Application Support/Cursor/User/settings.json
On Windows: %APPDATA%\Cursor\User\settings.json
On Linux: ~/.config/Cursor/User/settings.json
Add this to your settings.json:
{
"mcp.servers": {
"playwright-automation": {
"command": "node",
"args": ["/absolute/path/to/your/mcp-playwright-server/dist/index.js"],
"env": {
"NODE_ENV": "development"
}
}
}
}Step 3: Verify the Connection
After configuration, restart Cursor and verify the connection:
- Open a new chat or use Cmd+L to start a conversation
- Type: “What MCP tools do you have available?”
- You should see your Playwright tools listed:
- navigate_to_url
- click_element
- fill_input
- extract_text
- take_screenshot
- wait_for_element
If the tools aren’t showing up, check the troubleshooting section below.
Step 4: Test Basic Functionality
Run a quick test to ensure everything works:
Human: Navigate to https://example.com and take a screenshot
Cursor AI: I'll navigate to example.com and take a screenshot for you.
[Uses navigate_to_url tool]
[Uses take_screenshot tool]
[Shows the screenshot in chat]Essential Prompts for Web Automation
Now that your setup is working, here are the most effective prompt patterns I’ve discovered for different automation scenarios:
Testing and Quality Assurance
Form Validation Testing
Test the contact form on [website URL]. Try these scenarios:
1. Submit with all fields empty (check error messages)
2. Submit with invalid email format
3. Submit with valid data
4. Take screenshots of each state
Tell me what validation errors appear and if the form behavior is correct.Cross-Page Navigation Testing
Starting from the homepage of [website], navigate through this user journey:
1. Click on "Products" in the main menu
2. Select the first product
3. Add it to cart
4. Go to checkout
Take a screenshot at each step and tell me if any links are broken or pages fail to load.Responsive Design Verification
Visit [website URL] and check how it looks on mobile.
Change the viewport to 375x667 (iPhone size), navigate to the main sections,
and take screenshots. Tell me if there are any layout issues or elements
that don't fit properly.Content Extraction and Analysis
Competitive Analysis
Go to [competitor website] and extract:
1. All product names from their main catalog page
2. Pricing information if visible
3. Main navigation menu items
4. Footer links
Organize this data in a structured format for competitive analysis.News and Content Monitoring
Visit [news website] and extract all article headlines from the homepage.
For each headline, also get the publication time if available.
Format the results as a daily digest with timestamps.SEO and Technical Analysis
Analyze the SEO elements of [website URL]:
1. Extract the page title and meta description
2. Check if there are any broken images (alt text missing)
3. List all the H1, H2, and H3 headings
4. Take a screenshot for visual reference
Tell me if there are any obvious SEO issues.Development and Debugging
Feature Testing During Development
I just deployed a new feature on [staging URL]. Please test this workflow:
1. Login with username "testuser" and password "testpass123"
2. Navigate to the new dashboard section
3. Try creating a new project with name "Test Project"
4. Verify the project appears in the project list
Document any errors or unexpected behavior you encounter.Bug Reproduction
Help me reproduce this bug: "Users can't submit the feedback form on mobile."
1. Navigate to [website]/feedback
2. Set viewport to mobile size (375x667)
3. Fill out the form with test data
4. Try to submit and capture any error messages
5. Take screenshots of the process
Tell me exactly what happens when you try to submit.Performance and Load Testing Setup
Visit [website URL] and help me gather performance data:
1. Navigate to the main page and time how long it takes to load
2. Check if all images load properly
3. Try interacting with any dynamic elements (dropdowns, modals)
4. Take screenshots if any elements appear broken or slow to load
Report any performance issues you notice.E-commerce and Business Process Testing
Checkout Flow Validation
Test the complete purchase flow on [e-commerce site]:
1. Browse to a product page
2. Add item to cart
3. Proceed to checkout
4. Fill out shipping information (use fake but valid format data)
5. Stop before payment (don't actually purchase)
Document each step and identify any friction points or errors.Inventory and Product Monitoring
Check product availability on [website]:
1. Search for "[product name]"
2. Check if it's in stock
3. Extract the current price
4. Look for any sale/discount badges
5. Take a screenshot of the product page
Report the current status and pricing.Advanced Automation Patterns
Multi-Step Workflow with Conditional Logic
Help me test this complex workflow on [application URL]:
1. If the login page appears, log in with [credentials]
2. Navigate to the user dashboard
3. If there's a "New User" popup, dismiss it
4. Look for a "Create New" button and click it
5. Fill out the form with these details: [provide details]
6. Submit and verify success message appears
Handle any unexpected popups or errors gracefully and report what happens.Data Collection with Pagination
Extract all product information from [catalog URL]:
1. Start on page 1 of the product catalog
2. Extract product names, prices, and availability for current page
3. If there's a "Next" button, click it and repeat
4. Continue until you reach the last page
5. Compile all data into a structured list
Stop if you encounter more than 50 products to avoid excessive automation.Dynamic Content Monitoring
Set up monitoring for [news/blog website]:
1. Visit the homepage
2. Extract all article titles published today
3. For each article, get the publication time and author
4. Take a screenshot of the current homepage layout
5. Save this as a baseline for comparison
This will help me track when new content is published.Cursor-Specific Tips and Tricks
Using Cursor’s Context Features
Combine Codebase Context with Web Automation
Looking at my React component in /src/components/ContactForm.tsx,
please test the live version on [staging URL]:
1. Navigate to the contact page
2. Test all the form fields I've defined in the component
3. Verify that validation messages match what's in my code
4. Check if the styling looks correct compared to my CSS
Compare the live behavior with my component implementation.Debugging with Real User Interactions
I'm seeing an error in my browser console when users click the submit button.
Can you reproduce this on [website URL]?
1. Open the contact form
2. Fill it out normally
3. Click submit and watch for any JavaScript errors
4. Try different input combinations
Help me understand when this error occurs by testing various scenarios.Optimizing Prompt Effectiveness
Be Specific About Expected Outcomes
✅ Good: "Navigate to the login page, enter 'test@example.com' and 'password123',
click login, and tell me if you see a dashboard or an error message."
❌ Vague: "Test the login functionality."Provide Context for Decision Making
✅ Good: "I'm testing a new checkout flow. Please go through the purchase process
but stop before entering real payment details. Focus on identifying any confusing
steps or unclear messaging."
❌ Unclear: "Test the checkout."Use Structured Requests for Complex Tasks
✅ Good: "Please test these three scenarios on [URL]:
1. [Specific scenario with expected outcome]
2. [Specific scenario with expected outcome]
3. [Specific scenario with expected outcome]
Compare results and highlight any inconsistencies."
❌ Overwhelming: "Test everything on this website."Troubleshooting Common Issues
Connection Problems
MCP Server Not Detected
If Cursor doesn’t see your MCP tools:
- Check the server path: Ensure the absolute path in your configuration is correct
- Verify server functionality: Test the server independently with
node dist/index.js - Restart Cursor completely: Close all windows and reopen
- Check permissions: Ensure Cursor can execute the node command
# Test server manually
$ cd /path/to/mcp-playwright-server
$ node dist/index.js
# Should start without errorsServer Starts But Tools Don’t Work
If tools are listed but fail when used:
- Check browser installation: Run
npx playwright install - Verify dependencies: Ensure all npm packages are installed
- Test with headless mode: Temporarily set
headless: truein your server - Check system dependencies: Install required system libraries
# Linux users may need these dependencies
$ sudo apt-get install -y libnss3 libnspr4 libatk-bridge2.0-0 libdrm2 libxkbcommon0Performance Issues
Slow Response Times
If automation feels sluggish:
- Use headless mode for faster execution (when visual feedback isn’t needed)
- Implement connection pooling in your MCP server
- Add timeout configurations to prevent hanging requests
- Monitor memory usage and implement cleanup routines
// Add to your MCP server for better performance
private async initializeBrowser() {
this.browser = await chromium.launch({
headless: process.env.HEADLESS !== 'false',
args: ['--no-sandbox', '--disable-dev-shm-usage'] // Helps with memory
});
}Memory Leaks
For long automation sessions:
// Add periodic cleanup to your server
private async cleanupPeriodically() {
setInterval(async () => {
const pages = await this.browser?.pages() || [];
// Close old pages (keep only the most recent)
for (const page of pages.slice(0, -1)) {
await page.close();
}
}, 300000); // Every 5 minutes
}Browser and Website Issues
Handling Modern SPAs
For single-page applications with dynamic content:
When testing [SPA URL], please:
1. Navigate to the page
2. Wait for the loading spinner to disappear
3. Wait an additional 2 seconds for dynamic content to load
4. Then proceed with the actual testing
This ensures all JavaScript has finished executing.Dealing with Popups and Modals
While testing [website], if any popups or cookie banners appear:
1. Try to dismiss them first (look for X, Close, or Accept buttons)
2. If dismissal fails, take a screenshot and note the popup content
3. Continue with testing around the popup if possible
Focus on the main functionality even if popups interfere.Advanced Configuration Options
Environment-Specific Settings
Set up different configurations for development vs. production:
{
"mcp.servers": {
"playwright-dev": {
"command": "node",
"args": ["/path/to/mcp-playwright-server/dist/index.js"],
"env": {
"NODE_ENV": "development",
"HEADLESS": "false",
"SLOW_MO": "100"
}
},
"playwright-prod": {
"command": "node",
"args": ["/path/to/mcp-playwright-server/dist/index.js"],
"env": {
"NODE_ENV": "production",
"HEADLESS": "true"
}
}
}
}Custom Tool Extensions
Add specialized tools for your specific needs:
// Add to your MCP server for common patterns
{
name: 'test_form_validation',
description: 'Test form validation with common invalid inputs',
inputSchema: {
type: 'object',
properties: {
formSelector: { type: 'string' },
fields: {
type: 'array',
items: {
type: 'object',
properties: {
selector: { type: 'string' },
invalidValues: { type: 'array', items: { type: 'string' } }
}
}
}
}
}
}Best Practices for Cursor + MCP Workflow
Organizing Your Automation Tasks
Create a Testing Checklist
Keep a document in your project with common testing prompts:
# Web Automation Checklist
## Pre-deployment Testing
- [ ] Login flow validation
- [ ] Core user journeys
- [ ] Form submission testing
- [ ] Mobile responsiveness check
## Post-deployment Verification
- [ ] Production smoke tests
- [ ] Performance checks
- [ ] SEO element validation
- [ ] Analytics tracking verificationVersion Control Your Prompts
Save effective prompts as snippets in your project:
<!-- .cursor-prompts/form-testing.md -->
# Form Testing Template
Test the [FORM_NAME] form on [URL]:
1. Submit with empty fields (verify required field validation)
2. Submit with invalid email format (verify email validation)
3. Submit with valid data (verify success flow)
4. Take screenshots of validation states
Report any UX issues or inconsistent messaging.Integrating with Development Workflow
Code → Test → Fix Cycle
I just updated the validation logic in /src/utils/formValidation.js.
Can you test the contact form on [staging URL] to verify:
1. Email validation works with my new regex pattern
2. Phone number validation accepts the formats I specified
3. Error messages match the ones I defined in the code
Compare the live behavior with my implementation.Continuous Integration Preparation
Use MCP automation to prepare test cases for CI/CD:
Help me document test cases for our CI pipeline.
Test these scenarios on [staging URL] and create a test specification:
1. [User journey 1]
2. [User journey 2]
3. [Error case 1]
4. [Error case 2]
For each scenario, document the steps, expected outcomes, and any assertions needed.Conclusion
Setting up MCP with Playwright in Cursor transforms your development workflow from reactive debugging to proactive, AI-assisted testing and automation. The combination creates a unique environment where you can seamlessly move between writing code and testing it in real browser environments using natural language.
The key to success with this setup is starting simple and building complexity gradually. Begin with basic navigation and screenshot prompts, then evolve to more sophisticated workflows as you become comfortable with the pattern. The prompt examples I’ve shared here are battle-tested and will save you hours of trial and error.
What makes this approach particularly powerful is how it integrates with Cursor’s understanding of your codebase. You’re not just automating web interactions—you’re creating an AI assistant that understands both your code and how it behaves in real browser environments. This context awareness enables debugging and testing conversations that weren’t possible before.
The investment in setting up this integration pays dividends immediately. Tasks that used to require manual browser testing, writing custom scripts, or switching between multiple tools now happen conversationally within your development environment. As you build your library of effective prompts and refine your automation patterns, you’ll find yourself naturally shifting toward more thorough, consistent testing practices.
If you’re already using Cursor for development, adding MCP with Playwright is a natural next step that will significantly enhance your productivity. The setup effort is minimal compared to the ongoing benefits of having AI-powered web automation at your fingertips whenever you need it.