home / mcp / katcoder mysql mcp server

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.

Installation
Add the following to your MCP client configuration file.

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.

How to use

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.

How to install

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 dev

Security and configuration notes

Security 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.

Troubleshooting and tips

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 and workflows

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.

Available tools

list

Browse database structure and table information, with optional table parameter to fetch specific table schema.

read

Query data from a table with optional filtering, pagination, column selection, and sorting.

bulk_insert

Insert multiple records into a table in a single operation with validation and error handling.

create

Insert a single record into a table with validation.

update

Modify existing records with a where clause to target rows safely.

delete

Remove records with a mandatory where clause to prevent accidental deletions.

execute

Run a raw SQL query with optional parameters and an allowWrite flag to enable writes.

ddl

Execute Data Definition Language statements to modify database structure.

add_column

Add a new column to a table with full type, constraints, and position options.

drop_column

Remove a column from a table with safety checks.

modify_column

Change column type, nullability, defaults, and comments.

rename_column

Rename a column while preserving existing data.

rename_table

Rename a table with safety validation.

add_index

Create an index on a table with type, uniqueness, and columns.

drop_index

Drop an index from a table.

transaction

Execute multiple operations atomically within a single transaction.

utility

Perform health checks and metadata operations on the database.

show_table_data

Display table data with formatting, pagination, and optional schema information.