
这是一个模型上下文协议(MCP)服务器,为MySQL数据库提供压缩的模式信息。
概览
这是一个模型上下文协议(MCP)服务器,为MySQL数据库提供压缩的模式信息。当模式转储文件不符合上下文大小(因为你使用了大型数据库模式)时,这个MCP服务器非常有用。 https://github.com/user-attachments/assets/0cecef84-cd70-4f84-95cb-01c6ec7c9ac7 - 列表表(list_tables)- 列出指定数据库中的所有表信息。包括表名、注释、主键、唯一键和外键信息。- 参数 - dbName:用于检索信息的数据库名称(设置环境变量时不要求DB_NAME)- 描述表(describe_tables)- 显示指定数据库中特定表的详细信息。提供格式化信息,如列定义、键约束和索引。
概述(AI 翻译)
这是一个模型上下文协议(MCP)服务器,为MySQL数据库提供压缩的模式信息。 当模式转储文件不符合上下文大小(因为你使用大型数据库模式)时,这个MCP服务器非常有用。
https://github.com/user-attachments/assets/0cecef84-cd70-4f84-95cb-01c6ec7c9ac7
提供的工具
- 列表表(
list_tables) - 列出指定数据库中的所有表信息。包括表名、注释、主键、唯一键和外键信息。
- 参数
dbName:用于检索信息的数据库名称(设置环境变量时DB_NAME无需)- 描述表格([
describe_tables) - 显示指定数据库中特定表的详细信息。提供格式化信息,如列定义、键约束和索引。
- 参数
dbName:用于检索信息的数据库名称(设置DB_NAME环境变量时无需)tableNames:用于检索 的表名数组,用于获取 的详细信息
快速启动
- 配置mcp.json
如果使用Claude代码:
- 使用代理执行SQL生成
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
MySQL Schema MCP Server
This is a Model Context Protocol (MCP) server that provides compressed schema information for MySQL databases. This MCP server is useful when the schema dump file does not fit in the context size because you are using a large database schema.
https://github.com/user-attachments/assets/0cecef84-cd70-4f84-95cb-01c6ec7c9ac7
Provided Tools
- List Tables (
list_tables)- Lists all table information in the specified database. Includes table name, comment, primary key, unique key, and foreign key information.
- Parameters
dbName: The name of the database to retrieve information from (not required when DB_NAME environment variable is set)
- Describe Tables (
describe_tables)- Displays detailed information for specific tables in the specified database. Provides formatted information such as column definitions, key constraints, and indexes.
- Parameters
dbName: The name of the database to retrieve information from (not required when DB_NAME environment variable is set)tableNames: An array of table names to retrieve detailed information for
Quick Start
-
Configure mcp.json
{ "mcpServers": { "mysql-schema-explorer-mcp": { "command": "docker", "args": ["run", "-i", "--rm", "--pull", "always", "--network=host", "-e", "DB_HOST=127.0.0.1", "-e", "DB_PORT=3306", "-e", "DB_USER=root", "-e", "DB_PASSWORD=your_password", "ghcr.io/shibayu36/mysql-schema-explorer-mcp:latest" ] } } }If using Claude Code:
claude mcp add mysql-schema-explorer-mcp -- docker run -i --rm --pull always --network=host \ -e DB_HOST=127.0.0.1 \ -e DB_USER=root \ -e DB_PASSWORD=your_password \ -e DB_PORT=3306 \ ghcr.io/shibayu36/mysql-schema-explorer-mcp:latest -
Execute SQL generation using the agent
Example: Using the structure of the ecshop database, list the names of the 3 most recently ordered products by the user shibayu36.
Usage
Fixing to a Specific Database
When accessing only one database, you can set the DB_NAME environment variable to avoid specifying the database name each time.
{
"mcpServers": {
"mysql-schema-explorer-mcp": {
"command": "docker",
"args": ["run", "-i", "--rm", "--network=host",
"-e", "DB_HOST=127.0.0.1",
"-e", "DB_PORT=3306",
"-e", "DB_USER=root",
"-e", "DB_PASSWORD=your_password",
"-e", "DB_NAME=ecshop",
"ghcr.io/shibayu36/mysql-schema-explorer-mcp:latest"
]
}
}
}
Using Binary Instead of Docker
If you have a Go development environment, you can also install and use the binary directly.
-
Install the command
go install github.com/shibayu36/mysql-schema-explorer-mcp@latest -
Configure mcp.json
{ "mcpServers": {
安装
docker run -i --rm --pull always --network=host -e DB_HOST=127.0.0.1 -e DB_PORT=3306 -e DB_USER=root -e DB_PASSWORD=your_password ghcr.io/shibayu36/mysql-schema-explorer-mcp:latest配置
{
"mcpServers": {
"mysql-schema-explorer-mcp": {
"command": "docker",
"args": ["run", "-i", "--rm", "--pull", "always", "--network=host",
"-e", "DB_HOST=127.0.0.1",
"-e", "DB_PORT=3306",
"-e", "DB_USER=root",
"-e", "DB_PASSWORD=your_password",
"ghcr.io/shibayu36/mysql-schema-explorer-mcp:latest"
]
}
}
}