MySQL Navigator MCP

by Medsaad
MIT License
2
  • Linux
  • Apple

Integrations

  • Uses .env files for configuration and secure management of database credentials and connection parameters

  • Offers cross-platform compatibility for Linux systems with specified log file locations and installation instructions

  • Provides cross-platform support for macOS with documented log file locations and installation procedures

MySQL 导航器 MCP

一个强大的 MySQL/MariaDB 数据库导航工具,使用 MCP(模型控制协议),可轻松进行数据库查询和管理。

特征

  • 连接到 MySQL/MariaDB 数据库
  • 动态切换不同的数据库
  • 使用类型安全执行 SQL 查询
  • 检索数据库架构信息
  • 查询参数的 Pydantic 模型验证
  • 安全凭证管理
  • 综合测井系统
  • 连接池和重试机制
  • SSL/TLS 支持安全连接

日志文件位置(跨平台)

默认情况下,所有日志都写入:

  • Windows: C:\Users\<YourUsername>\.mcp\mcp-db.log
  • macOS/Linux: /home/<yourusername>/.mcp/mcp-db.log /mcp-db.log 或/Users/<yourusername>/.mcp/mcp-db.log mcp-db.log

如果您的主目录中不存在.mcp文件夹,应用程序将自动创建该文件夹。如果遇到任何问题,您可以手动创建该文件夹:

视窗:

mkdir $env:USERPROFILE\.mcp

macOS/Linux:

mkdir -p ~/.mcp

安装

来自 PyPI(推荐给大多数用户):

pip install mcp-db-navigator

来自源代码(用于开发):

git clone <your-repo-url> cd mcp-db pip install -e .
  1. 使用您的数据库凭证创建一个.env文件:
DB_HOST=your_host DB_PORT=your_port DB_NAME=your_database_name DB_USER=your_username DB_PASSWORD=your_password DB_SSL_CA=/path/to/ssl/ca.pem # Optional: for SSL/TLS connections DB_MAX_RETRIES=3 # Optional: number of connection retries DB_RETRY_DELAY=1.0 # Optional: delay between retries in seconds

使用示例

1.命令行

直接从终端运行 MCP 服务器:

mcp-db --config /path/to/your/project/.env

2. 在光标处

要在Cursor中使用此 MCP 服务器:

  • 打开 Cursor 设置并添加一个新的 MCP 服务器。
  • 使用以下配置(示例):
{ "mcpServers": { "mysql-navigator": { "command": "mcp-db", "args": [ "--config", "/absolute/path/to/your/.env" ] } } }
  • 确保.env文件的路径是绝对的。

3.在Claude桌面

如果 Claude Desktop 支持 MCP 服务器:

  • 添加一个新的 MCP 服务器,并使用上面的--config参数将其指向mcp-db命令。
  • 有关添加自定义 MCP 服务器的详细信息,请参阅 Claude Desktop 的文档。

查询参数

查询字典支持以下参数:

  • table_name (必填):要查询的表的名称
  • select_fields (可选):要选择的字段列表(默认为[*”])
  • where_conditions (可选):WHERE 子句的字段值对字典
  • order_by (可选):排序依据的字段列表
  • order_direction (可选):排序方向“ASC”或“DESC”(默认值:“ASC”)
  • limit (可选):要返回的记录数
  • offset (可选):要跳过的记录数
  • group_by (可选):分组依据的字段列表
  • having (可选):HAVING 子句的字段值对字典
  • join_table (可选):要连接的表的名称
  • join_type (可选):JOIN 操作的类型(默认值:“INNER”)
  • join_conditions (可选):连接条件字典

安全功能

  • 数据库凭证通过配置文件管理
  • 密码在 Pydantic 模型中存储为 SecretStr
  • 所有查询参数的输入验证
  • 通过参数化查询预防 SQL 注入
  • SSL/TLS 加密连接支持
  • 连接字符串清理
  • 查询速率限制
  • 查询参数清理

生产特点

错误处理

  • 全面的数据库操作错误处理
  • 连接超时处理
  • 失败连接的自动重试机制
  • 所有参数的输入验证

表现

  • 连接池以实现最佳资源利用
  • 查询执行时间记录
  • 连接池统计信息
  • 性能指标收集

监控

  • 具有不同日志级别的结构化日志记录
  • 查询执行跟踪
  • 连接状态监控
  • 错误率追踪

贡献

  1. 分叉存储库
  2. 创建你的功能分支( git checkout -b feature/amazing-feature
  3. 提交您的更改( git commit -m 'Add some amazing feature'
  4. 推送到分支( git push origin feature/amazing-feature
  5. 打开拉取请求

执照

该项目根据 MIT 许可证获得许可 - 有关详细信息,请参阅 LICENSE 文件。

-
security - not tested
A
license - permissive license
-
quality - not tested

local-only server

The server can only run on the client's local machine because it depends on local resources.

MySQL 导航器 MCP

  1. 特征
    1. 日志文件位置(跨平台)
      1. 安装
        1. 来自 PyPI(推荐给大多数用户):
        2. 来自源代码(用于开发):
      2. 使用示例
        1. 1.命令行
        2. 2. 在光标处
        3. 3.在Claude桌面
      3. 查询参数
        1. 安全功能
          1. 生产特点
            1. 错误处理
            2. 表现
            3. 监控
          2. 贡献
            1. 执照

              Related MCP Servers

              • -
                security
                F
                license
                -
                quality
                A TypeScript-based MCP server that facilitates SQL query execution and MySQL database connectivity using environment variables.
                Last updated -
                25
                JavaScript
                • Apple
              • A
                security
                A
                license
                A
                quality
                An MCP server that provides read-only access to MySQL databases.
                Last updated -
                4
                695
                17
                JavaScript
                MIT License
                • Linux
                • Apple
              • -
                security
                A
                license
                -
                quality
                A Model Context Protocol (MCP) server that enables AI assistants to interact with MySQL databases by executing SQL queries and checking database connectivity.
                Last updated -
                TypeScript
                MIT License
                • Apple
                • Linux
              • A
                security
                F
                license
                A
                quality
                MCP server that allows Claude AI to interact directly with MySQL databases, enabling query execution and table information retrieval through natural language.
                Last updated -
                1
                6
                3
                JavaScript

              View all related MCP servers

              ID: 7g1ycq5xwv