An MCP server implementation that integrates with MySQL databases, providing secure database access capabilities for LLMs.
Configuration
View docs{
"mcpServers": {
"kevinwatt-mysql-mcp": {
"command": "npx",
"args": [
"-y",
"@kevinwatt/mysql-mcp"
],
"env": {
"MYSQL_DB": "your_database",
"MYSQL_HOST": "127.0.0.1",
"MYSQL_PORT": "3306",
"MYSQL_USER": "root"
}
}
}
}You have a MySQL MCP Server that lets you securely query and modify a MySQL database through an MCP-enabled client. It supports read-only queries, write operations with transaction safety, and built-in security and monitoring to help LLMs interact with your data safely and efficiently.
Use this MCP server with any MCP client to perform database operations from your language models. You can run read-only queries to fetch data, list tables, and inspect table structures. For changes, you can execute INSERT, UPDATE, and DELETE statements with automatic transaction handling. All inputs can be parameterized to protect against SQL injection, and results include affected rows and insert IDs. Security features include read-only transaction mode for SELECTs, query length and result size limits, and logging for performance monitoring.
Typical usage patterns include asking your LLM to:
Prerequisites you need before installing this MCP server:
Install the MCP server package globally using the following command:
npm install -g @kevinwatt/mysql-mcpWhen running the MCP server, you set connection details via environment variables. The following variables are used to connect to your MySQL database:
A ready-to-use runtime example shows how to start the MCP server locally with the required environment variables set.
If you prefer to start the MCP server manually without a client, run the following command. The environment variables should be set in your shell or via a start script.
npx @kevinwatt/mysql-mcpExecute read-only SELECT queries with inputs and limits for query length and result size.
Execute data modification statements (INSERT/UPDATE/DELETE) with parameter support and automatic transaction handling.
List all tables in the current database without inputs.
Show the structure of a specified table.