Cover image
Try Now
2025-04-07

零负担,即使用模型上下文协议(MCP)服务器,用于与MySQL和自动化进行交互。无需node.js或Python环境。

3 years

Works with Finder

1

Github Watches

3

Github Forks

11

Github Stars

go-mcp-mysql

Overview

Zero burden, ready-to-use Model Context Protocol (MCP) server for interacting with MySQL and automation. No Node.js or Python environment needed. This server provides tools to do CRUD operations on MySQL databases and tables, and a read-only mode to prevent surprise write operations. You can also make the MCP server check the query plan by using a EXPLAIN statement before executing the query by adding a --with-explain-check flag.

Please note that this is a work in progress and may not yet be ready for production use.

Installation

  1. Get the latest release and put it in your $PATH or somewhere you can easily access.

  2. Or if you have Go installed, you can build it from source:

go install -v github.com/Zhwt/go-mcp-mysql@latest

Usage

Method A: Using Command Line Arguments

{
  "mcpServers": {
    "mysql": {
      "command": "go-mcp-mysql",
      "args": [
        "--host", "localhost",
        "--user", "root",
        "--pass", "password",
        "--port", "3306",
        "--db", "mydb"
      ]
    }
  }
}

Method B: Using DSN With Custom Options

{
  "mcpServers": {
    "mysql": {
      "command": "go-mcp-mysql",
      "args": [
        "--dsn", "username:password@tcp(localhost:3306)/mydb?parseTime=true&loc=Local"
      ]
    }
  }
}

Please refer to MySQL DSN for more details.

Note: For those who put the binary outside of your $PATH, you need to replace go-mcp-mysql with the full path to the binary: e.g.: if you put the binary in the Downloads folder, you may use the following path:

{
  "mcpServers": {
    "mysql": {
      "command": "C:\\Users\\<username>\\Downloads\\go-mcp-mysql.exe",
      "args": [
        ...
      ]
    }
  }
}

Optional Flags

  • Add a --read-only flag to enable read-only mode. In this mode, only tools beginning with list, read_ and desc_ are available. Make sure to refresh/restart the MCP server after adding this flag.
  • By default, CRUD queries will be first executed with a EXPLAIN ? statement to check whether the generated query plan matches the expected pattern. Add a --with-explain-check flag to disable this behavior.

Tools

Schema Tools

  1. list_database

    • List all databases in the MySQL server.
    • Parameters: None
    • Returns: A list of matching database names.
  2. list_table

    • List all tables in the MySQL server.
    • Parameters:
      • name: If provided, list tables with the specified name, same as SQL SHOW TABLES LIKE '%name%'. Otherwise, list all tables.
    • Returns: A list of matching table names.
  3. create_table

    • Create a new table in the MySQL server.
    • Parameters:
      • query: The SQL query to create the table.
    • Returns: x rows affected.
  4. alter_table

    • Alter an existing table in the MySQL server. The LLM is informed not to drop an existing table or column.
    • Parameters:
      • query: The SQL query to alter the table.
    • Returns: x rows affected.
  5. desc_table

    • Describe the structure of a table.
    • Parameters:
      • name: The name of the table to describe.
    • Returns: The structure of the table.

Data Tools

  1. read_query

    • Execute a read-only SQL query.
    • Parameters:
      • query: The SQL query to execute.
    • Returns: The result of the query.
  2. write_query

    • Execute a write SQL query.
    • Parameters:
      • query: The SQL query to execute.
    • Returns: x rows affected, last insert id: <last_insert_id>.
  3. update_query

    • Execute an update SQL query.
    • Parameters:
      • query: The SQL query to execute.
    • Returns: x rows affected.
  4. delete_query

    • Execute a delete SQL query.
    • Parameters:
      • query: The SQL query to execute.
    • Returns: x rows affected.

License

MIT

相关推荐

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Alexandru Strujac
  • Efficient thumbnail creator for YouTube videos

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • lumpenspace
  • Take an adjectivised noun, and create images making it progressively more adjective!

  • Lists Tailwind CSS classes in monospaced font

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • https://appia.in
  • Siri Shortcut Finder – your go-to place for discovering amazing Siri Shortcuts with ease

  • Carlos Ferrin
  • Encuentra películas y series en plataformas de streaming.

  • Yusuf Emre Yeşilyurt
  • I find academic articles and books for research and literature reviews.

  • tomoyoshi hirata
  • Sony α7IIIマニュアルアシスタント

  • apappascs
  • 发现市场上最全面,最新的MCP服务器集合。该存储库充当集中式枢纽,提供了广泛的开源和专有MCP服务器目录,并提供功能,文档链接和贡献者。

  • ShrimpingIt
  • MCP系列GPIO Expander的基于Micropython I2C的操作,源自ADAFRUIT_MCP230XX

  • jae-jae
  • MCP服务器使用剧作《无头浏览器》获取网页内容。

  • ravitemer
  • 一个功能强大的Neovim插件,用于管理MCP(模型上下文协议)服务器

  • patruff
  • Ollama和MCP服务器之间的桥梁,使本地LLMS可以使用模型上下文协议工具

  • pontusab
  • 光标与风浪冲浪社区,查找规则和MCP

  • av
  • 毫不费力地使用一个命令运行LLM后端,API,前端和服务。

  • Mintplex-Labs
  • 带有内置抹布,AI代理,无代理构建器,MCP兼容性等的多合一桌面和Docker AI应用程序。

  • WangRongsheng
  • 🧑‍🚀 llm 资料总结(数据处理、模型训练、模型部署、 o1 模型、mcp 、小语言模型、视觉语言模型)|摘要世界上最好的LLM资源。

  • modelcontextprotocol
  • 模型上下文协议服务器

    Reviews

    1 (1)
    Avatar
    user_9FvrwyAS
    2025-04-17

    I've been using go-mcp-mysql for a few months now, and I'm thoroughly impressed. Zhwt did an excellent job creating a seamless integration with MySQL databases. The performance is top-notch, and the documentation is clear and helpful. If you're looking for a reliable and efficient MySQL connector in Go, this is a must-try. Check it out on GitHub!