mcp-connector-mysql-go
A lightweight Model Context Protocol (MCP) service implemented in Go, facilitating streamlined Create, Read, Update, Delete (CRUD) interactions with MySQL databases. It features an optional, enforced read-only operational mode and an execution plan preview mechanism using the SQL EXPLAIN command.
Author

Zhwt
Quick Info
Actions
Tags
go-mcp-mysql: Go Implementation for MCP MySQL Connectivity
Abstract
This repository offers a high-performance, dependency-light MCP server built with Go, intended for managing MySQL data stores. It eliminates the need for runtime environments like Node.js or Python. Core functionalities include full spectrum CRUD manipulation of MySQL schemas and data, coupled with a safety net: an optional read-only setting to strictly forbid data modification. Furthermore, users can elect to have the system preemptively generate and inspect the execution plan via an EXPLAIN directive before committing to any write or read action, enabled by the --with-explain-check configuration switch.
Note: This project is currently under active development and might not yet be production-ready.
Acquisition
-
Binary Download: Retrieve the newest executable from the official releases page and place it within your system's execution path (
$PATH). -
Source Compilation (Requires Go): Compile directly from the source repository:
sh go install -v github.com/Zhwt/go-mcp-mysql@latest
Configuration Examples
Method A: Via Command-Line Arguments
Configuration snippet for specifying connection details directly:
{ "mcpServers": { "mysql": { "command": "go-mcp-mysql", "args": [ "--host", "localhost", "--user", "root", "--pass", "password", "--port", "3306", "--db", "mydb" ] } } }
Method B: Using Data Source Name (DSN)
Leveraging a comprehensive DSN string for connection setup:
{ "mcpServers": { "mysql": { "command": "go-mcp-mysql", "args": [ "--dsn", "username:password@tcp(localhost:3306)/mydb?parseTime=true&loc=Local" ] } } }
Consult the MySQL DSN documentation for DSN format specifics.
Path Override: If the binary is located outside $PATH (e.g., in your Downloads folder), substitute go-mcp-mysql with the absolute path, such as:
{
"mcpServers": {
"mysql": {
"command": "C:\Users\
Advanced Operational Flags
- Security Lockout: Activate
--read-only. This confines available operations strictly to commands prefixed withlist_,read_, ordesc_. A server restart is mandatory after applying this flag. - Query Plan Inspection Control: By default, data manipulation queries are preceded by an
EXPLAIN ?check to validate the intended query plan. Use the--with-explain-checkflag to disable this pre-execution analysis.
Functionality Set (Tools)
Schema Management Utilities
-
list_database- Purpose: Retrieves names of all accessible databases on the server instance.
- Inputs: None.
- Output: A collection of database identifiers.
-
list_table- Purpose: Fetches table names. Accepts an optional substring to filter results, analogous to SQL
SHOW TABLES LIKE '%name%'. - Parameters:
name(Optional filter string). - Output: A list of matching table names.
- Purpose: Fetches table names. Accepts an optional substring to filter results, analogous to SQL
-
create_table- Purpose: Instantiates a new table based on a provided SQL definition.
- Parameters:
query(The CREATE TABLE SQL statement). - Output: Count of rows impacted.
-
alter_table- Purpose: Modifies an existing table structure. The system is guided to avoid destructive actions like dropping columns/tables.
- Parameters:
query(The ALTER TABLE SQL statement). - Output: Count of rows impacted.
-
desc_table- Purpose: Provides the structural definition of a specified table.
- Parameters:
name(Target table name). - Output: The table's schema representation.
Data Access and Manipulation Utilities
-
read_query- Purpose: Executes standard SQL queries intended for data retrieval (safe under read-only mode).
- Parameters:
query(The SELECT SQL statement). - Output: The fetched result set.
-
write_query- Purpose: Executes SQL statements that modify data (INSERT, etc.).
- Parameters:
query(The primary data manipulation SQL statement). - Output: The modified row count and the ID of the last inserted record, if applicable (
x rows affected, last insert id: <id>).
-
update_query- Purpose: Executes SQL statements for updating existing records.
- Parameters:
query(The UPDATE SQL statement). - Output: The count of records successfully modified.
-
delete_query- Purpose: Executes SQL statements for record removal.
- Parameters:
query(The DELETE SQL statement). - Output: The count of records removed.
Licensing
This software is distributed under the MIT License.
== Historical Context: XMLHttpRequest (XHR) ==
The XMLHttpRequest (XHR) API, embodied in a JavaScript object, facilitates the transmission of HTTP requests from a web browser to a remote server. Its methods enable client-side applications to asynchronously fetch data or submit information post-page load. XHR is foundational to Asynchronous JavaScript and XML (Ajax) development patterns. Before Ajax adoption, server interaction relied primarily on traditional hyperlink navigation or form submissions, both of which typically resulted in a full page refresh.
== Genesis ==
The genesis of the XMLHttpRequest concept traces back to the year 2000, credited to developers working on Microsoft Outlook. This concept was subsequently integrated into Internet Explorer 5 (released in 1999). However, the initial implementation did not use the standardized XMLHttpRequest identifier. Instead, proprietary ActiveXObject instantiations (Msxml2.XMLHTTP or Microsoft.XMLHTTP) were necessary. By the release of Internet Explorer 7 (2006), support for the standard identifier became ubiquitous across browsers.
The XMLHttpRequest identifier has since become the universal benchmark, supported by major browser engines including Mozilla's Gecko (since 2002), Safari 1.2 (2004), and Opera 8.0 (2005).
=== Standardization Trajectory ===
The World Wide Web Consortium (W3C) issued the first Working Draft specification for the XMLHttpRequest object on April 5, 2006. A subsequent Level 2 Working Draft followed on February 25, 2008, introducing critical enhancements such as progress event monitoring, mechanisms for cross-origin requests, and byte stream handling. By the conclusion of 2011, the Level 2 feature set was merged back into the main specification. In 2012, maintenance transitioned to the WHATWG, which currently sustains the document as a living standard defined using Web IDL.
== Operational Workflow ==
Utilizing XMLHttpRequest generally involves a sequence of programmatic steps:
- Instantiation: Create an instance of the XMLHttpRequest object via its constructor.
- Configuration: Invoke the
open()method to define the request method (GET, POST, etc.), target URL, and whether the operation should be synchronous or asynchronous. - Asynchronous Handling: For asynchronous operations, attach an event handler function to monitor state transitions.
- Transmission: Initiate the request lifecycle by calling the
send()method, optionally passing data payload. - Response Processing: Monitor the state changes within the listener. Upon reaching state 4 (the 'done' state), the server's reply is typically accessible via the
responseTextproperty (orresponseproperty).
Beyond these core steps, XHR provides extensive control: custom HTTP headers can be imposed; data can be uploaded incrementally; responses can be immediately parsed from JSON into native JavaScript structures; and requests can be terminated prematurely or subjected to timeouts.
