Skip to main content

Quick start

This guide will help you get an MCP server running and execute your first queries. We’ll use the MySQL server as an example, but the same concepts apply to all servers in this collection.

Prerequisites

Before you begin, ensure you have:
  • A MySQL database running (or access to one)
  • Node.js installed (for NPM installation) OR Docker installed
  • Claude Desktop app (optional, for AI integration)

Step 1: Choose your installation method

Install and run the MySQL MCP server using npx:
npx -y @marcelo-ochoa/server-mysql
With environment variables for credentials:
MYSQL_USER=myuser MYSQL_PASSWORD=mypassword npx -y @marcelo-ochoa/server-mysql
Connection strings are optional at startup. If you don’t provide one, you can connect later using the mysql-connect tool.

Step 2: Connect to your database

Once the server is running, connect to your MySQL database using the mysql-connect tool.

Connection parameters

  • connectionString: MySQL connection string (e.g., host.docker.internal:3306/mydb)
  • user: Database username (e.g., root)
  • password: Database password

Example connection

mysql-connect host.docker.internal:3306/hr root my_2025
When using Docker on macOS, use host.docker.internal instead of localhost to connect to databases running on your host machine.

Step 3: Explore your database schema

The MCP server automatically discovers table schemas and exposes them as resources.

View available tables

Resources are exposed in the format:
mysql://<database>/<table>/schema
For example:
  • mysql://hr/employees/schema
  • mysql://hr/departments/schema

Get table statistics

Use the mysql-stats tool to retrieve comprehensive statistics for a table:
mysql-stats employees
This returns:
  • Table and index statistics
  • Column statistics
  • Row count and data size

Step 4: Execute your first query

All queries are executed within READ ONLY transactions to prevent data modification.

Query syntax

Use the mysql-query tool with SQL:
SELECT * FROM employees WHERE department_id = 10 LIMIT 5

Example queries

Find all tables in the database:
SHOW TABLES
Count records in a table:
SELECT COUNT(*) FROM employees
Join multiple tables:
SELECT e.employee_id, e.first_name, e.last_name, d.department_name
FROM employees e
JOIN departments d ON e.department_id = d.department_id
LIMIT 10

Step 5: Analyze query performance

Use the mysql-explain tool to understand query execution plans.

Generate an explain plan

SELECT * FROM employees WHERE email = '[email protected]'
The explain plan shows:
  • Table access methods
  • Index usage
  • Estimated rows scanned
  • Join order

Optimize your queries

Based on the explain plan, you can:
  • Add missing indexes
  • Rewrite inefficient queries
  • Identify full table scans

Step 6: Generate a performance report

The mysql-awr tool generates a comprehensive performance report similar to Oracle’s Automatic Workload Repository.

Run the AWR report

mysql-awr
The report includes:
  • Database statistics and uptime
  • InnoDB metrics (buffer pool, log writes)
  • Top queries by execution time (requires Performance Schema)
  • Table and index statistics
  • Connection information
  • Optimization recommendations
For optimal performance monitoring, ensure the Performance Schema is enabled:
[mysqld]
performance_schema = ON

Step 7: Integrate with Claude Desktop

Connect the MCP server to Claude Desktop for AI-powered database analysis.
1

Locate your configuration file

Find claude_desktop_config.json in your system:
  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
2

Add the server configuration

{
  "mcpServers": {
    "mysql": {
      "command": "docker",
      "args": [
        "run", 
        "-i", 
        "--rm",
        "-e", "MYSQL_USER=myuser",
        "-e", "MYSQL_PASSWORD=mypassword",
        "mochoa/mcp-mysql"
      ]
    }
  }
}
3

Restart Claude Desktop

Restart the Claude Desktop app to load the new configuration.
4

Start querying

You can now ask Claude to:
  • Connect to your database
  • Query tables and analyze data
  • Generate performance reports
  • Optimize queries based on explain plans

Example prompts for Claude

Once integrated with Claude Desktop, try these prompts: Connect to database:
Connect to host.docker.internal:3306/mydb using root as user and password123 as password using mysql mcp server
Explore schema:
Query all tables in the current database
Analyze data:
Show me the top 10 employees by salary
Performance analysis:
Get stats for the users table
Query optimization:
Explain the execution plan for: SELECT * FROM users WHERE email = '[email protected]'
Generate report:
Generate a performance report using mysql-awr
Get recommendations:
Based on the AWR report, what optimizations would you recommend?

Try other servers

Now that you’ve mastered the MySQL server, try the other servers in this collection:

Oracle Database

Connect to Oracle databases with AWR reporting and explain plansConnection example:
orcl-connect host.docker.internal:1521/freepdb1 hr hr_2025

PostgreSQL

Query PostgreSQL with performance analysis and pg_stat_statements integrationConnection example:
pg-connect host.docker.internal:5432/postgres postgres pg_2025

MikroTik RouterOS

Monitor MikroTik routers with security audits and performance reportsConnection example:
mk-connect 192.168.88.1 admin mypassword

QNAP NAS

Monitor QNAP NAS devices and manage filesConnection example:
qnap-connect http://10.1.1.241:8080 admin password

Common issues

Connection failed

Problem: Unable to connect to the database. Solutions:
  • Verify the database is running and accessible
  • Check credentials in environment variables
  • Use host.docker.internal instead of localhost when using Docker on macOS
  • Ensure firewall rules allow connections

Permission denied

Problem: Query execution fails with permission errors. Solutions:
  • Verify the database user has SELECT privileges
  • For explain plans (Oracle), grant SELECT_CATALOG_ROLE
  • For AWR reports (Oracle), grant EXECUTE ON DBMS_WORKLOAD_REPOSITORY

Performance Schema not available (MySQL)

Problem: AWR report shows limited query statistics. Solution: Enable Performance Schema in MySQL configuration:
[mysqld]
performance_schema = ON

Next steps

Installation guide

View detailed installation instructions for all servers

Introduction

Learn about all available servers and their features

Build docs developers (and LLMs) love