🔌
MCP工具

mcp-server-mysql — Claude MCP 必备工具中文教程

基于 JavaScript · 让 AI 助手直接操作你的系统与工具
英文名:mcp-server-mysql
⭐ 1.7k Stars 🍴 217 Forks 💻 JavaScript 📄 MIT 🏷 AI 8.6分
8.6AI 综合评分
mcp
✦ AI Skill Hub 推荐

mcp-server-mysql — Claude MCP 必备工具中文教程 是 AI Skill Hub 本期精选MCP工具之一。已获得 1.7k 颗 GitHub Star,综合评分 8.6 分,整体质量较高。我们强烈推荐将其纳入你的 AI 工具库,帮助提升工作效率。

📚 深度解析
mcp-server-mysql — Claude MCP 必备工具中文教程 是一款基于 MCP(Model Context Protocol)标准协议的 AI 工具扩展。MCP 协议由 Anthropic 开发并开源,旨在建立 AI 模型与外部工具之间的标准化通信接口,目前已被 Claude Desktop、Claude Code、Cursor 等主流 AI 工具采纳。

通过安装 mcp-server-mysql — Claude MCP 必备工具中文教程,你的 AI 助手将获得额外的工具调用能力,可以用自然语言直接操控该工具的功能,无需学习复杂的命令行语法。MCP 工具的核心价值在于"一次配置,永久增强"——配置完成后,每次与 AI 对话时都可以无缝调用这些工具。

在技术实现上,MCP 工具通过标准的 JSON-RPC 协议与 AI 客户端通信,工具的功能以"工具列表"的形式暴露给 AI 模型,AI 可以按需调用。mcp-server-mysql — Claude MCP 必备工具中文教程 提供了结构化的工具调用接口,使 AI 模型能够精确地理解和使用每个功能点,显著降低 AI 在工具使用上的错误率。

与传统的 API 集成相比,MCP 工具的优势在于无需编写代码——用户只需在配置文件中添加几行 JSON,即可让 AI 获得全新能力。AI Skill Hub 将 mcp-server-mysql — Claude MCP 必备工具中文教程 评为 AI 评分 8.6 分,属于同类工具中的优质选择。
📋 工具概览

mcp-server-mysql — Claude MCP 必备工具中文教程 是一款遵循 MCP(Model Context Protocol)标准协议的 AI 工具扩展。通过 MCP 协议,它可以让 Claude、Cursor 等主流 AI 客户端直接访问和操作外部工具、数据源和服务,实现 AI 能力的无缝扩展。无论是文件操作、数据库查询还是 API 调用,都可以通过自然语言在 AI 对话中直接触发,极大提升生产效率。

GitHub Stars
⭐ 1.7k
开发语言
JavaScript
支持平台
Windows / macOS / Linux
维护状态
正常维护,社区驱动
开源协议
MIT
AI 综合评分
8.6 分
工具类型
MCP工具
Forks
217
📖 中文文档
以下内容由 AI Skill Hub 根据项目信息自动整理,如需查看完整原始文档请访问底部「原始来源」。

mcp-server-mysql — Claude MCP 必备工具中文教程 是一款遵循 MCP(Model Context Protocol)标准协议的 AI 工具扩展。通过 MCP 协议,它可以让 Claude、Cursor 等主流 AI 客户端直接访问和操作外部工具、数据源和服务,实现 AI 能力的无缝扩展。无论是文件操作、数据库查询还是 API 调用,都可以通过自然语言在 AI 对话中直接触发,极大提升生产效率。

📌 核心特色
  • 通过标准 MCP 协议与 Claude、Cursor 等主流 AI 客户端深度集成
  • 提供结构化工具调用接口,显著降低 AI 集成复杂度
  • 支持 Claude Desktop 和 Claude Code 无缝接入,开箱即用
  • 可与其他 MCP 工具组合叠加,构建完整 AI 工作站
  • 轻量无侵入设计,不影响现有系统架构
🎯 主要使用场景
  • 在 Claude Desktop 对话中直接调用本地工具,实现 AI 与系统的深度联动
  • 通过自然语言驱动复杂的多步骤自动化任务,代替繁琐手动操作
  • 将多个 MCP 工具组合使用,构建个人专属 AI 工作站
以下安装命令基于项目开发语言和类型自动生成,实际以官方 README 为准。
安装命令
# 方式一:通过 Claude Code CLI 一键安装
claude skill install https://github.com/benborla/mcp-server-mysql

# 方式二:手动配置 claude_desktop_config.json
{
  "mcpServers": {
    "mcp-server-mysql---claude-mcp---------": {
      "command": "npx",
      "args": ["-y", "mcp-server-mysql"]
    }
  }
}

# 配置文件位置
# macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
# Windows: %APPDATA%/Claude/claude_desktop_config.json
📋 安装步骤说明
  1. 确认已安装 Node.js(v18 或以上版本)
  2. 打开 Claude Desktop 或 Claude Code 的 MCP 配置文件
  3. 按「交给 Agent 安装 → Claude Desktop」标签中的 JSON 配置填入 mcpServers 字段
  4. 保存配置文件并重启 Claude 客户端
  5. 重启后,在对话中即可使用本工具
以下用法示例由 AI Skill Hub 整理,涵盖最常见的使用场景。
常用命令 / 代码示例
# 安装后在 Claude 对话中直接使用
# 示例:
用户: 请帮我用 mcp-server-mysql — Claude MCP 必备工具中文教程 执行以下任务...
Claude: [自动调用 mcp-server-mysql — Claude MCP 必备工具中文教程 MCP 工具处理请求]

# 查看可用工具列表
# 在 Claude 中输入:"列出所有可用的 MCP 工具"
以下配置示例基于典型使用场景生成,具体参数请参照官方文档调整。
配置示例
// claude_desktop_config.json 配置示例
{
  "mcpServers": {
    "mcp-server-mysql___claude_mcp_________": {
      "command": "npx",
      "args": ["-y", "mcp-server-mysql"],
      "env": {
        // "API_KEY": "your-api-key-here"
      }
    }
  }
}

// 保存后重启 Claude Desktop 生效
📑 README 深度解析 真实文档 完整度 78/100 查看 GitHub 原文 →
以下内容由系统直接从 GitHub README 解析整理,保留代码块、表格与列表结构。

MCP Server for MySQL - Claude Code Edition

🚀 This is a modified version optimized for Claude Code with SSH tunnel support Original Author: @benborla29 Original Repository: https://github.com/benborla/mcp-server-mysql License: MIT

Key Features of This Fork

  • Claude Code Integration - Optimized for use with Anthropic's Claude Code CLI
  • SSH Tunnel Support - Built-in support for SSH tunnels to remote databases
  • Auto-start/stop Hooks - Automatic tunnel management with Claude start/stop
  • DDL Operations - Added MYSQL_DISABLE_READ_ONLY_TRANSACTIONS for CREATE TABLE support
  • Multi-Project Setup - Easy configuration for multiple projects with different databases

Security Features

  • SQL injection prevention through prepared statements
  • Query whitelisting/blacklisting capabilities
  • Rate limiting for query execution
  • Query complexity analysis
  • Configurable connection encryption
  • Read-only transaction enforcement

Requirements

  • Node.js v20 or higher
  • MySQL 5.7 or higher (MySQL 8.0+ recommended)
  • MySQL user with appropriate permissions for the operations you need
  • For write operations: MySQL user with INSERT, UPDATE, and/or DELETE privileges

Installation

Database Setup

Before running tests, you need to set up the test database and seed it with test data:

  1. Create Test Database and User
   -- Connect as root and create test database
   CREATE DATABASE IF NOT EXISTS mcp_test;

   -- Create test user with appropriate permissions
   CREATE USER IF NOT EXISTS 'mcp_test'@'localhost' IDENTIFIED BY 'mcp_test_password';
   GRANT ALL PRIVILEGES ON mcp_test.* TO 'mcp_test'@'localhost';
   FLUSH PRIVILEGES;
   
  1. Run Database Setup Script
   # Run the database setup script
   pnpm run setup:test:db
   

This will create the necessary tables and seed data. The script is located in scripts/setup-test-db.ts

3. Configure Test Environment Create a .env.test file in the project root (if not existing):

   MYSQL_HOST=127.0.0.1
   MYSQL_PORT=3306
   MYSQL_USER=mcp_test
   MYSQL_PASS=mcp_test_password
   MYSQL_DB=mcp_test
   

4. Update package.json Scripts Add these scripts to your package.json:

   {
     "scripts": {
       "setup:test:db": "ts-node scripts/setup-test-db.ts",
       "pretest": "pnpm run setup:test:db",
       "test": "vitest run",
       "test:watch": "vitest",
       "test:coverage": "vitest run --coverage"
     }
   }
   

First-time setup

pnpm run setup:test:db

Development Setup

  1. Clone the repository
  2. Install dependencies: pnpm install
  3. Build the project: pnpm run build
  4. Run tests: pnpm test

Quick Start for Claude Code Users

  1. Read the Setup Guide: See PROJECT_SETUP_GUIDE.md for detailed instructions
  2. Configure SSH Tunnels: Set up automatic SSH tunnels for remote databases
  3. Use with Claude: Integrated MCP server works seamlessly with Claude Code

A Model Context Protocol server that provides access to MySQL databases through SSH tunnels. This server enables Claude and other LLMs to inspect database schemas and execute SQL queries securely.

Configuration Example

SCHEMA_INSERT_PERMISSIONS=development:true,test:true,production:false
SCHEMA_UPDATE_PERMISSIONS=development:true,test:true,production:false
SCHEMA_DELETE_PERMISSIONS=development:false,test:true,production:false
SCHEMA_DDL_PERMISSIONS=development:false,test:true,production:false

For complete details and security recommendations, see README-MULTI-DB.md.

List all configured servers

claude mcp list

Configuration

Automatic Configuration with Smithery

If you installed using Smithery, your configuration is already set up. You can view or modify it with:

smithery configure @benborla29/mcp-server-mysql

When reconfiguring, you can update any of the MySQL connection details as well as the write operation settings:

  • Basic connection settings:
  • MySQL Host, Port, User, Password, Database
  • SSL/TLS configuration (if your database requires secure connections)
  • Write operation permissions:
  • Allow INSERT Operations: Set to true if you want to allow adding new data
  • Allow UPDATE Operations: Set to true if you want to allow updating existing data
  • Allow DELETE Operations: Set to true if you want to allow deleting data

For security reasons, all write operations are disabled by default. Only enable these settings if you specifically need Claude to modify your database data.

Advanced Configuration Options

For more control over the MCP server's behavior, you can use these advanced configuration options:

{
  "mcpServers": {
    "mcp_server_mysql": {
      "command": "/path/to/npx/binary/npx",
      "args": [
        "-y",
        "@benborla29/mcp-server-mysql"
      ],
      "env": {
        // Basic connection settings
        "MYSQL_HOST": "127.0.0.1",
        "MYSQL_PORT": "3306",
        "MYSQL_USER": "root",
        "MYSQL_PASS": "",
        "MYSQL_DB": "db_name",
        "PATH": "/path/to/node/bin:/usr/bin:/bin",

        // Performance settings
        "MYSQL_POOL_SIZE": "10",
        "MYSQL_QUERY_TIMEOUT": "30000",
        "MYSQL_CACHE_TTL": "60000",

        // Security settings
        "MYSQL_RATE_LIMIT": "100",
        "MYSQL_MAX_QUERY_COMPLEXITY": "1000",
        "MYSQL_SSL": "true",

        // Monitoring settings
        "ENABLE_LOGGING": "true",
        "MYSQL_LOG_LEVEL": "info",
        "MYSQL_METRICS_ENABLED": "true",

        // Write operation flags
        "ALLOW_INSERT_OPERATION": "false",
        "ALLOW_UPDATE_OPERATION": "false",
        "ALLOW_DELETE_OPERATION": "false"
      }
    }
  }
}

Environment Variables

Performance Configuration

  • MYSQL_POOL_SIZE: Connection pool size (default: "10")
  • MYSQL_QUERY_TIMEOUT: Query timeout in milliseconds (default: "30000")
  • MYSQL_CACHE_TTL: Cache time-to-live in milliseconds (default: "60000")
  • MYSQL_QUEUE_LIMIT: Maximum number of queued connection requests (default: "100")
  • MYSQL_CONNECT_TIMEOUT: Connection timeout in milliseconds (default: "10000")

Security Configuration

  • MYSQL_RATE_LIMIT: Maximum queries per minute (default: "100")
  • MYSQL_MAX_QUERY_COMPLEXITY: Maximum query complexity score (default: "1000")
  • MYSQL_SSL: Enable SSL/TLS encryption (default: "false")
  • MYSQL_SSL_CA: Path to SSL CA certificate file (PEM format). Only used when MYSQL_SSL=true. Required for connecting to MySQL instances with self-signed certificates or custom CAs.
  • MYSQL_SSL_CERT: Path to the client certificate file (PEM format) for mTLS. Only used when MYSQL_SSL=true. Enables mutual TLS (mTLS) authentication, where both the server and client present certificates. Required by some database configurations that enforce client certificate verification.
  • MYSQL_SSL_KEY: Path to the client private key file (PEM format) for mTLS. Only used when MYSQL_SSL=true. Must correspond to the certificate specified by MYSQL_SSL_CERT.
  • ALLOW_INSERT_OPERATION: Enable INSERT operations (default: "false")
  • ALLOW_UPDATE_OPERATION: Enable UPDATE operations (default: "false")
  • ALLOW_DELETE_OPERATION: Enable DELETE operations (default: "false")
  • ALLOW_DDL_OPERATION: Enable DDL operations (default: "false")
  • MYSQL_DISABLE_READ_ONLY_TRANSACTIONS: [NEW] Disable read-only transaction enforcement (default: "false") ⚠️ Security Warning: Only enable this if you need full write capabilities and trust the LLM with your database
  • SCHEMA_INSERT_PERMISSIONS: Schema-specific INSERT permissions
  • SCHEMA_UPDATE_PERMISSIONS: Schema-specific UPDATE permissions
  • SCHEMA_DELETE_PERMISSIONS: Schema-specific DELETE permissions
  • SCHEMA_DDL_PERMISSIONS: Schema-specific DDL permissions
  • MULTI_DB_WRITE_MODE: Enable write operations in multi-DB mode (default: "false")

Timezone and Date Configuration

  • MYSQL_TIMEZONE: Set the timezone for date/time values. Accepts formats like +08:00 (UTC+8), -05:00 (UTC-5), Z (UTC), or local (system timezone). Useful for ensuring consistent date/time handling across different server locations.
  • MYSQL_DATE_STRINGS: When set to "true", returns date/datetime values as strings instead of JavaScript Date objects. This preserves the exact database values without any timezone conversion, which is particularly useful for:
  • Applications that need precise control over date formatting
  • Cross-timezone database operations
  • Avoiding JavaScript Date timezone quirks

Monitoring Configuration

  • MYSQL_ENABLE_LOGGING: Enable query logging (default: "false")
  • MYSQL_LOG_LEVEL: Logging level (default: "info")
  • MYSQL_METRICS_ENABLED: Enable performance metrics (default: "false")

Remote MCP Configuration

  • IS_REMOTE_MCP: Enable remote MCP mode (default: "false")
  • REMOTE_SECRET_KEY: Secret key for remote MCP authentication (default: ""). If not provided, remote MCP mode will be disabled.
  • PORT: Port number for the remote MCP server (default: 3000)

Components

Troubleshooting

📚 实用指南(长尾问题)
适合谁
  • 使用 Cursor 编辑器、希望提升 AI 编程效率的开发者
  • 需要让 Claude / Cursor 操作本地工具的 AI 工程师
  • 构建多智能体协作系统的 Agent 开发者
最佳实践
  • 配置 MCP 服务器时建议使用 stdio 传输 + JSON-RPC,避免暴露公网
  • Agent 任务先做 dry-run 验证工具调用链,再开启自主执行
  • Cursor rules 控制在 80 行内,否则模型上下文成本会显著上升
常见错误
  • API key 直接提交到 git 仓库(请用 .env 并加入 .gitignore)
  • MCP 配置路径拼错或权限不足,重启 Claude Desktop 才生效
部署方案
  • CLI:直接 npm install -g / pip install,命令行调用
  • 云端托管:可放在 Vercel / Railway / Fly.io 等 PaaS 平台
相关搜索
mcp-server-mysql 中文教程mcp-server-mysql 安装报错怎么办mcp-server-mysql MCP 配置mcp-server-mysql Agent 工作流mcp-server-mysql 与同类工具对比mcp-server-mysql 最佳实践mcp-server-mysql 适合谁用
⚡ 核心功能
👥 适合人群
Claude Desktop / Claude Code 用户AI 工具开发者需要扩展 AI 能力的专业人士自动化工程师
🎯 使用场景
  • 在 Claude Desktop 对话中直接调用本地工具,实现 AI 与系统的深度联动
  • 通过自然语言驱动复杂的多步骤自动化任务,代替繁琐手动操作
  • 将多个 MCP 工具组合使用,构建个人专属 AI 工作站
⚖️ 优点与不足
✅ 优点
  • +MIT 协议,可免费商用
  • +标准化 MCP 协议,生态互联性强
  • +与 Claude 官方生态无缝对接
  • +即插即用,配置简单快捷
⚠️ 不足
  • 依赖 Claude 客户端,非 Claude 用户无法使用
  • MCP 协议仍在持续演进,接口可能变更
  • 需要一定的配置步骤
⚠️ 使用须知

AI Skill Hub 为第三方内容聚合平台,本页面信息基于公开数据整理,不对工具功能和质量作任何法律背书。

建议在沙箱或测试环境中充分验证后,再部署至生产环境,并做好必要的安全评估。

📄 License 说明

✅ MIT 协议 — 最宽松的开源协议之一,可自由商用、修改、分发,仅需保留版权声明。

🔗 相关工具推荐
📚 相关教程推荐
❓ 常见问题 FAQ
mcp-server-mysql 是一款JavaScript开发的AI辅助工具。A Model Context Protocol server that provides read-only access to MySQL databases. This server enables LLMs to inspect database schemas and execute read-only queries.
💡 AI Skill Hub 点评

经综合评估,mcp-server-mysql — Claude MCP 必备工具中文教程 在MCP工具赛道中表现稳健,质量优秀。如果你已有明确的使用需求,可以直接上手体验;如果还在评估阶段,建议对比同类工具后再做决策。

⬇️ 获取与下载
⬇ 下载源码 ZIP

✅ MIT 协议 · 可免费商用 · 直接从 aiskill88 服务器下载,无需跳转 GitHub

📚 深入学习 mcp-server-mysql — Claude MCP 必备工具中文教程
查看分步骤安装教程和完整使用指南,快速上手这款工具
🌐 原始信息
原始名称 mcp-server-mysql
原始描述 A Model Context Protocol server that provides read-only access to MySQL databases. This server enables LLMs to inspect database schemas and execute read-only queries.
Topics mcp
GitHub https://github.com/benborla/mcp-server-mysql
License MIT
语言 JavaScript
🔗 原始来源
🐙 GitHub 仓库  https://github.com/benborla/mcp-server-mysql

收录时间:2026-05-22 · 更新时间:2026-05-22 · License:MIT · AI Skill Hub 不对第三方内容的准确性作法律背书。