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 Server list 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
Inputs: field (required), table (required).
connect_dbC
Connect to MySQL database using URL or config
Inputs: database, host, password, url, +2 more.
create_tableC
Create a new table in the database
Inputs: fields (required), table (required), indexes.
describe_tableB
Get table structure
Inputs: table (required).
executeB
Execute an INSERT, UPDATE, or DELETE query
Inputs: sql (required), params.
list_tablesB
List all tables in the database
Inputs: no named parameters.
queryB
Execute a SELECT query
Inputs: sql (required), params.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
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.
Hosted MySQL MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
A Model Context Protocol server for Wix AI tools
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA 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.5329 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.67ISC