MCP ExplorerExplorer

Mcp Mysql Client

@bonyuta0204on 10 months ago
1 MIT
FreeCommunity
AI Systems
mcp mysql client

Overview

What is Mcp Mysql Client

mcp-mysql-client is a Model Context Protocol (MCP) server designed for interacting with MySQL databases. It allows AI models to perform database operations through a standardized interface.

Use cases

Use cases include AI model training that requires data retrieval from MySQL, automated database management tasks, and applications needing to interact with MySQL databases for data storage and retrieval.

How to use

To use mcp-mysql-client, first build the server with ‘go build’, then run it using ‘./mcp-mysql-client’. You can connect to a MySQL database by providing the required parameters such as host, port, username, and password.

Key features

Key features include the ability to connect to MySQL databases, execute SQL queries, list available databases, list tables within a database, and describe table structures.

Where to use

mcp-mysql-client can be used in various fields such as data analysis, machine learning, and application development where interaction with MySQL databases is required.

Content

MySQL MCP Server

A Model Context Protocol (MCP) server for interacting with MySQL databases.

Overview

This project implements a MySQL client as an MCP server using Go. It allows AI models to interact with MySQL databases through a standardized interface, enabling them to perform database operations like querying, listing databases and tables, and describing table structures.

Features

  • Connect to MySQL databases
  • Execute SQL queries
  • List available databases
  • List tables in a database
  • Describe table structure

Project Structure

.
├── main.go              # Main application entry point
├── pkg/
│   ├── datastore/       # Database connection management
│   │   ├── interface.go # Interface for datastore operations
│   │   └── mysql.go     # MySQL implementation
│   ├── handlers/        # MCP tool handlers
│   │   ├── handlers.go
│   │   └── handlers_test.go
│   ├── integration/     # Integration tests with real MySQL
│   │   ├── helper.go
│   │   └── handlers_integration_test.go
│   └── utils/           # Utility functions
│       └── formatter.go
├── docker-compose.yml   # Docker setup for testing
└── README.md

Requirements

  • Go 1.24 or later
  • MySQL server

Dependencies

Building and Running

# Build the server
go build

# Run the server
./mcp-mysql-client

Testing

Unit Tests

Run the unit tests with:

make test-unit

MCP Tools

Connect

Establishes a connection to a MySQL database.

Parameters:

  • host (required): MySQL host address
  • port (default: “3306”): MySQL port
  • username (required): MySQL username
  • password (required): MySQL password
  • database (default: “”): MySQL database name

Query

Executes a SQL query on the connected database.

Parameters:

  • sql (required): SQL query to execute

List Databases

Lists all databases available on the connected MySQL server.

Parameters: None

List Tables

Lists all tables in the current database or a specified database.

Parameters:

  • database (optional): Database name (uses current connection if not specified)

Describe Table

Describes the structure of a specified table.

Parameters:

  • table (required): Table name

License

MIT

Tools

No tools

Comments

Recommend MCP Servers

View All MCP Servers