mcpField
M
MySQL MCP Server

MySQL MCP Server

Local
github.com/sajithammaDatabases1Updated 77w ago

About MySQL MCP Server

MySQL MCP Server is a Python server and interactive client for managing SQLite databases. It lets database users inspect tables and run SQL through natural-language requests.

Key features

  1. 01List database tables
  2. 02Inspect table schemas
  3. 03Run SQL queries with formatted results
  4. 04Interactive database client

Use cases

  1. 01Review available tables
  2. 02Check a table's structure
  3. 03Retrieve or modify data with SQL

MCP support

The MCP server exposes tools for listing tables, describing schemas, and executing SQL. Its accompanying client connects to the server over SSE.

Configuration

Local server config is the same for every client. Copy it into your client’s MCP config file.

No install method listed yet

We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.

Repository

Tools

No tool list yet

Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.

Details

From the project README

MySQL MCP Server

A powerful database management tool built with FastMCP that provides an interactive interface for managing SQLite databases. This project includes both a server component and a client interface for easy database operations.

Features

  • List all tables in the database
  • Get detailed schema information for any table
  • Execute SQL queries with formatted results
  • Interactive client interface for database operations

Prerequisites

  • Python 3.8 or higher
  • pip (Python package installer)

Setup

  1. Clone the repository:
git clone [email protected]:sajithamma/mysql-mcp-server.git
cd mysql-mcp-server
  1. Create and activate a virtual environment:
# Create virtual environment
python3.12 -m venv venv

# Activate virtual environment
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Run the fixture to create the database:
python sqlite_fixture.py

Project Structure

The project consists of two main components:

  1. mcpserver.py - The MCP server implementation
  2. mcpclient.py - The client interface
Server Component

The server provides the following tools:

@mcp.tool()
def list_tables() -> List[str]:
    """List all tables in the SQLite database."""
    # Implementation details...

@mcp.tool()
def describe_table(table_name: str) -> Dict[str, Any]:
    """Get the schema information for a specific table."""
    # Implementation details...

@mcp.tool()
def run_query(query: str) -> Dict[str, Any]:
    """Execute a SQL query and return the results."""
    # Implementation details...
Client Component

The client provides an interactive interface for database operations:

async def main():
    server = MCPServerSse(
        name="SQLite Database Manager",
        params={
            "url": "http://localhost:8000/sse",
        },
    )
    # Client implementation...

Running the Application

  1. Start the MCP server:
fastmcp run mcpserver.py:mcp --transport sse --host 127.0.0.1 --port 8000
  1. In a separate terminal, run the client:
python mcpclient.py

Usage

Once both the server and client are running, you can interact with the database using natural language commands. The client supports the following operations:

  1. List all tables in the database
  2. Get detailed schema information for any table
  3. Execute SQL queries to retrieve or modify data

Example commands:

  • "Show me all tables in the database"
  • "Describe the structure of the users table"
  • "Run a query to select all records from the users table"

Environment Variables

Create a .env file in the project root with the following variables:

# Add any required environment variables here

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Comments

Markdown supported

New to MCP?

From what the protocol is to installing your first server, these answers cover most first questions.

An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.