mysql_mcp_server
mcp_mysql_服务器
介绍
mcp_mysql_server_pro 不仅涉及 MySQL CRUD 操作,还包括数据库异常分析功能,并方便开发人员使用自定义工具进行扩展。
支持 STDIO 和 SSE 模式
支持多个SQL执行,以“;”分隔
支持根据表注释查询数据库表名和字段
支持SQL执行计划分析
支持中文字段转拼音
支持表锁分析
支持数据库健康状态分析
支持readonly、writer、admin三种角色的权限控制
"readonly": ["SELECT", "SHOW", "DESCRIBE", "EXPLAIN"], # Read-only permissions "writer": ["SELECT", "SHOW", "DESCRIBE", "EXPLAIN", "INSERT", "UPDATE", "DELETE"], # Read-write permissions "admin": ["SELECT", "SHOW", "DESCRIBE", "EXPLAIN", "INSERT", "UPDATE", "DELETE", "CREATE", "ALTER", "DROP", "TRUNCATE"] # Administrator permissions支持提示模板调用
Related MCP server: MySQL MCP Server Pro
工具清单
工具名称 | 描述 |
执行sql | 可以根据权限配置执行["SELECT", "SHOW", "DESCRIBE", "EXPLAIN", "INSERT", "UPDATE", "DELETE", "CREATE", "ALTER", "DROP", "TRUNCATE"]命令的SQL执行工具 |
获取中文首字母 | 将中文字段名称转换为拼音首字母 |
获取数据库健康运行状况 | 分析MySQL健康状态(连接状态、事务状态、运行状态、锁状态检测) |
获取表描述 | 根据表名查找数据库中的表结构,支持多表查询 |
获取表索引 | 根据表名查找数据库中的表索引,支持多表查询 |
获取表锁 | 检查当前MySQL服务器是否存在行级锁或者表级锁 |
获取表名 | 根据表注释和描述在数据库中搜索表名 |
获取数据库健康索引使用情况 | 获取当前连接的mysql数据库的索引使用情况,包括冗余索引情况、性能较差的索引情况、查询时间大于30秒的top5个未使用索引情况 |
提示列表
提示名称 | 描述 |
分析mysql提示符 | 这是分析 MySQL 相关问题的提示 |
查询表数据提示 | 这是使用工具查询表数据的提示,如果description为空,则会初始化为MySQL数据库查询助手 |
使用说明
SSE模式
使用 uv 启动服务
将以下内容添加到您的 mcp 客户端工具中,例如 cursor、cline 等。
mcp json 如下:
{
"mcpServers": {
"operateMysql": {
"name": "operateMysql",
"description": "",
"isActive": true,
"baseUrl": "http://localhost:9000/sse"
}
}
}修改 .env 文件内容以使用数据库详细信息更新数据库连接信息:
# MySQL Database Configuration
MYSQL_HOST=192.168.xxx.xxx
MYSQL_PORT=3306
MYSQL_USER=root
MYSQL_PASSWORD=root
MYSQL_DATABASE=a_llm
MYSQL_ROLE=readonly # Optional, default is 'readonly'. Available values: readonly, writer, admin启动命令:
# Download dependencies
uv sync
# Start
uv run server.pySTDIO模式
将以下内容添加到您的 mcp 客户端工具中,例如 cursor、cline 等。
mcp json 如下:
{
"mcpServers": {
"operateMysql": {
"isActive": true,
"name": "operateMysql",
"command": "uv",
"args": [
"--directory",
"G:\\python\\mysql_mcp\\src", # Replace this with your project path
"run",
"server.py",
"--stdio"
],
"env": {
"MYSQL_HOST": "192.168.xxx.xxx",
"MYSQL_PORT": "3306",
"MYSQL_USER": "root",
"MYSQL_PASSWORD": "root",
"MYSQL_DATABASE": "a_llm",
"MYSQL_ROLE": "readonly" # Optional, default is 'readonly'. Available values: readonly, writer, admin
}
}
}
} 自定义工具扩展
在handles包中添加一个新的工具类,继承自BaseHandler,并实现get_tool_description和run_tool方法
在init.py中导入新工具,使其在服务器中可用
示例
创建新表并插入数据,提示格式如下:
# Task
Create an organizational structure table with the following structure: department name, department number, parent department, is valid.
# Requirements
- Table name: t_admin_rms_zzjg
- Field requirements: string type uses 'varchar(255)', integer type uses 'int', float type uses 'float', date and time type uses 'datetime', boolean type uses 'boolean', text type uses 'text', large text type uses 'longtext', large integer type uses 'bigint', large float type uses 'double'
- Table header needs to include primary key field, serial number XH varchar(255)
- Table must include these fixed fields at the end: creator-CJR varchar(50), creation time-CJSJ datetime, modifier-XGR varchar(50), modification time-XGSJ datetime
- Field naming should use tool return content
- Common fields need indexes
- Each field needs comments, table needs comment
- Generate 5 real data records after creation根据表comments查询数据,提示如下:
Query Zhang San's data from the user information table分析慢SQL,提示如下:
select * from t_jcsjzx_hjkq_cd_xsz_sk xsz
left join t_jcsjzx_hjkq_jcd jcd on jcd.cddm = xsz.cddm
Based on current index situation, review execution plan and provide optimization suggestions in markdown format, including table index status, execution details, and optimization recommendations分析SQL死锁问题,提示如下:
update t_admin_rms_zzjg set sfyx = '0' where xh = '1' is stuck, please analyze the cause分析健康状况提示如下
Check the current health status of MySQLAvailable Tools
5 toolsexecute_sqlC
在MySQL5.6s数据库上执行SQL
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | 要执行的SQL语句 |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries full burden for behavioral disclosure. It states the tool executes SQL on MySQL5.6, but doesn't disclose critical behavioral traits: whether it's read-only or can modify data, authentication requirements, transaction handling, error behavior, result format, or any rate limits. '执行SQL' implies both read and write operations are possible, but this isn't clarified.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is extremely concise - a single sentence that directly states the tool's purpose without any wasted words. It's front-loaded with the core functionality and includes the database specification. Every word earns its place.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a SQL execution tool with no annotations and no output schema, the description is incomplete. It doesn't address critical context: what types of SQL are supported, whether it's for read-only queries or data modification, what the return format looks like, error handling, or security implications. The agent lacks sufficient information to use this tool safely and effectively.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, with the single parameter 'query' documented as '要执行的SQL语句' (SQL statement to execute). The description adds no additional parameter semantics beyond what the schema provides. The baseline score of 3 is appropriate when the schema already fully documents parameters.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the action ('执行SQL' - execute SQL) and specifies the target resource ('在MySQL5.6s数据库上' - on MySQL5.6 database). It distinguishes from sibling tools that focus on metadata retrieval (get_table_name, get_table_desc, etc.) rather than SQL execution. However, it doesn't explicitly differentiate from potential non-sibling SQL execution tools.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when this tool is appropriate, what types of SQL statements it supports (SELECT, INSERT, UPDATE, DDL, etc.), or any prerequisites or limitations. The agent must infer usage from the purpose alone.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get_chinese_initialsC
创建表结构时,将中文字段名转换为拼音首字母字段
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | 要获取拼音首字母的汉字文本,以“,”分隔 |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the tool's function but lacks details on behavioral traits such as error handling (e.g., for non-Chinese text), performance considerations, or output format. The description does not contradict annotations, but it fails to provide sufficient context for safe and effective use.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is concise and front-loaded, consisting of a single sentence that directly states the tool's purpose. There is no wasted verbiage, and it efficiently communicates the core function. However, it could be slightly improved by structuring it to include usage context more explicitly.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the complexity of text conversion and the lack of annotations and output schema, the description is incomplete. It does not explain what the tool returns (e.g., a string of initials, a list, or an error message), nor does it address edge cases or dependencies. For a tool with no structured output documentation, this leaves significant gaps for the agent.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema has 100% description coverage, with the 'text' parameter documented as 'Chinese text to get pinyin initials, separated by commas.' The description adds no additional parameter semantics beyond what the schema provides, such as examples or constraints. Since schema coverage is high, the baseline score of 3 is appropriate, as the description doesn't compensate but also doesn't detract.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose: converting Chinese field names to pinyin initials during table structure creation. It specifies the verb ('convert') and resource ('Chinese field names'), though it doesn't explicitly differentiate from sibling tools like get_table_desc or get_table_name, which appear to be related to table metadata but serve different functions.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides minimal usage guidance, only mentioning 'when creating table structures.' It does not specify when to use this tool versus alternatives (e.g., whether it's for database design, data migration, or other contexts), nor does it mention prerequisites or exclusions. This leaves the agent with little context for appropriate invocation.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get_table_descC
根据表名搜索数据库中对应的表结构,支持多表查询
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | 要搜索的表名 |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool searches for table structures and supports multi-table queries, but lacks details on permissions, rate limits, error handling, or output format. For a database query tool with zero annotation coverage, this is a significant gap in transparency about how the tool behaves in practice.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, efficient sentence in Chinese that conveys the core functionality without unnecessary words. It's front-loaded with the main purpose and includes an additional feature (multi-table query support). However, it could be slightly more structured by separating key points, but overall it's concise and to the point.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the complexity of a database query tool with no annotations and no output schema, the description is incomplete. It doesn't explain what '表结构' (table structures) includes (e.g., columns, data types, constraints), how results are returned, or any limitations. For a tool that likely returns detailed metadata, more context is needed to guide effective use.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema has 100% description coverage, with the parameter 'text' documented as '要搜索的表名' (table name to search). The description adds minimal value beyond this, only implying that multiple table names might be supported via '多表查询' (multi-table queries), but doesn't specify syntax or format. With high schema coverage, the baseline score of 3 is appropriate as the schema does the heavy lifting.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose: searching for table structures in a database by table name, with support for multi-table queries. It specifies the verb ('搜索' - search) and resource ('表结构' - table structures), making the function understandable. However, it doesn't explicitly differentiate from sibling tools like get_table_name or get_table_index, which likely serve related but distinct purposes.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides no guidance on when to use this tool versus alternatives. It mentions support for multi-table queries but doesn't clarify scenarios where this is preferable over other tools like get_table_name (which might retrieve table names without structures) or execute_sql (which could query data directly). There's no mention of prerequisites, limitations, or typical use cases.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get_table_indexC
根据表名搜索数据库中对应的表索引,支持多表查询
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | 要搜索的表名 |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool searches for table indexes and supports multi-table queries, but lacks details on permissions, rate limits, error handling, or what '多表查询' entails (e.g., how inputs are processed). This is insufficient for a tool that interacts with a database, leaving behavioral traits unclear.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, efficient sentence in Chinese that conveys the core functionality without unnecessary details. It is front-loaded with the main purpose, though it could be slightly more structured to separate capabilities from constraints. Overall, it earns its place concisely.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the complexity of database operations, lack of annotations, and no output schema, the description is incomplete. It does not explain what the tool returns (e.g., index details, error formats), behavioral aspects like side effects, or how '多表查询' works. This leaves significant gaps for an AI agent to use the tool effectively.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema has 100% description coverage, with the parameter 'text' documented as '要搜索的表名' (table name to search). The description adds minimal value beyond this, only implying that multiple table names might be supported ('多表查询'), but without specifying format or syntax. Baseline 3 is appropriate as the schema does the heavy lifting.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose: '根据表名搜索数据库中对应的表索引,支持多表查询' (search for table indexes in a database based on table names, supporting multi-table queries). It specifies the verb '搜索' (search) and resource '表索引' (table indexes), though it doesn't explicitly differentiate from sibling tools like get_table_desc or get_table_name, which might retrieve different metadata.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides no guidance on when to use this tool versus alternatives. It mentions '支持多表查询' (supports multi-table queries), which hints at a capability, but does not specify scenarios, prerequisites, or exclusions compared to siblings such as execute_sql or get_table_desc. This leaves the agent without clear usage context.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
get_table_nameB
根据表中文名搜索数据库中对应的表名
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | 要搜索的表中文名 |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions searching but doesn't describe how the search works (e.g., exact match, partial match, case sensitivity), what happens if no match is found (e.g., returns null, error), or any performance considerations like rate limits. For a search tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, clear sentence that directly states the tool's function without unnecessary words. It is front-loaded with the core purpose and efficiently conveys the essential information, making it easy to parse and understand quickly.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's complexity (a simple search with one parameter) and the lack of annotations and output schema, the description is minimally adequate. It covers the basic purpose but lacks details on behavior, error handling, and output format. For a tool with no structured metadata beyond the input schema, it should provide more context to be fully helpful.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema has 100% description coverage, with the parameter 'text' documented as '要搜索的表中文名' (Chinese table name to search for). The description adds no additional semantic details beyond what the schema provides, such as examples or constraints on the input format. Since schema coverage is high, the baseline score of 3 is appropriate, as the description doesn't compensate but also doesn't detract.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose: '根据表中文名搜索数据库中对应的表名' (search for corresponding table names in the database based on Chinese table names). It specifies the verb '搜索' (search) and resource '表名' (table names) with the input constraint '表中文名' (Chinese table names). However, it doesn't explicitly differentiate from sibling tools like 'get_table_desc' or 'get_table_index', which likely retrieve different metadata about tables.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools such as 'get_table_desc' (which might retrieve table descriptions) or 'get_table_index' (which might retrieve table indexes), nor does it specify prerequisites like database connectivity or access permissions. The usage context is implied but not explicitly stated.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
5 tool updates
v1.0.0- First observed
execute_sql - First observed
get_chinese_initials - First observed
get_table_desc - First observed
get_table_index - First observed
get_table_name
TDQS
The tools have distinct primary purposes (SQL execution, field name conversion, table structure/index/name retrieval), but there is some overlap between get_table_desc, get_table_index, and get_table_name as they all involve table metadata retrieval, which could cause confusion about which to use for specific queries. Descriptions help clarify, but the boundaries are not perfectly clear.
All tool names follow a consistent verb_noun pattern using snake_case (e.g., execute_sql, get_table_desc), with no deviations in style or convention. This predictability makes it easy for agents to understand and navigate the tool set.
With 5 tools, the count is reasonable and well-scoped for a MySQL server, covering core operations like SQL execution and table metadata access. It is slightly lean but not insufficient, as it avoids bloat while providing essential functionality.
The tool set is severely incomplete for a MySQL database server. It lacks basic CRUD operations (e.g., create_table, update_data, delete_table), data manipulation beyond raw SQL, and lifecycle management tools, leaving significant gaps that will hinder agent workflows and cause failures in typical database interactions.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Generate, fix, explain and run read-only SQL on PostgreSQL, MySQL and SQL Server
Your Supabase account in natural language: run SQL, apply migrations, manage tables, storage, edge f
DBRE-grade SQL analysis inside any MCP client. No connection. No install. Paste a query.
Connect to PlanetScale databases, branches, schema, query insights, and execute SQL
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA universal SQLite database management tool that enables SQL query execution through MCP protocol. Supports SELECT/INSERT/UPDATE/DELETE/CREATE operations with built-in SQL injection protection across stdio, SSE, and streamable-http communication modes.MIT
- AlicenseBqualityDmaintenanceProvides comprehensive MySQL database operations including CRUD, performance optimization, health analysis, and anomaly detection. Supports multiple connection modes, OAuth2.0 authentication, and role-based permissions for database management through natural language.91MIT
- AlicenseNot gradedqualityAmaintenanceMulti-database management tool and MCP server supporting MySQL, PostgreSQL, SQLite, and Dameng DM8, enabling AI assistants to query and manage databases via stdio or HTTP.MIT
- FlicenseNot gradedqualityCmaintenanceEnables SQL queries, schema exploration, and Oracle sequence management across multiple databases including Oracle, OceanBase, and DolphinDB. Supports multiple environments with secure password handling.-
Appeared in Searches
- Developing and redeveloping web frontend and Python backend projects, including frontend-backend integration and debugging
- Using Laravel Helper Functions and Resolving MySQL Table Query Errors
- A platform for managing code repositories and DevOps workflows
- Frontend Development Tool for Detecting Errors
- Searching for Reddit discussions about server-sent events (SSE)
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/wenb1n-dev/mysql_mcp_server_pro'
If you have feedback or need assistance with the MCP directory API, please join our Discord server