Skip to main content

MCP Server to connect the MySQL database

Project description

MySQL MCP Server Documentation

Overview

This repository contains the MySQL database configuration for the MCP (Model Context Protocol) server. This MCP server handles data fetching from the connected database.

Prerequisites

  • Python 3.10 or above
  • pip or uv package installer
  • mysql-connector-python

Installation

# Install from PyPI
pip install mcp_mysql_connect

# Or using uv
uv pip install mcp_mysql_connect

Configuration

  1. Create a .env file in your project directory with the following environment variables:
DB_HOST=your_mysql_host
DB_USER=your_username
DB_PASSWORD=your_password
DB_NAME=your_database
  1. Make sure these environment variables are accessible to your application.

Usage

# Example usage with Claude
from mcp.client import Client
from mcp.tools import Tools

# Connect to your MySQL MCP server
tools = Tools()
tools.add_server("mysql", "mcp_mysql_connect")

# Create a client with the tools
client = Client(tools=tools)

# Example query
response = client.complete(
    messages=[
        {"role": "user", "content": "Query all users from the database"}
    ]
)
print(response.content)

Environment Variables

Required environment variables for database connection:

  • DB_HOST - Database host address
  • DB_USER - Database username
  • DB_PASSWORD - Database password
  • DB_NAME - Target database name

Development

To contribute or modify this package, clone the repository and install in development mode:

git clone <repository_url>
cd MySQL-MCP-Server
python -m pip install -e .

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

mcp_mysql_connect-1.0.0.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

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

mcp_mysql_connect-1.0.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file mcp_mysql_connect-1.0.0.tar.gz.

File metadata

  • Download URL: mcp_mysql_connect-1.0.0.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for mcp_mysql_connect-1.0.0.tar.gz
Algorithm Hash digest
SHA256 d437aa47eeb67c6ddb1dded22a6234c2a2b2c2f0b26d55e6df117b5de402d614
MD5 1efac96c93814bc2b2bb2e9fe5e2c053
BLAKE2b-256 f7b426e8bb79b57118100e6430540902458d0922988bda5103ed9df735764706

See more details on using hashes here.

File details

Details for the file mcp_mysql_connect-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mcp_mysql_connect-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ab57f8bf69fa8b5848ee9ab9977478819f51fcbff2421c45a666e5c2d8f149d4
MD5 6eee0e2ae56c0907ee27805f6401667f
BLAKE2b-256 7fe7ee0b82ee59075e36528b159bd64bcafd2efd45d49a90d1872f7a2bdbeede

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