MM

mineru98/mysql-mcp-server

部署与 DevOps

本页由 AI 翻译,技术细节请以原文为准。 查看原文

28 stars 6 forks 质量 55 趋势 11MIT

一个基于MCP设计用于与光标和MySQL交互的服务器应用。

概览

根据需要更改数据库连接信息。 这将按照预设的设置进行。 MCP 功能可从 Cursor 0.46 及以上版本开始使用。此外,MCP 功能仅对 Cursor Pro 账户用户开放。 - 添加工具 - 执行函数实现实际的逻辑执行(服务层)。- @tool装饰器帮助在MCP(控制器层)注册工具。- 说明 - mysql_mcp_server/执行者下的每个文件代表一个工具。- 如果添加新工具,必须导入 mysql_mcp_server/executors/.py 并包含在数组中。- 这确保模块自动注册在TOOLS_DEFINITION变量中。

概述(AI 翻译)

韩国어 README.md

0.处决

运行 Docker

根据需要更改数据库连接信息。

运行 Docker Compose

这将按照预设配置进行。

直接用 Python 运行

光标配置

MCP功能可从光标0.46及以上版本提供。

此外,MCP功能仅对Cursor Pro账户用户开放。

工具添加技巧

  • 添加工具
  • execute 函数实现实际的逻辑执行(服务层)。
  • @tool 装饰器帮助将工具注册为 MCP(控制器层)。
  • 解释
  • 每个文件在mysql_mcp_server/executors下代表一个工具。
  • 如果新增工具,必须导入 mysql_mcp_server/executors/__init__.py 并包含在 __all__ 数组中。
  • 确保模块自动注册在TOOLS_DEFINITION变量中。

🚧 发展路线图 🚧

  • ⚙️ 参数选项
  • [ ] 🔧 为每个工具启用/禁用开关:提供一个函数以降低输入上下文成本 💰

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

mysql-mcp-server

한국어 README.md

0. Execution

Running with Docker

Change the database connection information as needed.

docker run -d --name mcp-mysql \
  -e MYSQL_HOST=localhost \
  -e MYSQL_PORT=3306 \
  -e MYSQL_USER=root \
  -e MYSQL_PASSWORD=mcpTest1234!!! \
  -e MYSQL_DATABASE=mcp_test \
  -e MCP_PORT=8081 \
  -p 3306:3306 mineru/mcp-mysql:1.0.0

Running with Docker Compose

This will proceed with a pre-configured setup.

docker-compose up -d

Running directly with Python

pip install -r requirements.txt
python mysql_mcp_server/main.py run

Cursor Configuration

MCP functionality is available from Cursor version 0.46 and above.

Additionally, the MCP feature is only accessible to Cursor Pro account users.

Tool Addition Tips

  • Adding a Tool
    • execute functions implement the actual logic execution (Service Layer).
    • The @tool decorator helps register the tool with MCP (Controller Layer).
  • Explanation
    • Each file under mysql_mcp_server/executors represents a single tool.
    • If a new tool is added, it must be imported in mysql_mcp_server/executors/__init__.py and included in the __all__ array.
    • This ensures the module is automatically registered in the TOOLS_DEFINITION variable.
flowchart LR;
    A[AI Model] -->|Request tool list| B[MCP Server]
    B -->|Return available tools| A

    A -->|Request specific tool execution| B
    B -->|Call the corresponding executor| C[Executors]
    
    subgraph Executors
        C1[execute_create_table] -->|Create table| D
        C2[execute_desc_table] -->|View table schema| D
        C3[execute_explain] -->|Query execution plan| D
        C4[execute_insert_query] -->|Execute INSERT query| D
        C5[execute_insight_starter] -->|Checking the schema for building reports| D
        C6[execute_invoke_viz_pro] -->|Visualization chart recommendations| D
        C7[execute_select_query] -->|Execute SELECT query| D
        C8[execute_show_tables] -->|Retrieve table list| D
    end

    D[DatabaseManager] -->|Connect to MySQL| E[MySQL 8.0]

    E -->|Return results| D
    D -->|Send results| C
    C -->|Return results| B
    B -->|Return execution results| A

🚧 Development Roadmap 🚧

  • ⚙️ Parameter Options

    • [ ] 🔧 Enable/Disable Switch for Each Tool: Provide a function to reduce Input Context costs 💰
    • [ ] 🔒 Query Security Level Setting: Offer optional control over functions that could damage asset value, such as DROP, DELETE, UPDATE 🚫
  • ✨ Features

    • [x] 📊 Data Analysis Report Generation: Provide a report generation function optimized for the model to appropriately select various charts based on user requests 📈
在 GitHub 查看完整 README

安装

docker run -d --name mcp-mysql \
新手?先看 mcpskill.org 教程 →