mcp-mysql-connector
Provides tools for interacting with MySQL databases, enabling connection management, query execution, database and table operations, user and privilege management, schema introspection, and transaction control.
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-connectorShow me the schema of 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.
mcp-mysql-connector
MCP server exposing MySQL database functionalities as tools for LLM agents.
mcp-name: io.github.daedalus/mcp-mysql-connector
Overview
mcp-mysql-connector is a Model Context Protocol (MCP) server that provides MySQL database operations as tools for LLM agents. It allows AI assistants to interact with MySQL databases through a standardized protocol, enabling:
Database and table management
Query execution
User authentication and privilege management
Schema introspection
Transaction control
Related MCP server: MCP Server MySQL
Install
pip install mcp-mysql-connectorQuick Start
Running the Server
# Run with stdio transport (default)
mcp-mysql-connector
# Or run programmatically
python -c "from mcp_mysql import mcp; mcp.run()"Configuration
Connect to MySQL using the connect tool:
{
"host": "localhost",
"port": 3306,
"user": "root",
"password": "your_password",
"database": "your_database"
}MCP Tools
Connection Management
Tool | Description |
| Connect to a MySQL database |
| Disconnect from MySQL |
| Check connection status |
| Commit current transaction |
| Rollback current transaction |
Query Execution
Tool | Description |
| Execute raw SQL query and return results |
Database Operations
Tool | Description |
| List all databases on server |
| Create a new database |
| Drop a database |
| Check if database exists |
Table Operations
Tool | Description |
| List tables in a database |
| Get table schema |
| Create a new table |
| Drop a table |
| Check if table exists |
Column & Index Operations
Tool | Description |
| Show column details |
| Show index details |
| Create an index |
| Drop an index |
User Management
Tool | Description |
| Create a MySQL user |
| Drop a MySQL user |
| Grant privileges to user |
| Revoke privileges from user |
| Show user privileges |
Server Information
Tool | Description |
| Get MySQL server status |
MCP Resources
The server provides dynamic resources for database and table metadata:
database://{name}- Database metadata including table listtable://{db}/{table}- Table metadata including schema, columns, and indexes
Usage Examples
Connect and Query
# First, connect to database
connect(host="localhost", user="root", password="secret", database="mydb")
# Execute a query
execute_query(sql="SELECT * FROM users WHERE active = true")
# List all tables
list_tables(database="mydb")Create Database and Table
# Create a database
create_database(name="newapp")
# Create a table
create_table(name="users", schema="id INT PRIMARY KEY AUTO_INCREMENT, name VARCHAR(255), email VARCHAR(255) UNIQUE")User Management
# Create a new user with password
create_user(username="app_user", host="localhost", password="secure_password")
# Grant privileges
grant_privileges(privileges="SELECT,INSERT,UPDATE,DELETE", on="newapp.*", username="app_user", host="localhost")Transaction Control
# Start transaction
execute_query(sql="BEGIN")
# Execute operations
execute_query(sql="INSERT INTO accounts (balance) VALUES (100)")
# Commit or rollback
commit() # or rollback()Environment Variables
The server supports configuration via environment variables:
export MYSQL_HOST=localhost
export MYSQL_PORT=3306
export MYSQL_USER=root
export MYSQL_PASSWORD=secret
export MYSQL_DATABASE=mydbDevelopment
# Clone repository
git clone https://github.com/daedalus/mcp-mysql-connector.git
cd mcp-mysql-connector
# Create virtual environment
python -m venv venv
source venv/bin/activate
# Install dependencies
pip install -e ".[test]"
# Run tests
pytest
# Format code
ruff format src/ tests/
# Lint
ruff check src/ tests/
# Type check
mypy src/Architecture
mcp-mysql-connector/
├── src/mcp_mysql/
│ ├── core/models.py # Data models (QueryResult, TableSchema, etc.)
│ ├── adapters/mysql.py # MySQL connection & pooling
│ ├── services/connection.py # Connection manager
│ ├── tools/mysql_tools.py # MCP tool implementations
│ └── mcp.py # FastMCP server setup
└── tests/ # Test suiteRequirements
Python 3.11+
fastmcp >= 2.0.0
pymysql >= 1.1.0
sqlparse >= 0.4.0
License
MIT License - see LICENSE for details.
This server cannot be deployed
Maintenance
Related MCP Connectors
- dataOAuthco.thinair
PostgreSQL, MySQL, and SQL Server in one session. 26 read-only MCP tools for AI agents.
PostgreSQL, MySQL, OpenAPI/Swagger, and shared Agent Memory with scoped access.
Gateway between LLM agents and world data through eight tools and a bundled endpoint catalog.
Safe, read-only Postgres and MySQL access for AI agents. Audit log + column-level controls.
Related MCP Servers
- AlicenseBqualityDmaintenanceEnables AI models to perform MySQL database operations through a standardized interface, supporting secure connections, query execution, and comprehensive schema management.7133 npm33MIT
- AlicenseAqualityCmaintenanceEnables LLMs to interact with MySQL databases through standardized protocol, supporting database management, table operations, data queries, and modifications with configurable permission controls.1534 npm1MIT
- AlicenseAqualityDmaintenanceEnables AI agents to safely interact with MySQL/MariaDB databases, supporting read-only queries by default with optional write operations and access control.8MIT
- FlicenseNot gradedqualityDmaintenanceEnables AI agents to interact with a MySQL database using natural language, automating SQL tasks like querying, inserting, updating, and deleting data.1-