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 协议,它可以让 Claude、Cursor 等主流 AI 客户端直接访问和操作外部工具、数据源和服务,实现 AI 能力的无缝扩展。无论是文件操作、数据库查询还是 API 调用,都可以通过自然语言在 AI 对话中直接触发,极大提升生产效率。
mcp-server-mysql — Claude MCP 必备工具中文教程 是一款遵循 MCP(Model Context Protocol)标准协议的 AI 工具扩展。通过 MCP 协议,它可以让 Claude、Cursor 等主流 AI 客户端直接访问和操作外部工具、数据源和服务,实现 AI 能力的无缝扩展。无论是文件操作、数据库查询还是 API 调用,都可以通过自然语言在 AI 对话中直接触发,极大提升生产效率。
# 方式一:通过 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
# 安装后在 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 生效
🚀 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
MYSQL_DISABLE_READ_ONLY_TRANSACTIONS for CREATE TABLE supportBefore running tests, you need to set up the test database and seed it with test data:
-- 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;
# 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"
}
}
pnpm run setup:test:db
pnpm installpnpm run buildpnpm testA 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.
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.
claude mcp list
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:
For security reasons, all write operations are disabled by default. Only enable these settings if you specifically need Claude to modify your database data.
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"
}
}
}
}
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")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 databaseSCHEMA_INSERT_PERMISSIONS: Schema-specific INSERT permissionsSCHEMA_UPDATE_PERMISSIONS: Schema-specific UPDATE permissionsSCHEMA_DELETE_PERMISSIONS: Schema-specific DELETE permissionsSCHEMA_DDL_PERMISSIONS: Schema-specific DDL permissionsMULTI_DB_WRITE_MODE: Enable write operations in multi-DB mode (default: "false")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:MYSQL_ENABLE_LOGGING: Enable query logging (default: "false")MYSQL_LOG_LEVEL: Logging level (default: "info")MYSQL_METRICS_ENABLED: Enable performance metrics (default: "false")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)AI Skill Hub 为第三方内容聚合平台,本页面信息基于公开数据整理,不对工具功能和质量作任何法律背书。
建议在沙箱或测试环境中充分验证后,再部署至生产环境,并做好必要的安全评估。
✅ MIT 协议 — 最宽松的开源协议之一,可自由商用、修改、分发,仅需保留版权声明。
经综合评估,mcp-server-mysql — Claude MCP 必备工具中文教程 在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 |
收录时间:2026-05-22 · 更新时间:2026-05-22 · License:MIT · AI Skill Hub 不对第三方内容的准确性作法律背书。
选择 Agent 类型,复制安装指令后粘贴到对应客户端