Content
# Tool List
<div align="center">
[](https://archestra.ai/mcp-catalog/pengcunfu__go-mcp-mysql)
[](https://opensource.org/licenses/Apache-2.0)
[](https://goreportcard.com/report/github.com/pengcunfu/mysql-mcp-server)
[](https://github.com/pengcunfu/mysql-mcp-server/releases)
**Zero Burden, Ready-to-Use MySQL MCP Server**
</div>
---
## Features
- **Zero Dependency**: No Node.js or Python environment required, single executable file
- **Secure and Reliable**: Supports read-only mode to prevent accidental writes
- **Query Optimization**: Optional EXPLAIN check to optimize query performance
- **Complete CRUD**: Supports full lifecycle management of databases and tables
- **High Performance**: Developed in Go, excellent performance
- **Easy to Use**: Supports both command-line parameters and DSN configuration
> **Note**: This project is actively under development. It is recommended to thoroughly test it before using it in a production environment.
## Installation
### Method 1: Download Precompiled Binary
Download the latest version suitable for your operating system from the [Releases page](https://github.com/pengcunfu/mysql-mcp-server/releases) and place it in `$PATH` or a location where you can easily access it.
### Method 2: Build from Source
If you have Go 1.21 or higher installed:
```bash
go install -v github.com/pengcunfu/mysql-mcp-server@latest
```
## Quick Start
### Configuration Method A: Using Command-Line Parameters
```json
{
"mcpServers": {
"mysql": {
"command": "mysql-mcp-server",
"args": [
"--host", "localhost",
"--user", "root",
"--pass", "password",
"--port", "3306",
"--db", "mydb"
]
}
}
}
```
### Configuration Method B: Using DSN Connection String
```json
{
"mcpServers": {
"mysql": {
"command": "mysql-mcp-server",
"args": [
"--dsn", "username:password@tcp(localhost:3306)/mydb?parseTime=true&loc=Local"
]
}
}
}
```
> **Tip**: For more MySQL DSN configuration options, refer to the [MySQL DSN documentation](https://github.com/go-sql-driver/mysql#dsn-data-source-name).
### Using Absolute Paths
If the binary file is not in `$PATH`, you need to use the full path. For example, Windows users can configure it like this:
```json
{
"mcpServers": {
"mysql": {
"command": "C:\\Users\\<username>\\Downloads\\mysql-mcp-server.exe",
"args": ["--host", "localhost", "--user", "root", "--pass", "password"]
}
}
}
```
## Configuration Options
### Command-Line Parameters
| Flag | Description | Default |
|------|-------------|---------|
| `--host` | MySQL hostname | `localhost` |
| `--user` | MySQL username | `root` |
| `--pass` | MySQL password | - |
| `--port` | MySQL port | `3306` |
| `--db` | Database name | - |
| `--dsn` | Custom DSN (use priority) | - |
| `--read-only` | Enable read-only mode | `false` |
| `--with-explain-check` | Use EXPLAIN check query plan before execution | `false` |
### Optional Flags
| Flag | Description |
|------|-------------|
| `--read-only` | Enable read-only mode, only allow tools starting with `list`, `read_`, and `desc_`, prevent data modification |
| `--with-explain-check` | Use `EXPLAIN` to check query plan before executing CRUD queries, help optimize performance |
> **Note**: Changes to flags require restarting the MCP server to take effect
## Available Tools
### Database Schema Management
#### `list_table`
List all tables in the database server.
- **Parameters**: None
- **Returns**: List of table names
#### `create_table`
Create a new table in the database server.
- **Parameters**:
- `query`: CREATE TABLE SQL statement
- **Returns**: Affected rows
#### `alter_table`
Modify the existing table structure, do not support dropping tables or columns.
- **Parameters**:
- `query`: ALTER TABLE SQL statement
- **Returns**: Affected rows
#### `desc_table`
View the table structure details.
- **Parameters**:
- `name`: Table name
- **Returns**: Table structure information (CREATE TABLE statement)
#### `drop_table`
Delete a table in the database server.
- **Parameters**:
- `name`: Table name
- **Returns**: Execution result
### Data Operations
#### `read_query`
Execute read-only SQL queries (SELECT).
- **Parameters**:
- `query`: SELECT SQL statement
- **Returns**: Query result set (CSV format)
#### `write_query`
Execute write SQL queries (INSERT).
- **Parameters**:
- `query`: INSERT SQL statement
- **Returns**: Affected rows and last inserted ID
#### `update_query`
Execute update SQL queries (UPDATE).
- **Parameters**:
- `query`: UPDATE SQL statement
- **Returns**: Affected rows
#### `delete_query`
Execute delete SQL queries (DELETE).
- **Parameters**:
- `query`: DELETE SQL statement
- **Returns**: Affected rows
## Contribution
Contributions are welcome! If you have any ideas, suggestions, or found bugs, please:
1. Fork this repository
2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request
## License
This project is licensed under the [Apache License 2.0](https://opensource.org/licenses/Apache-2.0).
## Links
- [GitHub Repository](https://github.com/pengcunfu/mysql-mcp-server)
- [Issue Tracker](https://github.com/pengcunfu/mysql-mcp-server/issues)
- [MCP Protocol Documentation](https://modelcontextprotocol.io/)
- [MySQL Driver Documentation](https://github.com/go-sql-driver/mysql)
## Author
**pengcunfu**
- GitHub: [@pengcunfu](https://github.com/pengcunfu)
---
<div align="center">
If this project helps you, give it a star!
</div>
Connection Info
You Might Also Like
markitdown
MarkItDown-MCP is a lightweight server for converting URIs to Markdown.
markitdown
Python tool for converting files and office documents to Markdown.
firecrawl
Firecrawl MCP Server enables web scraping, crawling, and content extraction.
Filesystem
Node.js MCP Server for filesystem operations with dynamic access control.
TrendRadar
TrendRadar: Your hotspot assistant for real news in just 30 seconds.
OmniRoute
Never stop coding. The free AI gateway — one endpoint, 160+ providers, zero...