MCP MySQL Server
Supports configuration through environment variables in .env files, allowing database connection details to be securely stored and accessed.
Enables querying and managing MySQL databases with support for SELECT, INSERT, UPDATE, and DELETE operations, as well as schema management through table listing, creation, description, and column addition.
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., "@MCP MySQL 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.
@enemyrr/mcp-mysql-server
A Model Context Protocol server that provides MySQL database operations. This server enables AI models to interact with MySQL databases through a standardized interface.
Installation & Setup for Cursor IDE
Installing via Smithery
To install MySQL Database Server for Claude Desktop automatically via Smithery:
npx -y @smithery/cli install @enemyrr/mcp-mysql-server --client claudeInstalling Manually
Clone and build the project:
git clone https://github.com/enemyrr/mcp-mysql-server.git
cd mcp-mysql-server
npm install
npm run buildAdd the server in Cursor IDE settings:
Open Command Palette (Cmd/Ctrl + Shift + P)
Search for "MCP: Add Server"
Fill in the fields:
Name:
mysqlType:
commandCommand:
node /absolute/path/to/mcp-mysql-server/build/index.js
Note: Replace
/absolute/path/to/with the actual path where you cloned and built the project.
Related MCP server: MCP MySQL Server
Database Configuration
You can configure the database connection in three ways:
Database URL in .env (Recommended):
DATABASE_URL=mysql://user:password@host:3306/databaseIndividual Parameters in .env:
DB_HOST=localhost
DB_USER=your_user
DB_PASSWORD=your_password
DB_DATABASE=your_databaseDirect Connection via Tool:
use_mcp_tool({
server_name: "mysql",
tool_name: "connect_db",
arguments: {
url: "mysql://user:password@host:3306/database"
// OR
workspace: "/path/to/your/project" // Will use project's .env
// OR
host: "localhost",
user: "your_user",
password: "your_password",
database: "your_database"
}
});Available Tools
1. connect_db
Connect to MySQL database using URL, workspace path, or direct credentials.
2. query
Execute SELECT queries with optional prepared statement parameters.
use_mcp_tool({
server_name: "mysql",
tool_name: "query",
arguments: {
sql: "SELECT * FROM users WHERE id = ?",
params: [1]
}
});3. execute
Execute INSERT, UPDATE, or DELETE queries with optional prepared statement parameters.
use_mcp_tool({
server_name: "mysql",
tool_name: "execute",
arguments: {
sql: "INSERT INTO users (name, email) VALUES (?, ?)",
params: ["John Doe", "john@example.com"]
}
});4. list_tables
List all tables in the connected database.
use_mcp_tool({
server_name: "mysql",
tool_name: "list_tables"
});5. describe_table
Get the structure of a specific table.
use_mcp_tool({
server_name: "mysql",
tool_name: "describe_table",
arguments: {
table: "users"
}
});6. create_table
Create a new table with specified fields and indexes.
use_mcp_tool({
server_name: "mysql",
tool_name: "create_table",
arguments: {
table: "users",
fields: [
{
name: "id",
type: "int",
autoIncrement: true,
primary: true
},
{
name: "email",
type: "varchar",
length: 255,
nullable: false
}
],
indexes: [
{
name: "email_idx",
columns: ["email"],
unique: true
}
]
}
});7. add_column
Add a new column to an existing table.
use_mcp_tool({
server_name: "mysql",
tool_name: "add_column",
arguments: {
table: "users",
field: {
name: "phone",
type: "varchar",
length: 20,
nullable: true
}
}
});Features
Multiple connection methods (URL, workspace, direct)
Secure connection handling with automatic cleanup
Prepared statement support for query parameters
Schema management tools
Comprehensive error handling and validation
TypeScript support
Automatic workspace detection
Security
Uses prepared statements to prevent SQL injection
Supports secure password handling through environment variables
Validates queries before execution
Automatically closes connections when done
Error Handling
The server provides detailed error messages for:
Connection failures
Invalid queries or parameters
Missing configuration
Database errors
Schema validation errors
Contributing
Contributions are welcome! Please feel free to submit a Pull Request to https://github.com/enemyrr/mcp-mysql-server
License
MIT
Available Tools
7 toolsadd_columnC
Add a new column to existing table
| Name | Required | Description | Default |
|---|---|---|---|
| field | Yes | ||
| table | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden of behavioral disclosure. It states this is a mutation ('Add'), implying it modifies database structure, but doesn't cover critical aspects like permissions required, whether changes are reversible, impact on existing data, error handling, or response format. For a tool that alters schema with no annotation coverage, this is a significant gap in transparency.
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, efficient sentence with zero wasted words. It's front-loaded with the core action and resource, making it easy to parse quickly. Every word ('Add', 'new column', 'existing table') contributes directly to understanding the tool's function.
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 complexity (2 parameters with nested objects, no output schema, and no annotations), the description is incomplete. It doesn't explain the input structure (e.g., that 'field' is an object with specific properties), behavioral traits (e.g., mutation effects), or output expectations. For a schema-altering tool with rich parameters but no supporting documentation, this leaves too much undefined.
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 description coverage is 0%, meaning none of the parameters (table, field with nested properties like name, type, nullable, length, default) are documented in the schema. The description only mentions 'table' and 'column' generically, without explaining what 'field' represents or detailing the nested properties. It fails to compensate for the schema's lack of documentation, leaving key semantics unclear.
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 action ('Add') and resource ('new column to existing table'), making the purpose immediately understandable. It distinguishes this tool from siblings like 'create_table' (which creates entire tables) and 'describe_table' (which inspects structure). However, it doesn't specify what kind of database or system it operates on, which could help further differentiate it from generic column-adding tools.
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 provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing an existing table from 'create_table' or 'list_tables'), exclusions (e.g., not for modifying columns), or comparisons to siblings like 'execute' (which might handle SQL directly). Without this context, an agent must infer usage from the tool name alone.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
connect_dbC
Connect to MySQL database using URL or config
| Name | Required | Description | Default |
|---|---|---|---|
| database | No | ||
| host | No | ||
| password | No | ||
| url | No | Database URL (mysql://user:pass@host:port/db) | |
| user | No | ||
| workspace | No | Project workspace path |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool connects to a database, implying it establishes a session or handle, but doesn't describe what happens after connection (e.g., persistence, timeout, error handling), authentication needs beyond parameters, or side effects. For a tool with zero annotation coverage, this is a significant gap in transparency.
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 extremely concise—a single sentence that directly states the tool's purpose and method without any fluff. It's front-loaded and wastes no words, making it easy for an agent to parse quickly. Every part of the sentence earns its place by conveying essential information.
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's complexity (database connection with 6 parameters), lack of annotations, no output schema, and low schema description coverage, the description is incomplete. It doesn't cover behavioral aspects like connection lifecycle, error cases, or output format, leaving critical gaps for the agent to infer. This is inadequate for a tool that likely has significant operational implications.
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 description coverage is 33% (only 'url' and 'workspace' have descriptions), so the description must compensate but adds minimal value. It mentions 'URL or config', hinting at parameters like 'url' and possibly 'host', 'user', etc., but doesn't explain their semantics, relationships (e.g., mutual exclusivity), or defaults. The description provides some context but doesn't fully bridge the coverage gap, warranting a baseline score.
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 action ('Connect to MySQL database') and the resource ('MySQL database'), making the purpose evident. It specifies the connection method ('using URL or config'), which helps distinguish it from other database operations. However, it doesn't explicitly differentiate from sibling tools like 'execute' or 'query', which might also involve database interactions, so it's not a perfect 5.
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 provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing this connection before using other tools like 'query'), exclusions, or contextual cues. With sibling tools like 'execute' and 'query' available, the lack of usage guidelines leaves the agent uncertain about proper sequencing or selection.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
create_tableC
Create a new table in the database
| Name | Required | Description | Default |
|---|---|---|---|
| fields | Yes | ||
| indexes | No | ||
| table | Yes | Table name |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden of behavioral disclosure. It states 'create' implies a write operation but doesn't cover critical aspects like permissions required, whether the operation is idempotent, error handling (e.g., if the table already exists), or side effects. This leaves significant gaps for a mutation 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, direct sentence with zero wasted words, making it highly efficient and front-loaded. It immediately conveys the core purpose without unnecessary elaboration, which is ideal for conciseness.
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 mutation tool with 3 parameters, no annotations, and no output schema, the description is insufficient. It lacks details on behavior, error cases, dependencies (e.g., connection state), and doesn't explain what 'create' entails operationally (e.g., atomicity, rollback). This leaves the agent poorly equipped to use the tool effectively in complex scenarios.
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 description coverage is low at 33%, with only the 'table' parameter having a description. The tool description doesn't add any parameter details beyond the schema, failing to compensate for the coverage gap. However, the schema itself provides clear structure for 'fields' and 'indexes', so a baseline score of 3 is appropriate given the schema's clarity despite missing descriptions.
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 action ('create') and resource ('new table in the database'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'add_column' or 'execute', which could also involve table creation operations, so it doesn't reach the highest score.
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 provides no guidance on when to use this tool versus alternatives like 'execute' (which might create tables via SQL) or 'add_column' (which modifies existing tables). There's no mention of prerequisites, such as needing an established database connection via 'connect_db', leaving the agent without contextual usage cues.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
describe_tableB
Get table structure
| Name | Required | Description | Default |
|---|---|---|---|
| table | Yes | Table name |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, and the description fails to disclose behavioral traits like read-only nature, side effects, or required permissions. It simply states the function without additional context.
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 extremely concise (two words), front-loaded, and gets straight to the point. However, it could benefit from a bit more detail without sacrificing brevity.
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 is simple with one parameter and no output schema, the description is minimal but adequate for a basic understanding. However, it doesn't specify what 'structure' includes (e.g., columns, types), leaving some ambiguity.
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 the only parameter 'table' described as 'Table name'. The description adds no new meaning beyond the schema, so baseline 3 is appropriate.
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 table structure' clearly states the verb (Get) and resource (table structure), and distinguishes the tool from siblings like execute, list_tables, and query, which have different purposes.
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 provides no guidance on when to use this tool vs alternatives, such as list_tables or query. It lacks context on when not to use it or any prerequisites.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
executeB
Execute an INSERT, UPDATE, or DELETE query
| Name | Required | Description | Default |
|---|---|---|---|
| params | No | Query parameters (optional) | |
| sql | Yes | SQL query (INSERT, UPDATE, DELETE) |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description must bear the burden of behavioral disclosure. It confirms mutation but fails to detail side effects, permanence, or return behavior.
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 short sentence with no wasted words, but it could include more detail without sacrificing conciseness.
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 lack of output schema and annotations, the description does not explain return values or error behavior. It is too minimal for a mutation tool.
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%, and the description does not add meaning beyond the schema. The schema already documents 'sql' and 'params' adequately.
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 tool executes INSERT, UPDATE, or DELETE queries, which specifies the action and resource. It distinguishes from sibling tools like 'query' which likely handles SELECT statements.
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 write operations but does not explicitly guide when to use this tool versus alternatives like 'query'. There is no mention of prerequisites or restrictions.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
list_tablesB
List all tables in the database
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
There are no annotations, so the description must fully disclose behavior. It merely states 'List all tables', which implies a read operation, but omits details on permissions, output format, or performance implications.
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, efficient sentence with no unnecessary words. It is appropriately front-loaded but lacks any structural enhancement like bullet points that could aid readability.
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 no output schema or annotations, the description should explain what 'list' returns (e.g., table names, schemas). Without this, an agent may not know how to use the result. Sibling tools like 'describe_table' suggest additional context might be needed.
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 tool has no parameters, so the description cannot add parameter meaning. Baseline for zero parameters is 4, and the description is sufficient for the parameterless case.
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 tool lists all tables in the database. While it distinguishes from 'describe_table' by listing instead of describing, it does not explicitly differentiate from potential siblings like 'query' or 'execute'.
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 provides no guidance on when to use this tool versus its siblings (describe_table, execute, query). It is implied that it retrieves table names, but no context on prerequisites or alternatives.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
queryB
Execute a SELECT query
| Name | Required | Description | Default |
|---|---|---|---|
| params | No | Query parameters (optional) | |
| sql | Yes | SQL SELECT query |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description bears full responsibility for behavioral disclosure. It only states the tool executes a SELECT query, but does not explicitly confirm it is read-only, mention permission requirements, error handling, or the effect of malformed queries. The implied read-only nature is not sufficient.
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 front-loads the main action. It is not verbose, though it could include more context without losing conciseness. The structure is effective but minimal.
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?
There is no output schema, yet the description does not explain what the tool returns (e.g., result set structure, row count, error messages). It also lacks information on pagination, limits, or behavior with large queries, leaving the agent with significant gaps.
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 description coverage is 100%, so the schema already documents both parameters ('sql' and 'params') adequately. The description adds no additional meaning or context about parameter usage, formatting, or constraints beyond the schema, earning a baseline score of 3.
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' clearly identifies the tool's action (execute) and resource (SELECT query). It distinguishes from sibling tools like 'execute' (which likely handles other SQL statements) and 'describe_table'/'list_tables' (which are informational).
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 provides no guidance on when to use this tool versus alternatives. It does not mention that for non-SELECT queries (e.g., INSERT, UPDATE) one should use the sibling 'execute' tool, nor does it specify any prerequisites or limitations.
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.
7 tool updates
v1.0.0- First observed
add_column - First observed
connect_db - First observed
create_table - First observed
describe_table - First observed
execute - First observed
list_tables - First observed
query
TDQS
Scored across 7 tools
Each tool has a clearly distinct purpose with no ambiguity: connect_db handles connections, list_tables and describe_table provide metadata, create_table and add_column manage schema, while execute and query separate write and read operations. The descriptions make it easy to distinguish between similar tools like execute vs query or create_table vs add_column.
All tools follow a consistent verb_noun pattern with clear, descriptive names (e.g., connect_db, list_tables, create_table). There are no deviations in naming conventions, and the snake_case style is applied uniformly throughout the toolset.
With 7 tools, this server is well-scoped for basic MySQL database operations. Each tool earns its place by covering essential functions: connection management, schema operations, metadata queries, and data manipulation. The count is neither too sparse nor overwhelming for the domain.
The toolset provides solid coverage for core MySQL workflows, including connection, schema management (create, modify), and data operations (read/write). A minor gap exists in lacking explicit tools for updating or deleting tables (e.g., drop_table, alter_table), but agents can work around this using the execute tool for such DDL queries.
Maintenance
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.5156 npmMIT
- 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-
- AlicenseAqualityDmaintenanceA Model Context Protocol server that allows AI agents to execute SQL queries against a MySQL database, supporting operations like reading data, creating tables, inserting, updating, and deleting records.6317 npm7MIT