home / mcp / katcoder mysql mcp server
Provides a secure MCP interface to interact with MySQL data and metadata using a range of read, write, and schema tools.
Configuration
View docs{
"mcpServers": {
"berthojoris-katcoder-mysql-mcp": {
"command": "npx",
"args": [
"katcoder-mysql-mcp",
"\"mysql://user:password@localhost:3306/mydb\"",
"all"
],
"env": {
"NODE_ENV": "development",
"LOG_LEVEL": "info",
"MYSQL_URL": "mysql://user:password@localhost:3306/mydb"
}
}
}
}You can use the KatCoder MySQL MCP Server to expose MySQL data and operations through a secure, standardized MCP interface. It supports safe read and write operations, optional schema changes, and transaction-aware actions, making it suitable for AI agents, dashboards, and automation that need reliable database access without embedding raw SQL in your logic.
You connect to a MySQL database through an MCP client by providing a connection string and selecting which tools you want to enable. Use read-only tools for analytics and reporting, or enable write and schema tools in trusted environments. You can combine multiple operations into a single transaction to ensure atomicity, and you can run custom SQL when you explicitly allow write access.
Prerequisites you need before running the server are Node.js and Git. You will clone the project, install dependencies, and build the distribution before starting the MCP server.
git clone https://github.com/katkoder/katcoder-mysql-mcp.git
cd katcoder-mysql-mcp
npm install
npm run build
npm run devSecurity is enforced through input validation, parameter binding, and strict control of write operations. Use dedicated database users with minimal privileges and enable only the tools you need for each environment. The server supports connection pooling, timeouts, and secure error handling to prevent leakage of sensitive data.
Configuration can include setting a database connection string, selecting tools to enable, tuning the connection pool, and adjusting timeout behavior.
If you encounter connection issues, verify the MySQL server is running and that your connection string is correct. Check that the user has the necessary privileges for the actions you intend to perform. For performance, monitor the connection pool and query times, and consider adding appropriate indexes.
For common checks, test connectivity and basic health using the utility tool with a ping or version action, then proceed to describe or query as needed.
Environment variables and runtime options let you control logging level, environment mode, and connection behavior. Typical flows include using a read-only setup for analytics, a restricted write setup for data entry, and a fully trusted setup for development or admin tasks.
Browse database structure and table information, with optional table parameter to fetch specific table schema.
Query data from a table with optional filtering, pagination, column selection, and sorting.
Insert multiple records into a table in a single operation with validation and error handling.
Insert a single record into a table with validation.
Modify existing records with a where clause to target rows safely.
Remove records with a mandatory where clause to prevent accidental deletions.
Run a raw SQL query with optional parameters and an allowWrite flag to enable writes.
Execute Data Definition Language statements to modify database structure.
Add a new column to a table with full type, constraints, and position options.
Remove a column from a table with safety checks.
Change column type, nullability, defaults, and comments.
Rename a column while preserving existing data.
Rename a table with safety validation.
Create an index on a table with type, uniqueness, and columns.
Drop an index from a table.
Execute multiple operations atomically within a single transaction.
Perform health checks and metadata operations on the database.
Display table data with formatting, pagination, and optional schema information.