Allows interaction with MySQL databases, providing tools to execute SQL queries, retrieve data, and analyze results through a client-server architecture.
pymcp
pymcp is a Python project based on FastMCP that provides tools for interacting with MySQL databases. The project supports communication between servers and clients, and allows data to be retrieved and analyzed through various tools.
Project Structure
Related MCP server: MySQL Database Access
Install and run
1. Install dependencies
Requires Python 3.13 or later. To install dependencies, run the following command:
2. Run the server
To run the server, run main.py :
The server runs on 0.0.0.0:8080 by default.
3. Run the client
To run the client, run client.py :
Clients can communicate with the server to execute MySQL queries or query a list of tools.
Preferences
MySQL settings are applied differently depending on the environment:
Local environment :
src/env.pyDevelopment environment :
src/env_dev.py
The environment can be set via APP_ENV environment variable. The default is local .
Tools provided
The tools provided by the server are:
describe_tools
Lists available tools and explains how to use them.query_mysql(sql: str)
Executes a given SQL query and returns the results.
Example:query_mysql("SELECT * FROM users LIMIT 10;")
Main File Description
main.py
This is the entry point to running the server. It initializes the MCP instance, registers the tools, and then runs the server.
client.py
This is the client code that interacts with the server. It connects to the server and can call tools.
src/mysql_tool.py
This is a file that defines MySQL-related tools. You can execute SQL queries using tools such as query_mysql .
src/env.py and src/env_dev.py
Environment variable file containing MySQL connection settings. Loads appropriate settings depending on the environment.