MCP for Java Development and Testing: MySQL & Browser Automation Guide

This article explains the Model Context Protocol (MCP), its architecture and communication methods, then demonstrates how to build and configure a MySQL-MCP server in Python, integrate it with AI tools like Workbuddy, and use browser automation via MCP for automated testing of web applications.

Lobster Programming
Lobster Programming
Lobster Programming
MCP for Java Development and Testing: MySQL & Browser Automation Guide

What is MCP?

MCP (Model Context Protocol) is an open standardized protocol released by Anthropic in November 2024 and later donated to the Linux Foundation's Agentic AI Foundation. It acts like a USB for AI, providing a unified interface for large model applications to securely connect to external data sources, tools, and business systems. This solves the pain point of LLMs being limited to static training knowledge and lacking a standard way to call external capabilities. The underlying communication is based on JSON-RPC 2.0.

MCP Core Roles

Host (Host Application) : The user-facing AI application such as Claude Desktop or Cursor IDE, responsible for managing user conversations, LLM inference, permissions, and security policies.

MCP Client : A connector inside the host; one client corresponds to one MCP Server. It handles session establishment, protocol capability negotiation, message forwarding, and maintains security isolation boundaries.

MCP Server : An independently running program (local process via stdio or remote HTTP service) that wraps external capabilities into standard MCP interfaces for discovery and invocation by the host's LLM.

The USB analogy: just as a computer doesn't need custom drivers for each USB device, an AI doesn't need custom integration code for each database or browser — any MCP service can be plugged in and used immediately.

Communication Methods

MCP supports two transport mechanisms:

Stdio (Local Process) : The MCP server runs as a child process communicating via standard input/output. Suitable for local IDEs, local file or database MCP services.

Streamable HTTP : Remote network calls for MCP services deployed on servers, supporting multi-client access over the network.

Choose Stdio when a service needs to run securely on a single user's machine; choose Streamable HTTP when the service must be shared among multiple users.

MCP in Java Development and Testing Workflow

Using Workbuddy as an example (Cursor and Trae also support MCP), the workflow is:

User accesses local Java code in the workspace via the AI tool.

When the code requires database queries (e.g., MySQL), the AI tool invokes the MCP service.

The MCP service executes the query and returns data to the AI tool.

The AI tool analyzes the code logic with the retrieved data and produces an analysis report.

For browser automation, the AI tool takes control of a locally running browser (e.g., a logged-in company admin console) via an MCP service that listens to the browser's debugging port. The AI then simulates human interactions — clicking buttons, navigating pages — and generates functional test reports. Bugs found can be fed back to the AI for fixes, significantly improving delivery quality.

Building a MySQL-MCP Server

Prerequisites

Install a Python environment.

Dependencies

pip install fastmcp pymysql sqlparse python-dotenv

AI-Generated MCP Service

Use an AI tool (e.g., Workbuddy) to generate the MCP service code that connects to MySQL. The generated project structure includes a main entry script (main.py), configuration files, and modules for database connection and query execution.

Database Configuration

Configure your database connection details (host, port, username, password, database name) in the appropriate config file (e.g., .env or a dedicated config module).

Testing the MCP Server

Run main.py directly to verify the server starts successfully. The console should show the MCP server listening and ready to accept connections.

Configuring in Workbuddy

In Workbuddy's custom connector settings, add the MySQL-MCP configuration:

{
  "mcpServers": {
    "mysql-ai-self-mcp": {
      "command": "cmd",
      "args": [
        "/c",
        "C:\\Windows\\py.exe",
        "D:\\py_workspace\\ai_mcp_server\\main.py"
      ]
    }
  }
}

Save the configuration; a successful connection indicator appears in Workbuddy. Test by asking Workbuddy to query the configured MySQL database.

Browser Automation via MCP

Launch Chrome with Remote Debugging

Start Chrome with a dedicated debugging port and user data directory to preserve login state:

"C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222 --user-data-dir="%USERPROFILE%\chrome_debug_profile"

Verify Browser Listening

Navigate to http://127.0.0.1:9222/json/version in a browser. A JSON response confirms the debugging endpoint is active. Keep this browser window open because the AI tool can only attach to this specific instance.

Test with Baidu

Open Baidu in the debug browser window, then ask the AI tool (via Workbuddy) whether it can monitor the browser. The AI tool connects to the MCP service that bridges to the Chrome DevTools Protocol, enabling it to read page content and simulate interactions.

Leverage Login State for Testing

Because the debug browser retains the user's login cookies, the AI tool can take over already-authenticated admin consoles in test or development environments. It can then click through every functional button, generate a comprehensive test report, and feed discovered bugs back to the AI for remediation — dramatically improving functional delivery quality.

Conclusion

By connecting MCP services for MySQL, Redis, Nacos, and browser automation to an AI tool, developers can let the AI read local Java source code, analyze runtime issues in test/dev environments, and automate end-to-end functional testing. This integration significantly boosts problem diagnosis efficiency and test coverage.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

AI toolsMCPautomated testingMySQLJava developmentModel Context Protocolbrowser automationWorkBuddy
Lobster Programming
Written by

Lobster Programming

Sharing insights on technical analysis and exchange, making life better through technology.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.