mcpField
M
mcp-mysql-connector

mcp-mysql-connector

Local
github.com/daedalusDatabases0Updated 27w ago

About mcp-mysql-connector

mcp-mysql-connector is an MCP server that exposes MySQL operations as tools for LLM agents and AI assistants. It covers queries, schema and user management, and transaction control, with metadata also available as resources.

Key features

  1. 01Connect to and disconnect from MySQL
  2. 02Execute SQL queries
  3. 03Manage databases, tables, columns, and indexes
  4. 04Create users and manage privileges
  5. 05Commit or roll back transactions
  6. 06Inspect database and table metadata

Use cases

  1. 01Run queries against a MySQL database
  2. 02Inspect table schemas and indexes
  3. 03Manage database users and privileges
  4. 04Apply or undo a set of database changes

MCP support

It exposes MySQL operations as MCP tools and database and table metadata as MCP resources. MCP clients can use it to query and manage a connected database.

Configuration

Local server config is the same for every client. Copy it into your client’s MCP config file.

mcp.json · Universal config
{
"mcpServers": {
"daedalus-mcp-mysql-connector": {
"command": "uvx",
"args": [
"mcp-mysql-connector"
]
}
}
}
Run commanduvx mcp-mysql-connector

Local servers need a runtime on your machine (e.g. Node.js 18+). Config file locations differ by client; see your client’s docs.

Packages
pypimcp-mysql-connector0.1.1

Tools

No tool list yet

Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.

Details

From the project README

mcp-mysql-connector

MCP server exposing MySQL database functionalities as tools for LLM agents.

mcp-name: io.github.daedalus/mcp-mysql-connector

PyPI Python Coverage Ruff

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

Install

pip install mcp-mysql-connector

Quick 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
ToolDescription
connectConnect to a MySQL database
disconnectDisconnect from MySQL
is_connectedCheck connection status
commitCommit current transaction
rollbackRollback current transaction
Query Execution
ToolDescription
execute_queryExecute raw SQL query and return results
Database Operations
ToolDescription
list_databasesList all databases on server
create_databaseCreate a new database
drop_databaseDrop a database
database_existsCheck if database exists
Table Operations
ToolDescription
list_tablesList tables in a database
describe_tableGet table schema
create_tableCreate a new table
drop_tableDrop a table
table_existsCheck if table exists
Column & Index Operations
ToolDescription
show_columnsShow column details
show_indexesShow index details
create_indexCreate an index
drop_indexDrop an index
User Management
ToolDescription
create_userCreate a MySQL user
drop_userDrop a MySQL user
grant_privilegesGrant privileges to user
revoke_privilegesRevoke privileges from user
show_privilegesShow user privileges
Server Information
ToolDescription
server_statusGet MySQL server status

MCP Resources

The server provides dynamic resources for database and table metadata:

  • database://{name} - Database metadata including table list
  • table://{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=mydb

Development

# 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 suite

Requirements

  • Python 3.11+
  • fastmcp >= 2.0.0
  • pymysql >= 1.1.0
  • sqlparse >= 0.4.0

License

MIT License - see LICENSE for details.

Comments

Markdown supported

New to MCP?

From what the protocol is to installing your first server, these answers cover most first questions.

An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.