MySQL MCP Server
Enables executing SQL queries against a MySQL database, returning results as JSON.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MySQL MCP Servershow me the most recent 10 orders"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MySQL MCP Server
This project is an MCP (Model Context Protocol) server for AI models that allows executing SQL queries against a MySQL database.
What it does
The server exposes a tool that sends a single SQL statement to a MySQL database and returns the result as JSON. It also handles connection and execution errors.
Related MCP server: MCP MySQL Server
Requirements
Node.js
npm
Installation
Install the dependencies with:
npm installConfiguration
Before running the server, you should change the connection constants to match your MySQL setup:
const DB_HOSTNAME = "localhost";
const DB_USERNAME = "root";
const DB_PASSWORD = "123456";Replace DB_HOSTNAME, DB_USERNAME, and DB_PASSWORD with the values required by your environment.
Usage with MCP clients
This server is intended to be started by MCP-compatible clients; you do not need to run node main.js manually. Properly configured clients will start the server when needed. Below are example client configurations (use relative paths or environment variables; replace /path/to/... with the correct path on your system).
Continue (VSCode extension) — example
config.yaml:
mcpServers:
- name: MySQL MCP server
command: npx
args:
- -y
- node
- /path/to/mcp_servers/mysql/main.js
env: {}Claude (desktop) — example
claude_desktop_config.json:
{
"mcpServers": {
"mysql": {
"command": "npx",
"args": ["-y", "node", "/path/to/mcp_servers/mysql/main.js"]
}
}
}GitHub Copilot (VSCode) — example
settings.json(if the extension supports direct entries):
{
"github.copilot.mcpServers": {
"mysql": {
"command": "npx",
"args": ["-y", "node", "/path/to/mcp_servers/mysql/main.js"]
}
}
}ChatGPT (clients that support MCP) — generic example:
{
"mcpServers": {
"mysql": {
"command": "npx",
"args": ["-y", "node", "/path/to/mcp_servers/mysql/main.js"]
}
}
}Generic MCP client (command line):
# A client can launch the server this way if it must be started manually
npx -y node /path/to/mcp_servers/mysql/main.jsNotes:
Replace paths and credentials with secure values for your environment.
Ignore any configuration entries that contain machine-specific absolute paths; use relative paths or variables instead.
Check the documentation of the MCP client you use for the exact configuration key names; the examples above are common templates.
Once started, it can be used by MCP-compatible clients.
This server cannot be deployed
Maintenance
Related MCP Connectors
Access New Relic observability data through MCP - query metrics, logs, traces, entities, and more
Query, join, profile, clean and convert CSV/JSON/Parquet with server-side DuckDB over MCP.
n8n MCP — query your own n8n instance (BYO).
Governed data discovery, exact queries, decisions, simulations, and runtime utilities over MCP.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceEnables read-only interaction with SQL databases through MCP, providing database metadata exploration, sample data retrieval, and secure query execution. Supports MySQL with multiple transport options and built-in security features including SQL injection protection and data sanitization.11 npm5MIT
- AlicenseNot gradedqualityDmaintenanceEnables interaction with MySQL databases through MCP, supporting query execution, table operations (insert, update, delete), and schema inspection for natural language database management.133 npmMIT
- AlicenseNot gradedqualityDmaintenanceEnables MySQL database operations through MCP, including executing SQL queries, listing databases and tables, and describing table structures.362 npm5MIT
- AlicenseNot gradedqualityCmaintenanceEnables safe querying and optional writing to MySQL databases via MCP tools, with support for schema inspection, connection management, and read-only mode.19 npm3MIT