mcpField
M
MySQL Readonly MCP Server

MySQL Readonly MCP Server

Local
github.com/the-nine-nationDatabases1Updated 77w ago

About MySQL Readonly MCP Server

MySQL Readonly MCP Server provides a read-only interface for accessing MySQL data through MCP. It is intended for database access where query limits, parameterization, and checks against write operations are required.

Key features

  1. 01Read-only MySQL queries
  2. 02Connection pooling
  3. 03Parameterized queries
  4. 04Automatic row limits
  5. 05Checks against write operations

Use cases

  1. 01Let an agent retrieve database records safely
  2. 02Inspect query results with a default row cap

MCP support

An MCP server that exposes safe, read-only MySQL queries. It restricts non-read operations and limits returned rows.

Configuration

Local server config is the same for every client. Copy it into your client’s MCP config file.

No install method listed yet

We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.

Repository

Tools

No tool list yet

Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.

Details

From the project README

MySQL Readonly MCP Server

这是一个基于MCP(Model Context Protocol)的MySQL只读查询服务器,它允许通过安全的只读查询接口访问MySQL数据库。

功能特点

  • 支持MySQL数据库的只读查询操作
  • 使用连接池管理数据库连接
  • 自动限制查询结果数量
  • 支持参数化查询
  • 提供格式化的查询结果输出
  • 内置安全检查,防止非只读操作

环境要求

  • Python 3.10+
  • MySQL 5.7+
  • aiomysql

安装

git clone https://github.com/the-nine-nation/mysql-mcp.git
pip install -e .

使用方法

以cursor为例,将如下字典放入config.json: 其中 sys.executable为python虚拟环境的执行文件,通常名字为python,conda或uv下皆可以 mysql_mcp_py为main.py文件的绝对路径

    "mysql": {
        "command": sys.executable,
        "args": [mysql_mcp_py],
        "env": {
            "MYSQL_ENABLED": "true",
            "MYSQL_HOST": "mysql数据库的ip",
            "MYSQL_PORT": "mysql数据库的端口",
            "MYSQL_DATABASE": "mysql数据库的名称",
            "MYSQL_USERNAME": "mysql数据库的用户名",
            "MYSQL_PASSWORD": "mysql数据库的密码",
            "MYSQL_POOL_MINSIZE": "1",
            "MYSQL_POOL_MAXSIZE": "10",
            "MYSQL_RESOURCE_DESC_FILE": "mysql数据库的资源描述文件路径"
        }
    }

请注意: 1.MYSQL_RESOURCE_DESC_FILE是一个说明,可以将数据库中一些信息放入其中,例如什么表是做什么用的,能够提升模型理解能力. 2.MYSQL_ENABLED默认可以不用填

安全特性

  • 只允许只读操作
  • 防止多语句执行
  • 自动限制查询结果数量
  • 使用参数化查询防止SQL注入

注意事项

  • 确保数据库用户只有只读权限
  • 资源描述文件是必需的,用于定义可用的查询接口
  • 查询结果默认限制为20行,可通过环境变量调整

贡献

欢迎提交Issue和Pull Request。

Comments

Markdown supported

New to MCP?

From what the protocol is to installing your first server, these answers cover most first questions.

An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.