一个与MySQL数据库集成的MCP服务器实现,为大型语言模型(LLMs)提供安全的数据库访问能力。
npm install -g @kevinwatt/mysql-mcp
{
"mcpServers": {
"mysql": {
"command": "npx",
"args": [
"-y",
"@kevinwatt/mysql-mcp"
],
"env": {
"MYSQL_HOST": "127.0.0.1",
"MYSQL_PORT": "3306",
"MYSQL_USER": "root",
"MYSQL_PASS": "",
"MYSQL_DB": "your_database"
}
}
}
}

mysql_query
sql
(字符串): 要执行的SQL SELECT查询mysql_execute
sql
(字符串): SQL语句(INSERT/UPDATE/DELETE)params
(数组, 可选): SQL语句的参数list_tables
describe_table
table
(字符串): 要描述的表名让您的LLM执行以下命令:
"Show me all tables in the database" "Describe the structure of users table" "Select all active users from the database" "Insert a new record into orders table"
如果需要,手动启动服务器:
npx @kevinwatt/mysql-mcp
MIT
Dewei Yen