mcp-mysql-server
@f4ww4z/mcp-mysql-服务器
提供 MySQL 数据库操作的模型上下文协议服务器。该服务器使 AI 模型能够通过标准化接口与 MySQL 数据库交互。
安装
通过 Smithery 安装
要通过Smithery自动为 Claude Desktop 安装 MySQL 服务器:
npx -y @smithery/cli install @f4ww4z/mcp-mysql-server --client claude手动安装
npx @f4ww4z/mcp-mysql-serverRelated MCP server: MCP MySQL Server
配置
服务器需要在您的 MCP 设置配置文件中设置以下环境变量:
建议使用
{
"mcpServers": {
"mysql": {
"command": "npx",
"args": ["-y", "@f4ww4z/mcp-mysql-server", "mysql://user:password@localhost:port/database"],
}
}
}{
"mcpServers": {
"mysql": {
"command": "npx",
"args": ["-y", "@f4ww4z/mcp-mysql-server"],
"env": {
"MYSQL_HOST": "your_host",
"MYSQL_USER": "your_user",
"MYSQL_PASSWORD": "your_password",
"MYSQL_DATABASE": "your_database"
}
}
}
}运行评估
evals 包会加载一个 mcp 客户端,然后运行 index.ts 文件,因此测试之间无需重新构建。您可以通过在 npx 命令前添加前缀来加载环境变量。完整文档可在此处找到。
OPENAI_API_KEY=your-key npx mcp-eval src/evals/evals.ts src/index.ts可用工具
1. 连接数据库
使用提供的凭据建立与 MySQL 数据库的连接。
use_mcp_tool({
server_name: "mysql",
tool_name: "connect_db",
arguments: {
host: "localhost",
user: "your_user",
password: "your_password",
database: "your_database"
}
});2. 查询
使用可选的准备好的语句参数执行 SELECT 查询。
use_mcp_tool({
server_name: "mysql",
tool_name: "query",
arguments: {
sql: "SELECT * FROM users WHERE id = ?",
params: [1]
}
});3. 执行
使用可选的准备好的语句参数执行 INSERT、UPDATE 或 DELETE 查询。
use_mcp_tool({
server_name: "mysql",
tool_name: "execute",
arguments: {
sql: "INSERT INTO users (name, email) VALUES (?, ?)",
params: ["John Doe", "john@example.com"]
}
});4. 列表表
列出所连接数据库中的所有表。
use_mcp_tool({
server_name: "mysql",
tool_name: "list_tables",
arguments: {}
});5. describe_table
获取特定表的结构。
use_mcp_tool({
server_name: "mysql",
tool_name: "describe_table",
arguments: {
table: "users"
}
});特征
通过自动清理来安全处理连接
查询参数的预处理语句支持
全面的错误处理和验证
TypeScript 支持
自动连接管理
安全
使用准备好的语句来防止 SQL 注入
支持通过环境变量进行安全密码处理
执行前验证查询
完成后自动关闭连接
错误处理
服务器提供了常见问题的详细错误消息:
连接失败
无效查询
缺少参数
数据库错误
贡献
欢迎贡献!请随时向https://github.com/f4ww4z/mcp-mysql-server提交 Pull 请求。
执照
麻省理工学院
Available Tools
4 toolsdescribe_tableB
Get table structure
| Name | Required | Description | Default |
|---|---|---|---|
| table | Yes | Table name |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, and the description fails to disclose behavioral traits like read-only nature, side effects, or required permissions. It simply states the function without additional context.
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 (two words), front-loaded, and gets straight to the point. However, it could benefit from a bit more detail without sacrificing brevity.
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 is simple with one parameter and no output schema, the description is minimal but adequate for a basic understanding. However, it doesn't specify what 'structure' includes (e.g., columns, types), leaving some ambiguity.
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 coverage is 100% with the only parameter 'table' described as 'Table name'. The description adds no new meaning beyond the schema, so baseline 3 is appropriate.
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 'Get table structure' clearly states the verb (Get) and resource (table structure), and distinguishes the tool from siblings like execute, list_tables, and query, which have different 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 vs alternatives, such as list_tables or query. It lacks context on when not to use it or any prerequisites.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
executeB
Execute an INSERT, UPDATE, or DELETE query
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | SQL query (INSERT, UPDATE, DELETE) | |
| params | No | Query parameters (optional) |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description must bear the burden of behavioral disclosure. It confirms mutation but fails to detail side effects, permanence, or return 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 short sentence with no wasted words, but it could include more detail without sacrificing conciseness.
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 lack of output schema and annotations, the description does not explain return values or error behavior. It is too minimal for a mutation tool.
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 coverage is 100%, and the description does not add meaning beyond the schema. The schema already documents 'sql' and 'params' adequately.
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 executes INSERT, UPDATE, or DELETE queries, which specifies the action and resource. It distinguishes from sibling tools like 'query' which likely handles SELECT statements.
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 implies usage for write operations but does not explicitly guide when to use this tool versus alternatives like 'query'. There is no mention of prerequisites or restrictions.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
list_tablesB
List all tables in the database
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
There are no annotations, so the description must fully disclose behavior. It merely states 'List all tables', which implies a read operation, but omits details on permissions, output format, or performance implications.
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 with no unnecessary words. It is appropriately front-loaded but lacks any structural enhancement like bullet points that could aid readability.
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 no output schema or annotations, the description should explain what 'list' returns (e.g., table names, schemas). Without this, an agent may not know how to use the result. Sibling tools like 'describe_table' suggest additional context might be needed.
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 tool has no parameters, so the description cannot add parameter meaning. Baseline for zero parameters is 4, and the description is sufficient for the parameterless case.
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 lists all tables in the database. While it distinguishes from 'describe_table' by listing instead of describing, it does not explicitly differentiate from potential siblings like 'query' or 'execute'.
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 its siblings (describe_table, execute, query). It is implied that it retrieves table names, but no context on prerequisites or alternatives.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
queryB
Execute a SELECT query
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | SQL SELECT query | |
| params | No | Query parameters (optional) |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description bears full responsibility for behavioral disclosure. It only states the tool executes a SELECT query, but does not explicitly confirm it is read-only, mention permission requirements, error handling, or the effect of malformed queries. The implied read-only nature is not sufficient.
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 concise sentence that front-loads the main action. It is not verbose, though it could include more context without losing conciseness. The structure is effective but minimal.
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?
There is no output schema, yet the description does not explain what the tool returns (e.g., result set structure, row count, error messages). It also lacks information on pagination, limits, or behavior with large queries, leaving the agent with significant gaps.
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%, so the schema already documents both parameters ('sql' and 'params') adequately. The description adds no additional meaning or context about parameter usage, formatting, or constraints beyond the schema, earning a baseline score of 3.
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 'Execute a SELECT query' clearly identifies the tool's action (execute) and resource (SELECT query). It distinguishes from sibling tools like 'execute' (which likely handles other SQL statements) and 'describe_table'/'list_tables' (which are informational).
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 does not mention that for non-SELECT queries (e.g., INSERT, UPDATE) one should use the sibling 'execute' tool, nor does it specify any prerequisites or limitations.
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.
4 tool updates
v1.0.1- First observed
describe_table - First observed
execute - First observed
list_tables - First observed
query
TDQS
Each tool serves a distinct purpose: describe_table shows schema, execute handles writes, list_tables lists tables, and query handles reads. No overlap or ambiguity.
Naming is inconsistent: 'describe_table' and 'list_tables' follow verb_noun, while 'execute' is a bare verb and 'query' is a noun. No uniform pattern.
Four tools is reasonable for basic database operations, covering schema inspection, reads, and writes. Could be slightly expanded, but not under- or over-scoped.
Covers essential CRUD and schema listing, but misses DDL operations like create/alter/drop table, which are common needs. Notable gap for schema modification.
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
- mcpOAuthcom.gibsonai
GibsonAI MCP server: manage your databases with natural language
MCP server unifying ERPs, CRMs, APIs and knowledge base for Claude, ChatGPT and Gemini.
MCP server that lets AI assistants use all OneSchema features exposed via the public API.
MCP server for AI dialogue using various LLM models via AceDataCloud
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceA server that enables AI models to interact with MySQL databases through a Model Control Protocol, providing tools for table creation, schema inspection, query execution, and data retrieval.28MIT
- AlicenseBqualityDmaintenanceA Model Context Protocol server that enables AI models to interact with MySQL databases, providing tools for querying, executing statements, listing tables, and describing table structures.5342MIT
- FlicenseBqualityDmaintenanceA Model Context Protocol server that enables AI models to interact with MySQL databases through a standardized interface, providing tools for querying, executing commands, and managing database schemas.7-
- FlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that enables AI models to interact with MySQL databases through natural language, supporting SQL queries, table creation, and schema exploration.3-
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/f4ww4z/mcp-mysql-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server