DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Custom Model Context Protocol (MCP) for NL2SQL: A Rigorous Evaluation Framework on Oracle Database
  • Using Arrow Flight SQL to Improve Data Transfer Performance in Apache Doris
  • Master SQL Performance Optimization: Step-by-Step Techniques With Case Studies
  • Useful System Table Queries in Relational Databases

Trending

  • A 5-Step SOC Guide That Meets RBI Expectations and Strengthens Security Operations
  • Kafka and Spark Structured Streaming in Enterprise: The Patterns That Hold Up Under Pressure
  • Why Good Models Fail After Deployment
  • From AI Chaos to Control: Building Enterprise-Grade LLM Gateways With MuleSoft Anypoint
  1. DZone
  2. Data Engineering
  3. Databases
  4. Automating a Web Form With Playwright MCP and MySQL MCP

Automating a Web Form With Playwright MCP and MySQL MCP

Learn how to automate form filling using Playwright MCP and MySQL MCP by fetching real-time data from a database with minimal scripting.

By 
Kailash Pathak user avatar
Kailash Pathak
DZone Core CORE ·
Jul. 23, 25 · Tutorial
Likes (0)
Comment
Save
Tweet
Share
3.2K Views

Join the DZone community and get the full member experience.

Join For Free

Combining browser automation with database interactions opens up powerful possibilities. Imagine fetching user data from a database and using it to populate a web form automatically — no manual scripting required.

With Playwright MCP (Model Context Protocol) and MySQL MCP, you can achieve this seamlessly. In this blog, I’ll walk you through how to integrate these tools to fetch data from a MySQL database and use it to fill in the checkout in the Web Form. By the end, you’ll have a working automation setup that’s both efficient and scalable.

Why Use MCP With Playwright and MySQL?

The Model Context Protocol (MCP), developed by Anthropic, standardizes how large language models (LLMs) interact with external tools like browsers and databases. Playwright MCP acts as a bridge between LLMs and Playwright’s browser automation capabilities, allowing you to control web interactions using natural language or structured commands. MySQL MCP, on the other hand, enables read-only access to MySQL databases, letting you query data dynamically.

Together, these tools allow you to:

  • Fetch real-time data from a database
  • Automate web interactions like form filling
  • Create end-to-end testing workflows with minimal coding
  • Leverage AI-driven automation for dynamic, data-driven scenarios

In the example we are going to discuss, we’ll fetch Checkout data from a MySQL database and use it to populate the checkout form on saucedemo.com, a demo e-commerce site.

Prerequisites

Before we start, ensure you have the following:

  • Node.js (LTS version, 18 or newer) installed
  • MySQL server with a database named “demo”
  • Playwright MCP and MySQL MCP servers installed
  • Cursor IDE or Claude Desktop for running MCP commands
  • A basic understanding of JavaScript/TypeScript and SQL

Step 1: Setting Up the MySQL Database

First, let’s create a demo database and a table to store customer data for the checkout form. The checkout form on saucedemo.com requires a first name, last name, and postal code. We’ll create a table called Checkout to save this data.

SQL Setup

Connect to your MySQL server (via MySQL Workbench or the command line) and run the following SQL commands:

SQL
 
CREATE DATABASE demo;
USE demo;

CREATE TABLE Checkout (
    id INT AUTO_INCREMENT PRIMARY KEY,
    first_name VARCHAR(50) NOT NULL,
    last_name VARCHAR(50) NOT NULL,
    postal_code VARCHAR(10) NOT NULL
);

INSERT INTO Checkout (first_name, last_name, postal_code) VALUES
('John', 'Doe', '12345'),
('Jane', 'Smith', '67890'),
('Alex', 'Johnson', '54321');


This creates a demo database with a Checkout table containing sample data.

Verify the data by running:

SQL
 
SELECT * FROM Checkout;


Step 2: Installing and Configuring MySQL MCP Server

The MySQL MCP server allows LLMs to execute read-only queries on your MySQL database. Let’s set it up.

Installation

Install the MySQL MCP server using npm.

C
 
npx -y @smithery/cli install mysql-mcp-server --client claude


MySQL Configuration

Create a dedicated MySQL user with minimal permissions for security (avoid using root credentials). Configure the server by adding the following to your MCP configuration file (e.g., ~/.cursor/mcp.json for Cursor.

MySQL configuration


Python
 
"mysql": {
      "type": "stdio",
      "command": "npx",
      "args": [
                "--from",
                "mysql-mcp-server",
                "mysql_mcp_server"
            ],
      "env": {
        "MYSQL_HOST": "localhost",
        "MYSQL_PORT": "3306",
        "MYSQL_USER": "root",
        "MYSQL_PASSWORD": "xxxxx",
        "MYSQL_DATABASE": "demo"
      }
  }


Step 3: Installing and Configuring Playwright MCP

The Playwright MCP from executeautomation/mcp-playwright enables browser automation. Follow these steps.

Clone the repository and install dependencies:

Python
 
git clone https://github.com/executeautomation/mcp-playwright.git
cd mcp-playwright
npm install


Or, install the package globally (if available via npm):

Playwright MCP Configuration

Add the Playwright MCP server to your MCP configuration file:

Python
 
  "mcpServers": {
    "playwright": {
      "command": "npx",
      "args": ["-y", "@executeautomation/playwright-mcp-server"]
    },
}


Step 4: Automating the Checkout Form

For demo purposes, we are taking the example of the saucedemo “Checkout: Your Information” page. We will fill in the data in the three fields below using MySQL MCP along with Playwright MCP:

Fill in the three fields


Now let's take the scenario that we want to automate using Playwright MCP and MySQL MCP.

Use Case

Let's take the below use case where we’ll fetch a third customer record from the demo database and use the data to fill the saucedemo.com checkout form. In Cursor IDE or Claude Desktop, connect to both MCP servers and use this prompt. In this blog, we are using the Cursor IDE.

Prompt: We will use a cursor to execute the use case below.

Python
 
1.Open https://www.saucedemo.com/
2.Login with username and password
3.Add product “Sauce Labs Backpack” into the cart
4.Open the cart
5.Click on Checkout button
6.Pull data of third record from Checkout Table of demo database  and fill data in First Name,Last Name and Zip/Postal Code
7.Click on continue button
8.Click on Finish button
9.Verify message Thank you for your order


Execute the use case

When we trigger the above prompt in the cursor, the first tool call is to start a new browser session, and other tools to fill data into fields, connect with the DB, and execute the query. Finally, fill in the data from the DB in the checkout form.

Tool to start the session

Fill in the data from the DB

Tools for connecting with DB


Finally, you will see that all steps of the use cases are executed successfully.

All steps are executed successfully

See the video below for more details.

Video

Each step is covered in the video below:


Conclusion

Integrating Playwright MCP from executeautomation/mcp-playwright with MySQL MCP Server from designcomputer/mysql_mcp_server enables powerful, data-driven automation. This blog showed how to fetch customer data from a demo database and automate the saucedemo.com checkout form using natural language commands. It’s a game-changer for testers and developers looking to streamline workflows.

Database MySQL Form (document) Protocol (object-oriented programming)

Opinions expressed by DZone contributors are their own.

Related

  • Custom Model Context Protocol (MCP) for NL2SQL: A Rigorous Evaluation Framework on Oracle Database
  • Using Arrow Flight SQL to Improve Data Transfer Performance in Apache Doris
  • Master SQL Performance Optimization: Step-by-Step Techniques With Case Studies
  • Useful System Table Queries in Relational Databases

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook