home / mcp / fhuang mcp mysql mcp server

fhuang mcp mysql MCP Server

一个提供MySQL数据库操作的模型上下文协议服务器。该服务器使AI模型能够通过标准化接口与MySQL数据库进行交互。支持对数据库的所有操作。

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "huangfeng19820712-mcp-mysql-server": {
      "command": "npx",
      "args": [
        "-y",
        "@fhuang/mcp-mysql-server",
        "mysql://user:password@localhost:port/database"
      ],
      "env": {
        "MYSQL_HOST": "your_host",
        "MYSQL_USER": "your_user",
        "MYSQL_DATABASE": "your_database",
        "MYSQL_PASSWORD": "your_password"
      }
    }
  }
}

This MCP server enables AI models to perform MySQL database operations through a standardized Model Context Protocol interface, enabling seamless querying, updates, and data discovery against MySQL databases.

How to use

To use this MCP server with an MCP client, configure a MySQL server entry in your MCP settings and start the server in your environment. The server provides tools to connect to a MySQL database, run queries, manage tables, and inspect schema or server status through the MCP workflow.

How to install

Prerequisites: Node.js (and npm) or a compatible runtime for running MCP servers; an MCP-enabled environment where you can manage server configurations.

npx -y @smithery/cli install @fhuang/mcp-mysql-server --client claude

Configuration

Configure the MCP server in your MCP settings to point at the MySQL server using the stdio command flow shown in the README. The server is invoked via npx with the appropriate arguments and optional environment variables for the MySQL connection.

{
  "mcpServers": {
    "mysql": {
      "command": "npx",
      "args": ["-y", "@fhuang/mcp-mysql-server", "mysql://user:password@localhost:port/database"]
    }
  }
}
{
  "mcpServers": {
    "mysql": {
      "command": "npx",
      "args": ["-y", "@fhuang/mcp-mysql-server"],
      "env": {
        "MYSQL_HOST": "your_host",
        "MYSQL_USER": "your_user",
        "MYSQL_PASSWORD": "your_password",
        "MYSQL_DATABASE": "your_database"
      }
    }
  }
}

Security and features

The server emphasizes secure practices, including prepared statements to prevent SQL injection, environment-based password handling, query validation, and automatic connection cleanup. It supports prepared statements for query parameters, comprehensive error handling, TypeScript support, and automatic connection management.

Running evals

The evals package loads an MCP client that runs the index.ts file, so there is no need to rebuild between tests. You can load environment variables by prefixing the npx command.

OPENAI_API_KEY=your-key  npx mcp-eval src/evals/evals.ts src/index.ts

Notes

If you need to run MySQL-related operations locally, follow the installation steps and ensure your MCP configuration points to the correct MySQL host, user, password, and database. The server will expose tools for connecting to the database, executing queries, listing tables, describing tables, showing status variables, and explaining query plans.