zhwt_go_mcp_mysql

zhwt_go_mcp_mysql

by Zhwt
A ready-to-use MCP server for interacting with MySQL databases, enabling CRUD operations and automation without requiring Node.js or Python environments.

MySQL Integration with Model Context Protocol Server

Overview

The MySQL Integration with Model Context Protocol Server is a zero-burden, ready-to-use MCP server designed for interacting with MySQL databases and automation. It eliminates the need for Node.js or Python environments, providing tools for CRUD operations and a read-only mode to prevent unintended write operations. The server can also check query plans using the EXPLAIN statement before executing queries by adding the --with-explain-check flag.

Note: This project is a work in progress and may not yet be ready for production use.

Installation

  1. Download the latest release and place it in your $PATH or an accessible location.
  2. Alternatively, if you have Go installed, build it from source:
    shell 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"
      ]
    }
  }
}

For more details, refer to MySQL DSN.

Note: If the binary is outside your $PATH, replace go-mcp-mysql with the full path to the binary.

Optional Flags

  • Add --read-only to enable read-only mode. Only tools like list, read_, and desc_ will be available.
  • Add --with-explain-check to disable the default behavior of checking query plans with EXPLAIN.

Tools

Schema Tools

  1. list_database
  2. Lists all databases in the MySQL server.
  3. Parameters: None
  4. Returns: A list of database names.

  5. list_table

  6. Lists all tables in the MySQL server.
  7. Parameters: name (optional) – Filters tables by name.
  8. Returns: A list of matching table names.

  9. create_table

  10. Creates a new table in the MySQL server.
  11. Parameters: query – The SQL query to create the table.
  12. Returns: Number of rows affected.

  13. alter_table

  14. Alters an existing table in the MySQL server.
  15. Parameters: query – The SQL query to alter the table.
  16. Returns: Number of rows affected.

  17. desc_table

  18. Describes the structure of a table.
  19. Parameters: name – The name of the table to describe.
  20. Returns: The structure of the table.

Data Tools

  1. read_query
  2. Executes a read-only SQL query.
  3. Parameters: query – The SQL query to execute.
  4. Returns: The query result.

  5. write_query

  6. Executes a write SQL query.
  7. Parameters: query – The SQL query to execute.
  8. Returns: Number of rows affected and last insert ID.

  9. update_query

  10. Executes an update SQL query.
  11. Parameters: query – The SQL query to execute.
  12. Returns: Number of rows affected.

  13. delete_query

  14. Executes a delete SQL query.
  15. Parameters: query – The SQL query to execute.
  16. Returns: Number of rows affected.

License

This project is licensed under the MIT License.

About

The MySQL Integration with Model Context Protocol Server is a lightweight, easy-to-use solution for MySQL database interaction and automation. It is designed to be zero-burden and does not require Node.js or Python environments.

Topics

Resources

Activity

Languages

Features & Capabilities

Categories
mcp_server model_context_protocol go mysql database automation crud_operations query_plan_checking

Implementation Details

Stats

0 Views
0 Likes
3 GitHub Stars

Repository Info

Zhwt Organization

Similar Servers

continuedev_continue by continuedev
0
0
0