MySQL MCP Server
Server Configuration
Describes the environment variables required to run the server.
| Name | Required | Description | Default |
|---|---|---|---|
| MYSQL_MCP_HOST | No | MySQL主机地址 | localhost |
| MYSQL_MCP_PORT | No | MySQL端口 | 3306 |
| MYSQL_MCP_USER | No | MySQL用户名 | root |
| MYSQL_MCP_DATABASE | No | 默认数据库 | |
| MYSQL_MCP_MAX_ROWS | No | 查询结果最大行数 | 100 |
| MYSQL_MCP_PASSWORD | No | MySQL密码 | |
| MYSQL_MCP_READ_ONLY | No | 只读模式 | true |
| MYSQL_MCP_QUERY_TIMEOUT | No | 查询超时(秒) | 30 |
| MYSQL_MCP_BLOCKED_TABLES | No | 禁止访问的表列表 | |
| MYSQL_MCP_ALLOWED_DATABASES | No | 允许访问的数据库列表 |
Instructions
Guidance the server publishes about itself, which clients place ahead of the tool catalog so the model reads it before choosing anything.
This server publishes no instructions, or was last inspected before Glama recorded them.
Capabilities
Features and capabilities supported by this server
Protocol revision2025-11-25
| Capability | Details |
|---|---|
| tools | {
"listChanged": true
} |
| logging | {} |
| prompts | {
"listChanged": false
} |
| resources | {
"subscribe": false,
"listChanged": false
} |
Tools
Functions exposed to the LLM to take actions
| Name | Description |
|---|---|
| list_databasesA | 列出MySQL服务器上所有可访问的数据库 |
| list_tablesA | 列出指定数据库中的所有表 |
| describe_tableA | 获取表的详细结构信息,包括列定义、索引、建表语句 |
| queryA | 执行SQL查询(只读,仅支持SELECT/SHOW/DESCRIBE/EXPLAIN) |
| get_table_sampleA | 获取表的样本数据(默认前5行),快速了解数据内容 |
| get_table_statsA | 获取表的统计信息,包括行数、数据大小、索引大小、列基数 |
| explain_queryA | 获取SQL查询的执行计划,用于分析查询性能 |
| execute_writeA | 执行写操作(INSERT/UPDATE/DELETE),需要关闭只读模式 ⚠️ 此工具仅在只读模式关闭时可用(MYSQL_MCP_READ_ONLY=false) |
Prompts
Interactive templates invoked by user choice
| Name | Description |
|---|---|
| analyze_database | 生成数据库分析提示词,帮助AI全面了解数据库结构 |
| optimize_query | 生成SQL优化提示词 |
| compare_tables | 生成表对比提示词 |
Resources
Contextual data attached and managed by the client
| Name | Description |
|---|---|
| get_databases_resource | 数据库列表资源 |
TDQS
Scored across 8 tools
Most tools are clearly distinct in purpose, but `query` overlaps with several specialized tools since it can run SELECT/SHOW/DESCRIBE/EXPLAIN directly. The specialized tools have clear output formats and use cases, so an agent can usually pick correctly, but some boundary overlap exists.
The naming pattern is mostly consistent with snake_case verb_noun names like `list_databases`, `describe_table`, and `explain_query`. The generic `query` tool breaks the pattern slightly, but the overall convention is predictable and readable.
Eight tools is a well-scoped set for a MySQL MCP server. Each tool covers a meaningful area of database interaction—discovery, inspection, sampling, statistics, querying, performance analysis, and writes—without unnecessary redundancy or bloat.
The server provides solid coverage for read operations, schema inspection, query execution, performance analysis, and write operations. Missing DDL operations like creating or altering tables and databases are a minor gap, but for typical database exploration and data manipulation workflows the surface is largely complete.