mcp-mysql
A lightweight MCP server for MySQL, built with python
claude mcp add --transport stdio alexcc4-mcp-mysql-server uvx run main.py \ --env DB_HOST="Database host" \ --env DB_NAME="Database name" \ --env DB_PORT="Database port (defaults to 3306 if not specified)" \ --env DB_USER="Database username" \ --env DB_PASSWORD="Database password"
How to use
This MCP server provides a lightweight interface to a MySQL database, exposing read-only access to database schema and data through the MCP protocol. You can list all tables, fetch detailed schema information for tables, and execute read-only SQL queries via the server's tools. The available resources include mysql://schema for the complete database structure and mysql://tables for a list of all tables. The primary tool exposed by the server is query_data, which executes read-only SQL queries and returns the results. Use these capabilities to inspect schemas, preview data, and run safe queries without granting full database access. When integrating with Claude or other assistants, configure the server in your client’s MCP setup and provide the required environment variables to connect to your MySQL instance.
How to install
Prerequisites:
- Python 3.12.2+ (or a compatible Python environment)
- uv (uvx) for running Python MCP servers
- Access to a MySQL server with appropriate credentials
Installation steps:
-
Clone the repository: git clone git@github.com:alexcc4/mcp-mysql-server.git cd mysql-mcp-server
-
Install dependencies using uv (recommended): uv sync
-
Ensure your environment is configured with the required variables before starting the server. Example variables are shown in the Configuration section of the README. You can set them in your shell or in your Claude Desktop configuration as needed.
Additional notes
Tips and considerations:
- Use a least-privilege MySQL user with only read permissions to the target database.
- Avoid exposing root credentials; prefer dedicated read-only accounts.
- If you plan to run multiple databases, consider separate environment configurations for isolation.
- When deploying with Claude Desktop, ensure the config file maps the environment variables correctly to the server environment.
- If you encounter connection issues, verify network access to the DB host and confirm that DB_PORT is correct (default is 3306).
- For security, consider adding a query whitelist in your production environment to restrict what read-only queries can run.
Related MCP Servers
AgentChat
AgentChat 是一个基于 LLM 的智能体交流平台,内置默认 Agent 并支持用户自定义 Agent。通过多轮对话和任务协作,Agent 可以理解并协助完成复杂任务。项目集成 LangChain、Function Call、MCP 协议、RAG、Memory、Milvus 和 ElasticSearch 等技术,实现高效的知识检索与工具调用,使用 FastAPI 构建高性能后端服务。
mysql_mcp_server_pro
Model Context Protocol (MCP) server that supports secure interaction with MySQL databases and has anomaly analysis capabilities.更加牛逼!更加好用!不仅止于mysql的增删改查功能; 还包含了数据库异常分析能力;且便于开发者们进行个性化的工具扩展
nautex
MCP server for guiding Coding Agents via end-to-end requirements to implementation plan pipeline
mcp-yfinance
Real-time stock API with Python, MCP server example, yfinance stock analysis dashboard
cloudwatch-logs
MCP server from serkanh/cloudwatch-logs-mcp
servicenow-api
ServiceNow MCP Server and API Wrapper