Add your description here
Project description
mcp-server-mysql: A MySQL MCP Server
The Model Context Protocol (MCP) is an open protocol that enables seamless integration between LLM applications and external data sources and tools. Whether you're building an AI-powered IDE, enhancing a chat interface, or creating custom AI workflows, MCP provides a standardized way to connect LLMs with the context they need.
This repository is an example of how to create an MCP server for managing MySQL databases.
Overview
A Model Context Protocol server for interacting with a MySQL database. It provides tools for executing queries, creating and describing tables, inserting and fetching data, as well as listing existing tables.
Components
Tools
The server implements the following tools:
Query Execution
execute_query: Execute an arbitrary SQL query.- Takes a SQL string (
query) - Returns query results for SELECT/SHOW/DESCRIBE, or a success message for other commands
- Takes a SQL string (
Table Management
-
list_tables: List all tables in the current database- Returns JSON array of table names
-
create_table: Create a new table- Takes
name(table name) andschema(column definitions) - Creates the specified table
- Takes
-
describe_table: Show the structure of a specific table- Takes
table(name of the table) - Returns information about columns and data types
- Takes
Data Manipulation
-
insert_data: Insert new row into a table- Takes
table(target table name) anddata(dict of column values) - Inserts data into the specified table
- Takes
-
fetch_data: Fetch data by executing a SELECT query- Takes a SQL string (
query) - Returns rows matching the query
- Takes a SQL string (
Configuration
The MCP server connects to a MySQL database using environment variables. You need to set the following environment variables before running the server:
MYSQL_HOST: MySQL server hostnameMYSQL_PORT: MySQL server portMYSQL_USER: MySQL usernameMYSQL_PASSWORD: MySQL passwordMYSQL_DATABASE: MySQL database name
These settings are loaded using Pydantic's BaseSettings, which will raise an error if the required environment variables are not set.
Quickstart
Claude Desktop
On MacOS: ~/Library/Application\ Support/Claude/claude_desktop_config.json
On Windows: %APPDATA%/Claude/claude_desktop_config.json
{
"mysql": {
"command": "uvx",
"args": [
"mcp-server-mysql"
]
}
}
Development
Building and Publishing
To prepare the package for distribution:
- Sync dependencies and update lockfile:
uv sync
- Build package distributions:
uv build
This will create source and wheel distributions in the dist/ directory.
- Publish to PyPI:
uv publish
Note: You'll need to set PyPI credentials via environment variables or command flags:
- Token:
--tokenorUV_PUBLISH_TOKEN - Or username/password:
--username/UV_PUBLISH_USERNAMEand--password/UV_PUBLISH_PASSWORD
Debugging
Since MCP servers run over stdio, debugging can be challenging. For the best debugging experience, we strongly recommend using the MCP Inspector.
You can launch the MCP Inspector via npm with this command:
npx @modelcontextprotocol/inspector uv --directory $(PWD) run mcp-server-mysql
Upon launching, the Inspector will display a URL that you can access in your browser to begin debugging.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcp_server_mysql-0.1.4.tar.gz.
File metadata
- Download URL: mcp_server_mysql-0.1.4.tar.gz
- Upload date:
- Size: 22.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.26
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f642d7c6657d7d07ef3633d23ce526fd6ca85b310004a56efafd14288c7be1a
|
|
| MD5 |
e6325c124fd5fb63ebbe3aa09fbc326e
|
|
| BLAKE2b-256 |
c1a30570b0f7f84f16d1ac8e53ddf2e5c728554bc53a524ebe982b8769194bc4
|
File details
Details for the file mcp_server_mysql-0.1.4-py3-none-any.whl.
File metadata
- Download URL: mcp_server_mysql-0.1.4-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.26
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
80ced0b5b3ee2dadfe9d9aa39aa03fe7e57b9b475b947fd4da1ae232ad6110b9
|
|
| MD5 |
99166d9d26c933ab3c32f8fe9c51dff8
|
|
| BLAKE2b-256 |
33176766c73e63f76eb2968124291aec3ddc1a93f5a34af83eb1c0f809715a1a
|