Python MySQL MCP
pymcp
pymcp是一个基于 FastMCP 的 Python 项目,提供与 MySQL 数据库交互的工具。该项目支持服务器和客户端之间的通信,并允许通过各种工具检索和分析数据。
项目结构
pymcp/
├── client.py # 클라이언트 코드
├── main.py # 서버 실행 코드
├── src/
│ ├── env.py # 로컬 환경 설정
│ ├── env_dev.py # 개발 환경 설정
│ ├── mcp_instance.py # MCP 인스턴스 초기화
│ ├── mysql_tool.py # MySQL 관련 도구 정의
├── pyproject.toml # 프로젝트 메타데이터 및 의존성
├── requirements.txt # 의존성 목록
└── README.md # 프로젝트 설명Related MCP server: Jewei MSSQL MCP Server
安装并运行
1.安装依赖项
需要 Python 3.13 或更高版本。要安装依赖项,请运行以下命令:
pip install -r requirements.txt2. 运行服务器
要运行服务器,请运行main.py :
python main.py服务器默认在0.0.0.0:8080上运行。
3.运行客户端
要运行客户端,请运行client.py :
python client.py客户端可以与服务器通信以执行 MySQL 查询或查询工具列表。
偏好设置
根据环境的不同,MySQL 设置的应用也有所不同:
本地环境:
src/env.py开发环境:
src/env_dev.py
可以通过APP_ENV环境变量设置环境。默认为local 。
export APP_ENV=dev # 개발 환경 설정提供的工具
服务器提供的工具有:
describe_tools
列出可用的工具并解释如何使用它们。query_mysql(sql: str)
执行给定的 SQL 查询并返回结果。
例如:query_mysql("SELECT * FROM users LIMIT 10;")
主要文件描述
main.py
这是运行服务器的入口点。初始化 MCP 实例,注册工具,然后运行服务器。
client.py
这是与服务器交互的客户端代码。您可以连接到服务器并调用该工具。
src/mysql_tool.py
这是定义MySQL相关工具的文件。您可以通过query_mysql等工具执行 SQL 查询。
src/env.py和src/env_dev.py
包含 MySQL 连接设置的环境变量文件。根据环境加载适当的设置。
This server cannot be deployed
Maintenance
Related MCP Connectors
MCP server for querying and analyzing data from ad platforms, analytics tools, and spreadsheets
Token-free MCP server for structured RevoGrid Core, Pro, and Enterprise knowledge retrieval.
MCP server for the Seline Analytics API
MCP server for querying BrainKB, a knowledge base for neuroscience knowledge graphs.
Related MCP Servers
- AlicenseAqualityDmaintenanceAn MCP server that provides read-only access to MySQL databases.4317 npm72MIT
- AlicenseNot gradedqualityCmaintenanceA FastMCP-based server that enables executing Microsoft SQL Server data queries and table structure queries through a standardized MCP protocol interface.7MIT
- FlicenseNot gradedqualityNot gradedmaintenanceAn MCP server that enables interaction with MySQL databases through the Model Context Protocol, allowing execution of SQL queries and database table listing operations from Cline AI.-
- AlicenseNot gradedqualityDmaintenanceA production-ready MCP server for MySQL database operations, providing secure HTTP endpoints for read-only queries, performance analysis, and server monitoring.158 npm18MIT