DM

designcomputer/mysql_mcp_server

开发工具

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

1408 stars 261 forks 质量 87 趋势 45MIT

一个模型上下文协议(MCP)服务器,支持与MySQL数据库的安全交互

概览

一种模型上下文协议(MCP)实现,实现与MySQL数据库的安全交互。该服务器组件促进了AI应用(主机/客户端)与MySQL数据库之间的通信,使数据库探索和分析通过受控界面更加安全和结构化。 :MySQL MCP 服务器支持标准输入/输出(STDIO)和可流式HTTP(SSE)传输模式。SSE 模式推荐用于远程/自托管部署。 - — Fronteir AI 为你运行服务器;无需本地设置。- — Smithery 会在你自己的机器上安装并运行服务器。

概述(AI 翻译)

一种模型上下文协议(MCP)实现,实现与MySQL数据库的安全交互。该服务器组件促进了AI应用(主机/客户端)与MySQL数据库之间的通信,使数据库探索和分析通过受控界面更加安全和结构化。

注意:MySQL MCP 服务器支持标准输入/输出(STDIO)和可流式 HTTP(SSE)传输模式。SSE 模式推荐用于远程/自托管部署。

部署选项

  • Hosted — Fronteir AI 为你运行服务器;无需本地设置。
  • 本地 — Smithery 在你自己的机器上安装并运行服务器。

特色

  • 列出可用 MySQL 表作为资源
  • 阅读表格内容
  • 以正确的错误处理方式执行SQL查询
  • 多数据库模式(可选MYSQL_DATABASE)
  • SSE/HTTP 传输支持 (MCP_TRANSPORT=sse)
  • **SSH 隧道支持
  • 全面的模式信息
  • 表数据采样
  • 通过环境变量实现安全的数据库访问
  • 综合测井

安装

手动安装

通过Smithery安装

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

README

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

MySQL MCP Server

A Model Context Protocol (MCP) implementation that enables secure interaction with MySQL databases. This server component facilitates communication between AI applications (hosts/clients) and MySQL databases, making database exploration and analysis safer and more structured through a controlled interface.

Note: MySQL MCP Server supports both standard input/output (STDIO) and Streamable HTTP (SSE) transport modes. The SSE mode is recommended for remote/self-hosted deployments.

Deployment options

  • Hosted — Fronteir AI runs the server for you; no local setup required.
  • Local — install from PyPI and run the server on your own machine (see Installation).

Features

  • List available MySQL tables as resources
  • Read table contents
  • Execute SQL queries with proper error handling
  • Multi-database mode (Optional MYSQL_DATABASE)
  • SSE/HTTP transport support (MCP_TRANSPORT=sse)
  • SSH Tunneling support
  • Comprehensive schema information
  • Table data sampling
  • Secure database access through environment variables
  • Comprehensive logging

Installation

Manual Installation

pip install mysql-mcp-server

Installing via Claude Code CLI

claude mcp add --transport stdio designcomputer-mysql_mcp_server uvx mysql_mcp_server

Installing via Autohand Code CLI

autohand mcp add mysql env MYSQL_HOST=localhost MYSQL_PORT=3306 MYSQL_USER=your_username MYSQL_PASSWORD=your_password MYSQL_DATABASE=your_database uvx mysql_mcp_server

Add --scope project after mcp add to keep the registration in the current workspace. See Autohand Code for current CLI details.

Configuration

Set the following environment variables:

MYSQL_HOST=localhost     # Database host
MYSQL_PORT=3306         # Optional: Database port (defaults to 3306 if not specified)
MYSQL_USER=your_username
MYSQL_PASSWORD=your_password
MYSQL_DATABASE=your_database # Optional: Omit for multi-database mode

# Advanced Configuration
MYSQL_SSL_MODE=DISABLED  # DISABLED, REQUIRED, VERIFY_CA, VERIFY_IDENTITY
MYSQL_CONNECT_TIMEOUT=10 # Timeout in seconds

# Connection behaviour (Optional)
MYSQL_SQL_MODE=TRADITIONAL           # SQL mode applied to the connection (default: TRADITIONAL)

# Compatibility (Optional)
MYSQL_CHARSET=utf8mb4
MYSQL_COLLATION=utf8mb4_unicode_ci
MYSQL_AUTH_PLUGIN=       # e.g., mysql_native_password for older MySQL versions
在 GitHub 查看完整 README

安装

uvx --from mysql-mcp-server mysql_mcp_server
新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "mysql": { "command": "uv", "args": [ "--directory", "path/to/mysql_mcp_server", "run", "mysql_mcp_server" ], "env": { "MYSQL_HOST": "localhost", "MYSQL_PORT": "3306", "MYSQL_USER": "your_username", "MYSQL_PASSWORD": "your_password", "MYSQL_DATABASE": "your_database" } } } }