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.

A FastMCP-based server that enables interaction with MySQL databases, supporting client-server communication for querying and analyzing MySQL data.

  1. プロジェクト構造
    1. インストールと実行
      1. 依存インストール
      2. サーバーの実行
      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 -
          48
          3
          JavaScript
          MIT License
        • -
          security
          F
          license
          -
          quality
          Facilitates interaction with a local MySQL database via a RESTful API, supporting database queries and real-time updates with integration for Cursor MCP services.
          Last updated -
          2
          JavaScript
        • A
          security
          A
          license
          A
          quality
          An MCP server that provides read-only access to MySQL databases.
          Last updated -
          4
          419
          17
          JavaScript
          MIT License
          • Linux
          • Apple
        • -
          security
          A
          license
          -
          quality
          A server that provides MySQL database operations through SSE (Server-Sent Events) based on the MCP (Model-Controller-Provider) framework, enabling real-time data transmission from MySQL databases.
          Last updated -
          53
          Python
          MIT License
          • Linux
          • Apple

        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