Skip to main content
Glama

Python MySQL MCP

by hoonzinope

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 # 프로젝트 설명

安装并运行

1.安装依赖项

需要 Python 3.13 或更高版本。要安装依赖项,请运行以下命令:

pip install -r requirements.txt

2. 运行服务器

要运行服务器,请运行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 # 개발 환경 설정

提供的工具

服务器提供的工具有:

  1. describe_tools
    列出可用的工具并解释如何使用它们。

  2. 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.pysrc/env_dev.py

包含 MySQL 连接设置的环境变量文件。根据环境加载适当的设置。

-
security - not tested
F
license - not found
-
quality - not tested

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

基于FastMCP的服务器,可以与MySQL数据库交互,支持客户端-服务器通信,查询和分析MySQL数据。

  1. 项目结构
    1. 安装并运行
      1. 1.安装依赖项
      2. 2. 运行服务器
      3. 3.运行客户端
    2. 偏好设置
      1. 提供的工具
        1. 主要文件描述
          1. main.py
          2. client.py
          3. src/mysql_tool.py
          4. src/env.py和src/env_dev.py

        Related MCP Servers

        • -
          security
          A
          license
          -
          quality
          An MCP server that integrates with MySQL databases, enabling secure read and write operations through LLM-driven interfaces with support for transaction handling and performance monitoring.
          Last updated -
          87
          17
          MIT License
        • A
          security
          A
          license
          A
          quality
          An MCP server that provides read-only access to MySQL databases.
          Last updated -
          4
          288
          43
          MIT License
          • Linux
          • Apple
        • -
          security
          F
          license
          -
          quality
          An MCP server that allows working with MySQL databases by providing tools for executing read-only SQL queries, getting table schemas, and listing database tables.
          Last updated -
          311
          4
        • -
          security
          F
          license
          -
          quality
          A containerized server that allows interaction with MySQL databases through Model Context Protocol (MCP), enabling SQL query execution, schema retrieval, and table listing via natural language.

        View all related MCP servers

        MCP directory API

        We provide all the information about MCP servers via our MCP API.

        curl -X GET 'https://glama.ai/api/mcp/v1/servers/hoonzinope/pymcp-mysql'

        If you have feedback or need assistance with the MCP directory API, please join our Discord server