FastMCP-based MySQL database server

FastMCP-based MySQL database server

mcp-mysql-server-tonycai•bytonycai

A Python MCP server that lets clients query, read, write, and inspect the schema of a local MySQL database over stdio.

License: Not specified•Runtime: Awaiting documentation review•Category: databases storage

WHAT IT DOES

  • •Exposes tools to test the connection, list tables, read and write table data, get table schema, and execute custom SQL queries.
  • •Uses stdio for commands and results to support scripting and automation.
  • •Takes MySQL connection parameters such as host, user, password, and database through configuration.
  • •Can be run in Docker alongside a MySQL container with sample data.

BEST FOR

  • •Developers who want a lightweight local MCP server to explore and query a MySQL database.
  • •Automating MySQL schema inspection and data operations from MCP-compatible tools.
  • •Local testing setups using Docker Compose with a sample MySQL database.

ABOUT MCP-MYSQL-SERVER-TONYCAI

FastMCP-based MySQL database server is cataloged as an MCP server attributed to tonycai. A Python MCP server that lets clients query, read, write, and inspect the schema of a local MySQL database over stdio. It is categorized under databases storage. See the capability inspector for recorded interfaces and their independent review status; consult upstream documentation for the current interface.

HOW TO INSTALL

Installation configuration is not reviewed. No executable setup is offered for this entry; inspect the source repository before proceeding.

LICENSE

Catalog license label: Not specified. Check the source repository's current license and terms before using, modifying or distributing this software.

能力检查器

能力定义尚未审核。未核验的采集内容不会作为可信接口展示。

Tools (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

Resources (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

Prompts (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

NEWSLETTER - COMING LATER

Newsletter subscriptions are not open yet

Email delivery is not connected. This page does not collect email addresses or create subscriptions.

Browse the registry for current listings instead.

Community Reviews

Coming later

Reviews for FastMCP-based MySQL database server are not available yet

Review publishing and storage are not connected. This page does not collect or publish ratings or comments, including after sign-in.

FREQUENTLY ASKED QUESTIONS

How does the server communicate with clients?

It uses standard input and output (stdio) for commands and results.

Can I add new database tools to the server?

Yes, developers can add new functionalities by creating additional MCP tools decorated with `@mcp.tool()`.

上游原版 README

在 GitHub 查看同一版本原文

README.md · 6ee13723c910 · 采集于 2026-11-13 10:42:08 UTC

保留上游原文,不做 AI 改写。为安全起见过滤脚本、表单和不安全链接。

当前显示最后一次成功采集的文档快照,请以来源页面为准。

mcp-mysql-server

A simple Python script for interacting with a local MySQL database via standard input/output (stdio), based on FastMCP.

Overview

mcp-mysql-server provides a command-line interface for querying and inspecting the schema of a local MySQL database. It is designed for ease of use in local development environments where a lightweight, script-based interaction is preferred. The script utilizes standard input and output for commands and results, making it easy to integrate with other command-line tools and workflows.

Features

  • Query Execution: Execute SQL SELECT statements and view the results in a simple, readable format.
  • Data Manipulation: Insert data into tables with the write_table tool.
  • Schema Inspection: Retrieve information about the database schema, including:
    • Listing all tables with the list_tables tool.
    • Displaying the columns and their data types for a specific table with get_table_schema.
  • Connection Testing: Test database connectivity and get server information.
  • Configurable Access Controls: Define connection parameters (host, user, password, database) through configuration, allowing secure access to the database.
  • stdio Interface: Interact with the script using standard input for commands and receive output via standard output, facilitating scripting and automation.
  • Local Deployment Focus: Optimized for use within local development environments.

Getting Started

Prerequisites

  • Python 3.x installed on your system.
  • A local MySQL server instance running.
  • Required Python libraries (install using the requirements.txt file):
    pip install -r requirements.txt
    

Installation

  1. Download or clone the repository to your local machine.

Configuration

  1. Create a configuration file (e.g., config.ini) in the same directory as the script or specify the path when running the script. The configuration file should have the following format:

    [mysql]
    host = localhost
    port = 3306  # Optional, defaults to 3306
    user = your_mysql_user
    password = your_mysql_password
    database = your_database_name
    

    Note: Ensure the MySQL user specified has the necessary privileges to perform the actions you intend to execute.

Usage

Run the script with the following command, specifying the path to your configuration file:

python mcp-mysql-server.py --config config.ini

The script exposes the following tools that you can use to interact with your MySQL database:

  • test_connection: Tests the connection to the database and returns server information.
  • list_tables: Lists all tables in the current database.
  • read_table: Reads and returns all data from a specified table.
  • write_table: Inserts a new row of data into a specified table.
  • get_table_schema: Returns the schema (column definitions) for a specified table.
  • execute_sql: Executes a custom SQL query and returns the results.

Project Structure

  • mcp-mysql-server.py: Main script containing the MySQL MCP server implementation
  • config.ini: Configuration file for MySQL connection parameters
  • requirements.txt: List of Python dependencies
  • changes.log: Log of changes made to the project

Docker Support

This project can be run in Docker containers using Docker Compose. The setup includes:

  1. A MySQL container with sample data
  2. The MCP MySQL Server container

Running with Docker

  1. Make sure you have Docker and Docker Compose installed on your system.
  2. Clone this repository.
  3. From the repository root, run:
docker-compose up -d

This will:

  • Start a MySQL server with sample data (users and posts tables)
  • Start the MCP MySQL Server connected to the MySQL database

Configuration for Docker

A special configuration file (config.docker.ini) is used when running in Docker, which points to the MySQL container.

Testing

Unit tests are provided to ensure the functionality works correctly. The tests use mocking to avoid requiring an actual database connection.

Running Tests Locally

# Make a copy of the main script with underscore naming
cp mcp-mysql-server.py mcp_mysql_server.py

# Run the tests
python -m unittest tests.py

Running Tests with Docker

docker-compose -f docker-compose.test.yml up --build

This will build a test container and run the unit tests within it.

Development

For developers who want to extend this tool, you can add new functionalities by creating additional MCP tools. Each tool is a Python function decorated with @mcp.tool() that handles a specific database operation.

Example of adding a new tool:

@mcp.tool()
def my_new_tool(param1: str, param2: int) -> dict:
    """
    Documentation for the new tool.
    """
    connection = create_mysql_connection()
    cursor = connection.cursor()
    try:
        # Your tool implementation here
        return {"result": "success"}
    finally:
        cursor.close()
        connection.close()

Install configuration

Are you the maintainer?

Claim this server with your GitHub account to request manual ownership verification.

README Embed Badge
Markdown

Link to the catalog listing for FastMCP-based MySQL database server from your README. This badge does not certify ownership, compatibility or security.

[![MCP catalog listing](https://img.shields.io/badge/MCP-awesome--mcp-orange?style=flat-square)](https://awesome-mcp.com/servers/mcp-mysql-server-tonycai)

REPOSITORY STATS

GitHub StarsUnavailable
ForksUnavailable

Public repository statistics could not be verified. Check the configured source address; unavailable counts are not zero.

下载与拉取统计

来源、范围和时段分别列出;不相加,不代表安装人数、活跃用户或安全审核。

尚无已审核的包 / 镜像标识,暂不展示下载统计。

Related databases storage MCP Servers

Alternative and complementary servers in the same category

View all in databases storage →
AIStor MCP server
mcp-server-aistor•minio

This is a Model Context Protocol (MCP) server for interacting with AIStor object stores.

Repository stats unavailable
Databases & Storage
InfluxDB v2 MCP Server
influxdb-mcp-server•idoru

A Model Context Protocol (MCP) server that exposes access to an InfluxDB v2 instance using the InfluxDB OSS API v2.

Repository stats unavailable
Databases & Storage