mcp-mysql-with-port
v1.1.0
Published
A Model Context Protocol (MCP) server for MySQL database with custom port support
Downloads
11
Maintainers
Readme
mcp-mysql-with-port
A Model Context Protocol (MCP) server for MySQL database with custom port support.
Features
- ✅ Custom port support - Connect to MySQL on any port (not just 3306)
- ✅ Query execution (SELECT)
- ✅ Data modification (INSERT, UPDATE, DELETE)
- ✅ List all tables
- ✅ Describe table structure
Installation
npx -y mcp-mysql-with-portConfiguration
Windsurf / Cursor IDE
Add to your MCP configuration file:
Windsurf: ~/.codeium/windsurf/mcp_config.json
Cursor: ~/.cursor/mcp.json
{
"mcpServers": {
"mysql": {
"command": "npx",
"args": ["-y", "mcp-mysql-with-port"],
"env": {
"MYSQL_HOST": "localhost",
"MYSQL_PORT": "3306",
"MYSQL_USER": "root",
"MYSQL_PASSWORD": "your_password",
"MYSQL_DATABASE": "your_database"
}
}
}
}Environment Variables
| Variable | Description | Default |
|----------|-------------|---------|
| MYSQL_HOST | MySQL server hostname | localhost |
| MYSQL_PORT | MySQL server port | 3306 |
| MYSQL_USER | MySQL username | root |
| MYSQL_PASSWORD | MySQL password | (empty) |
| MYSQL_DATABASE | Database name | (empty) |
| ALLOW_DDL | Allow DDL operations (CREATE, ALTER, DROP, TRUNCATE, RENAME) | false |
| ALLOW_DML | Allow DML operations (INSERT, UPDATE, DELETE, REPLACE) | false |
Permission Control
By default, this MCP server runs in read-only mode. DDL and DML operations are disabled for safety.
To enable write operations, set the corresponding environment variables:
{
"env": {
"MYSQL_HOST": "localhost",
"MYSQL_PORT": "3306",
"MYSQL_USER": "root",
"MYSQL_PASSWORD": "your_password",
"MYSQL_DATABASE": "your_database",
"ALLOW_DML": "true",
"ALLOW_DDL": "true"
}
}Available Tools
query
Execute a SELECT query on the MySQL database.
SELECT * FROM users LIMIT 10execute
Execute INSERT, UPDATE, or DELETE queries.
INSERT INTO users (name, email) VALUES ('John', '[email protected]')list_tables
List all tables in the current database.
describe_table
Get the structure of a specific table.
Example Usage
After configuring the MCP server, you can use it in your AI assistant:
- "Show me all tables in the database"
- "Query the first 10 users"
- "Describe the orders table structure"
Why This Package?
Most MySQL MCP packages don't support custom ports. This package was created to solve that problem - simply set MYSQL_PORT environment variable to connect to MySQL on any port.
License
MIT
Author
wejack639
