SM

sajithrw/mcp-mysql

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

7 stars 4 forks 质量 68 趋势 15MIT

A Model Context Protocol (MCP) server for MySQL databases with support for AWS RDS. Enables AI assistants to execute queries, inspect schemas, and manage MySQL databases securely through the MCP...

概览

A Model Context Protocol (MCP) server for MySQL databases, including support for AWS RDS and other cloud MySQL instances. This server provides comprehensive database management capabilities through a standardized MCP interface. 📋 See VSCODE_SETUP.md for step-by-step VS Code and GitHub Copilot integration instructions. - ✅ : Connect to local MySQL or cloud instances (AWS RDS, Google Cloud SQL, etc.) - ✅ : Execute SQL queries with prepared statement support - ✅ : List databases, tables, and describe table structures - ✅ : View table indexes and statistics - ✅ : Secure connection handling with SSL support - ✅ : Comprehensive error reporting and connection management Or run ad‑hoc without global install using npx (shown later in config). Create (or update) .vscode/mcp.json in your project or in your global VS Code user settings folder. Use the published package via npx so you always invoke the correct version. Then: 1.

README

以下为原文 README 节选,完整内容请查看原文。

MCP MySQL Server

A Model Context Protocol (MCP) server for MySQL databases, including support for AWS RDS and other cloud MySQL instances. This server provides comprehensive database management capabilities through a standardized MCP interface.

📋 Quick Start for VS Code Users: See VSCODE_SETUP.md for step-by-step VS Code and GitHub Copilot integration instructions.

Features

  • ✅ Database Connection Management: Connect to local MySQL or cloud instances (AWS RDS, Google Cloud SQL, etc.)
  • ✅ Query Execution: Execute SQL queries with prepared statement support
  • ✅ Schema Inspection: List databases, tables, and describe table structures
  • ✅ Index Management: View table indexes and statistics
  • ✅ Security: Secure connection handling with SSL support
  • ✅ Error Handling: Comprehensive error reporting and connection management

Installation

npm install -g @sajithrw/[email protected]

Or run ad‑hoc without global install using npx (shown later in config).

From Source

git clone https://github.com/sajithrw/mcp-mysql.git
cd mcp-mysql
npm install
npm run build

Configuration

Create (or update) .vscode/mcp.json in your project or in your global VS Code user settings folder. Use the published package via npx so you always invoke the correct version.

{
  "servers": {
    "mcp-mysql": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "@sajithrw/[email protected]"
      ],
      "env": {
        "MYSQL_HOST": "localhost",
        "MYSQL_PORT": "3306",
        "MYSQL_USER": "your_username",
        "MYSQL_PASSWORD": "your_password",
        "MYSQL_DATABASE": "your_database"
      }
    }
  }
}

Then:

  1. Reload VS Code window (Command Palette: “Developer: Reload Window”).
  2. Open Command Palette and run: “MCP: Start Server” (pick mcp-mysql).
  3. Use Copilot / MCP clients to call tools (e.g., ask to list tables).

Previous settings.json based github.copilot.advanced.mcp configuration is deprecated in favor of mcp.json discovery.

Alternative: Local Build Path

If working from a local clone/build instead of the published package:

{
  "servers": {
    "mcp-mysql": {
      "type": "stdio",
      "command": "node",
      "args": ["/absolute/path/to/mcp-mysql/build/index.js"],
      "env": {
        "MYSQL_HOST": "localhost",
        "MYSQL_USER": "your_username",
        "MYSQL_PASSWORD": "your_password"
      }
    }
  }
}

Using with Claude Desktop

Add the server to your Claude Desktop configuration:

{
  "mcpServers": {
    "mysql": {
      "command": "npx",
      "args": ["@sajithrw/[email protected]"],
      "env": {
        "MYSQL_HOST": "localhost",
        "MYSQL_USER": "your_username",
        "MYSQL_PASSWORD": "your_password"
      }
    }
  }
}

Using with MCP Inspector

For testing and development:

在 GitHub 查看完整 README

安装

npx @sajithrw/[email protected]
新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "mysql": { "command": "npx", "args": ["@sajithrw/[email protected]"], "env": { "MYSQL_HOST": "localhost", "MYSQL_USER": "your_username", "MYSQL_PASSWORD": "your_password" } } } }