MySQL MCP Server
Allows executing SQL queries against a MySQL database and returns results as JSON.
Click on "Install 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 Serverselect first 5 rows from the users table"
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: MySQL MCP Server
Requirements
Node.js
npm, pnpm (recommended) or any compatible Node.js package manager
Installation
Install the dependencies with:
npm installOr:
pnpm installIf you use pnpm.
Or the equivalent for your Node.js package manager.
Configuration
Before running the server, edit "main.js" file and update the following default connection values to match your MySQL setup:
const DEFAULT_DB_HOST = "localhost";
const DEFAULT_DB_USER = "root";
const DEFAULT_DB_PASSWORD = "123456";
const DEFAULT_DB_NAME = "test";Replace these values with the ones required by your environment. When chatting with the AI, make sure to tell it at least the name of the database and the SQL statement. The database must already exist. You can also tell it the database host, username, and password but it is recommended to set those values in the constants above.
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 (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). Press Ctrl+Shift+P (Windows or Linux) or Cmd+Shift+P (Mac) to open the Command Palette. Execute the MCP: Open User Configuration command. This creates a clean mcp.json in your global user profile directory. Edit the mcp.json file and place the following:
{
"servers": {
"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:
Check the documentation of the MCP client you use for the exact configuration key names; the examples above are common templates.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/PedroUrday/mysql-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server