Skip to main content

MySQL server implementation for MCP (Model Control Protocol) framework

Project description

mcps-mysql-server

Repository: https://github.com/Shubham9975/mcp-mysql-server.git

A MySQL server implementation for the MCP (Model Control Protocol) framework. This server allows you to interact with MySQL databases through the MCP protocol, enabling SQL execution, table/resource listing, and schema retrieval.

Features

  • Execute SQL queries
  • List MySQL tables as resources
  • Get table schemas
  • Configurable through environment variables
  • Supports various MySQL character sets and collations

Installation

From PyPI

pip install mcps-mysql-server

From Source (GitHub)

git clone https://github.com/Shubham9975/mcp-mysql-server.git
cd mcp-mysql-server
pip install .

Or for development (editable) mode:

pip install -e .

Configuration

Set the following environment variables (required for connection):

  • MYSQL_HOST: MySQL server host (default: "localhost")
  • MYSQL_PORT: MySQL server port (default: 3306)
  • MYSQL_USER: MySQL username (required)
  • MYSQL_PASSWORD: MySQL password (required)
  • MYSQL_DATABASE: MySQL database name (required)
  • MYSQL_CHARSET: MySQL character set (default: "utf8mb4")
  • MYSQL_COLLATION: MySQL collation (default: "utf8mb4_unicode_ci")
  • MYSQL_SQL_MODE: MySQL SQL mode (default: "TRADITIONAL")

Example:

export MYSQL_USER="your_user"
export MYSQL_PASSWORD="your_password"
export MYSQL_DATABASE="your_database"

Usage

After setting environment variables, start the server:

mcps-mysql-server

MCP/Claude/Cursor Integration

Add this to your MCP configuration (e.g., ~/.cursor/mcp.json):

{
  "mcpServers": {
    "mysql-server": {
      "command": "mcps-mysql-server",
      "env": {
        "MYSQL_HOST": "localhost",
        "MYSQL_USER": "your_user",
        "MYSQL_PASSWORD": "your_password",
        "MYSQL_DATABASE": "your_database"
      }
    }
  }
}

Available Tools

execute_sql

Execute an SQL query on the MySQL server.

Example:

SELECT * FROM users LIMIT 10;

Available Resources

  • mysql://tables — List all tables in the database.
  • mysql://table/{table_name} — Get the schema of a specific table. Example: mysql://table/users

Development

  • All main code is in the mysql_server/ directory.
  • Use pip install -e . for editable installs during development.
  • If you add tests, place them in a tests/ directory.

Project Structure

.
├── mysql_server/           # Main package code
├── pyproject.toml          # Build system and metadata
├── README.md               # This file
├── LICENSE                 # License file
└── .gitignore              # Git ignore rules

Troubleshooting

  • Command not found:
    Ensure your Python Scripts directory is in your PATH.
    On Windows, this is usually C:\Users\<YourUser>\AppData\Local\Programs\Python\Python3x\Scripts.

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcps_mysql_server-0.1.2.tar.gz (23.7 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcps_mysql_server-0.1.2-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file mcps_mysql_server-0.1.2.tar.gz.

File metadata

  • Download URL: mcps_mysql_server-0.1.2.tar.gz
  • Upload date:
  • Size: 23.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for mcps_mysql_server-0.1.2.tar.gz
Algorithm Hash digest
SHA256 878af1de4ec686deefa32f0d14488393d50132867d35e5b8b07d7871faba0fa6
MD5 564cd0fbab60578d612d38de08c7b51b
BLAKE2b-256 2a25e3e4cedb0e897bf99c67caf35f27b0d9d0d34a319838feefbbbbf03b7d07

See more details on using hashes here.

File details

Details for the file mcps_mysql_server-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for mcps_mysql_server-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 88453037d426f4c254c3c74ed0e99ae08e8939be801fd8fb83e80674292a8445
MD5 77f49bea3dc8a24b77b0d5fcba6f461a
BLAKE2b-256 3f973456e076aec3a5f4c2cdcfeac74fb9fdf302ed701324c575140648093f86

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page