MySQL MCP Server
Provides tools for querying, exploring schemas, executing SQL with permission controls, listing tables, describing structures, and browsing databases in a MySQL database.
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 Serverlist all tables in the database"
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
A Model Context Protocol (MCP) server for MySQL databases, built with NestJS and MCP-Nest. Enables AI assistants like Claude and Cursor to interact with MySQL databases through a standardized protocol.
Overview
MySQL MCP Server exposes MySQL database operations as MCP tools, allowing AI assistants to:
Query and explore database schemas
Execute SQL queries with permission controls
List tables, describe table structures, and browse databases
Run in multiple transport modes (stdio, HTTP SSE, Streamable HTTP)
Related MCP server: MCP MySQL Server
Features
Description | |
Connection Pool | Efficient MySQL connection management with configurable pool size |
Permission Control | Granular SQL operation permissions (SELECT, INSERT, UPDATE, DELETE, DDL) |
DRY_RUN Mode | Validate SQL queries without returning actual data |
MCP Tools | Standardized database operations exposed via Model Context Protocol |
Graceful Shutdown | Clean resource cleanup on process termination |
File Logging | Configurable log output with rotation support |
Prerequisites
Node.js 18+
MySQL 5.7+ database
npm or pnpm package manager
Installation
# Global installation (recommended)
npm install -g @johnson.lee/mysql-mcp-server
# Or use npx
npx @johnson.lee/mysql-mcp-serverQuick Start
# Set environment variables
export DB_HOST=localhost
export DB_PORT=3306
export DB_USER=root
export DB_PASSWORD=your_password
export DB_NAME=your_database
# Run the server
mysql-mcpConfiguration
Configure via environment variables:
Database Connection
Variable | Default | Description |
| localhost | MySQL host |
| 3306 | MySQL port |
| root | MySQL user |
| - | MySQL password |
| test_db | Database name |
| 2 | Min pool connections |
| 10 | Max pool connections |
Permission Control
Variable | Default | Description |
| true | Allow SELECT queries |
| true | Allow SHOW / DESCRIBE |
| false | Allow INSERT |
| false | Allow UPDATE |
| false | Allow DELETE |
| false | Allow CREATE/ALTER/DROP/TRUNCATE |
Server Options
Variable | Default | Description |
| mysql-mcp-server | Server name — used as log file prefix |
| stdio | Transport: stdio/http-sse/streamable-http |
| info | Log level: debug/info/warn/error |
| ./logs | Log directory |
| false | Validate SQL without returning data |
Editor Integration
Claude Desktop
Edit ~/.config/claude/claude_desktop_config.json:
{
"mcpServers": {
"mysql": {
"command": "npx",
"args": ["@johnson.lee/mysql-mcp-server"],
"env": {
"DB_HOST": "localhost",
"DB_USER": "root",
"DB_PASSWORD": "your_password",
"DB_NAME": "your_database"
}
}
}
}Cursor
Create .cursor/mcp.json:
{
"mcpServers": {
"mysql": {
"command": "npx",
"args": ["@johnson.lee/mysql-mcp-server"],
"env": {
"DB_HOST": "localhost",
"DB_USER": "root",
"DB_PASSWORD": "your_password",
"DB_NAME": "your_database"
}
}
}
}Multi-Environment Setup
You can register multiple instances to connect different databases simultaneously.
Each instance should have a unique MCP_SERVER_NAME, which is also used as the log file prefix — e.g. dev-info.log, prod-error.log.
Note: All
envvalues must be strings. Use"true"/"false", not bare booleans.
{
"mcpServers": {
"dev-mysql": {
"command": "npx",
"args": ["@johnson.lee/mysql-mcp-server"],
"env": {
"MCP_SERVER_NAME": "dev",
"DB_HOST": "dev-db.example.com",
"DB_PORT": "3306",
"DB_USER": "dev_user",
"DB_PASSWORD": "dev_password",
"DB_NAME": "dev_db",
"LOG_DIR": "/tmp/mcp-logs"
}
},
"prod-mysql": {
"command": "npx",
"args": ["@johnson.lee/mysql-mcp-server"],
"env": {
"MCP_SERVER_NAME": "prod",
"DB_HOST": "prod-db.example.com",
"DB_PORT": "3306",
"DB_USER": "prod_user",
"DB_PASSWORD": "prod_password",
"DB_NAME": "prod_db",
"LOG_DIR": "/tmp/mcp-logs",
"DRY_RUN": "true"
}
}
}
}With the above config, log files are written to LOG_DIR with the server name as prefix:
/tmp/mcp-logs/
├── dev-info.log
├── dev-error.log
├── prod-info.log
└── prod-error.logAvailable Tools
list_tables
List all tables in the current database.
describe_table
Get table structure (columns, types, keys, etc.).
{
"name": "describe_table",
"arguments": { "tableName": "users" }
}execute_query
Execute SQL queries.
{
"name": "execute_query",
"arguments": { "sql": "SELECT * FROM users LIMIT 10" }
}list_databases
List all available databases on the MySQL server.
Available Tools
4 toolsdescribe_tableB
Get the structure of a specific table
| Name | Required | Description | Default |
|---|---|---|---|
| tableName | Yes | The name of the table to describe |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
The description indicates a read-only operation ('Get'), but lacks details on error handling (e.g., missing table), authentication needs, or what exactly constitutes 'structure' (columns, types, constraints?). With no annotations, the description carries the full burden, which is insufficient.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Single sentence, no unnecessary words. However, it could be slightly expanded to include what is returned without becoming verbose.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the simplicity (1 parameter, no output schema), the description is adequate but does not mention what the structure includes or behavior if the table does not exist. A bit more detail would improve completeness.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The only parameter, tableName, is fully described in the input schema (pattern, required, description). The tool description adds no additional meaning, so baseline score of 3 applies.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description 'Get the structure of a specific table' clearly states the action (Get) and the resource (structure of a specific table). It distinguishes from siblings like list_tables and execute_query, which list tables or run queries.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No explicit guidance on when to use this tool instead of alternatives. It is implied that one uses it to retrieve table structure, but there are no when-not instructions or prerequisites mentioned.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
execute_queryB
Execute a SELECT query on the database
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | The SQL query to execute | |
| timeout | No | Query timeout in milliseconds |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description must carry the full burden. It states 'SELECT query' implying read-only, but does not explicitly confirm non-destructiveness, mention permissions, error handling, or query restrictions (e.g., no DDL/DML). This is insufficient for a database tool.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, clear sentence with no redundant words. It is appropriately sized for a simple tool and front-loads the essential action.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool executes SQL queries, critical missing context includes: whether only SELECT is allowed, return format, timeout behavior, and potential side effects. The description is too minimal for safe and correct invocation, especially without annotations or output schema.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 100% with both parameters described. The tool description adds no extra meaning beyond the schema definitions; it merely restates 'SELECT query'. Baseline score of 3 is appropriate as the schema already provides parameter details.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description 'Execute a SELECT query on the database' clearly identifies the tool's action (execution), resource (database), and operation type (SELECT). It distinguishes from sibling tools that describe or list metadata.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No explicit usage guidelines are provided, but the description implies this tool is for SELECT queries, while siblings handle metadata exploration. The agent must infer when to use this versus describe_table or list_tables.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
list_databasesA
List all available databases
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description must convey behavior. It correctly indicates a read-only listing operation with no side effects, but does not mention output format or any constraints (e.g., user permissions). It is basic but not misleading.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single sentence with no wasted words. It is front-loaded and efficient.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a simple list tool with no parameters and no output schema, the description is almost complete. It could mention that it returns database names, but the core functionality is clear.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
There are no parameters, and schema description coverage is 100% trivially. Per guidelines, with 0 parameters the baseline is 4. The description does not need to add parameter meaning.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the verb 'list' and resource 'databases' with the scope 'all available'. It distinguishes itself from sibling tools (describe_table, execute_query, list_tables) which focus on tables and queries.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies usage when needing to see available databases but provides no explicit guidance on when to use or not use this tool versus alternatives. No exclusions or context are given.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
list_tablesA
List all tables in the current database
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, and the description only states the basic action. It does not disclose any behavioral traits such as output format, connection requirements, or potential side effects. For a simple read operation, this is minimal but could be improved.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, concise sentence that is front-loaded with the core purpose. Every word earns its place with no redundancy.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The description is adequate for a simple listing operation but lacks details on what information is returned (e.g., table names only). No output schema exists, so more context would be beneficial.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
There are no parameters, and schema coverage is 100%. The description adds no value beyond the schema, so baseline score of 3 applies.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description 'List all tables in the current database' clearly specifies the verb (list) and resource (tables), and effectively distinguishes from siblings like describe_table (describes a specific table) and list_databases (lists databases).
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies usage for listing tables but does not explicitly state when to use this tool versus alternatives like describe_table or execute_query. No exclusions or context are provided.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
4 tool updates
v0.0.2-8- First observed
describe_table - First observed
execute_query - First observed
list_databases - First observed
list_tables
TDQS
Each tool targets a distinct resource or action: table structure, SELECT query execution, database listing, and table listing. There is no overlap in functionality.
All tool names consistently follow the verb_noun pattern (list_databases, list_tables, describe_table, execute_query), making them easy to parse and select.
With 4 tools, the set is minimal but focused. It covers basic database exploration needs, though one might expect additional tools for write operations or schema browsing.
The set handles core read operations (listing, describing, querying) but lacks any write capabilities (INSERT, UPDATE, DELETE) and does not support non-SELECT queries, leaving notable gaps for a general MySQL server.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
The Mercado Pago MCP Server implements the Model Context Protocol to provide AI agents and LLMs with access to Mercado Pago's APIs and tools within compatible development environments. It acts as an intermediary that translates Mercado Pago resources into executable functions (tools) that AI applications can invoke to perform actions and automate flows. The server simplifies integration, enables using documentation to implement or improve code, and optimizes operations through natural language interactions without manual implementations.
A Model Context Protocol server for Wix AI tools
- mcpOAuthcom.gibsonai
GibsonAI MCP server: manage your databases with natural language
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceA server that enables AI models to interact with MySQL databases through a Model Control Protocol, providing tools for table creation, schema inspection, query execution, and data retrieval.28MIT
- AlicenseBqualityDmaintenanceA Model Context Protocol server that enables AI models to interact with MySQL databases, providing tools for querying, executing statements, listing tables, and describing table structures.5342MIT
- FlicenseBqualityDmaintenanceA Model Context Protocol server that enables AI models to interact with MySQL databases through a standardized interface, providing tools for querying, executing commands, and managing database schemas.7-
- FlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that enables AI models to interact with MySQL databases through natural language, supporting SQL queries, table creation, and schema exploration.3-
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- 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/CobaltBlue3699/mysql-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server