MySQL MCP Server

695
  • Linux
  • Apple

Integrations

  • Connects to a MySQL database, allowing LLMs to execute SQL queries, retrieve database information (databases, tables, and table structures), with configurable query timeout and result size limits.

MySQL MCP Server

MySQL Model Context Protocol(MCP) 서버는 로컬 환경의 MySQL 데이터베이스에 연결하여 대규모 언어 모델(LLM)이 SQL 쿼리를 실행할 수 있도록 하는 도구입니다.

요구사항

  • Node.js : 20.0.0 이상
  • MySQL : 5.7 이상의 MySQL 또는 MariaDB 서버

기능

  • MySQL 쿼리 실행 : LLM에서 SQL 쿼리를 직접 실행
  • 데이터베이스 정보 검색 : 데이터베이스 목록, 테이블 목록, 테이블 구조 확인
  • MCP 준수 : Model Context Protocol을 지원하고 LLM과 통합 가능
  • stdio 통신 : 표준 입출력을 사용하여 LLM과 통신, 포트 바인딩 없음
  • 연결 정보 저장 : 데이터베이스 연결 정보를 로컬로 저장하고 재사용

설치 및 사용 방법

NPX에서 임시 실행

npx -y https://github.com/yuki777/mysql-mcp-server --host 127.0.0.1 --port 13306 --user root

옵션

옵션설명기본값
-h, --host <host>MySQL 호스트localhost
-p, --port <port>MySQL 포트13306
-u, --user <user>MySQL 사용자루트
--password <password>MySQL 암호(빈 문자)
-d, --database <database>기본 데이터베이스(선택 사항)
-c, --config <path>설정 파일 경로(선택 사항)
--auto-connect서버 시작 시 자동으로 데이터베이스에 연결false
--server-port <port>MCP 서버 포트(stdio 모드에서는 사용되지 않음)3000
--server-host <host>MCP 서버 호스트(stdio 모드에서는 사용되지 않음)localhost
--query-timeout <ms>쿼리 시간 초과(밀리초)30000
--max-results <count>최대 결과 행 수1000
--debug디버그 모드false

연결 정보 저장 및 재사용

MySQL MCP Server는 성공적으로 연결된 데이터베이스의 정보를 로컬로 저장합니다. 이렇게하면 다음에 .mysql-mcp-connections.json 때 연결 정보를 자동으로 다시 사용할 수 있습니다.

연결 정보에는 다음이 포함됩니다.

  • 호스트 이름
  • 포트 번호
  • 사용자 이름
  • 비밀번호
  • 데이터베이스 이름(설정된 경우)

구성 파일 사용

구성 파일(JSON 형식)을 사용하여 연결 정보를 설정할 수도 있습니다.

{ "server": { "port": 3000, "host": "localhost" }, "mysql": { "host": "localhost", "port": 13306, "user": "root", "password": "yourpassword", "database": "mydb" }, "debug": false, "queryTimeout": 30000, "maxResultSize": 1000 }

구성 파일을 사용하는 경우 :

npx -y https://github.com/yuki777/mysql-mcp-server -c ./mysql-mcp-config.json

통신 방식

MySQL MCP Server는 MCP(Model Context Protocol)에 준거한 「stdio」모드로 동작합니다.

  1. 포트 충돌 방지 : 특정 포트를 사용하지 않기 때문에 포트 충돌 문제가 발생하지 않습니다.
  2. 향상된 보안: 네트워크 통신을 사용하지 않으므로 네트워크 수준 공격 위험을 줄입니다.
  3. 간단한 프로세스 간 통신 : LLM과의 통신 단순화

주의점

  • stdio 모드에서는 JSON 형식의 메시지를 교환합니다.
  • 한 줄에 하나의 JSON 메시지를 보내야합니다.
  • 오류 정보와 연결 로그는 표준 오류(stderr)로 출력됩니다.

제공되는 MCP 도구

데이터베이스 연결 관리

도구 이름설명필수 매개변수
connect_database데이터베이스에 연결host, port, user
disconnect_database현재 데이터베이스 연결을 끊습니다.없음
get_connection_status데이터베이스 연결 상태를 가져옵니다.없음

SQL 쿼리 작업

도구 이름설명필수 매개변수
execute_queryMySQL 쿼리를 실행합니다.query: SQL문
get_databases사용 가능한 데이터베이스 목록을 가져옵니다.없음
get_tables지정된 데이터베이스의 테이블 목록을 가져옵니다.database (선택 사항)
describe_table지정된 테이블의 구조를 가져옵니다.테이블

연결 관리 기능

MySQL MCP Server를 사용하면 서버 시작과 데이터베이스 연결을 분리할 수 있습니다.

  1. 연결 정보 없이 부팅 : 서버는 데이터베이스 연결 정보 없이 부팅 가능
  2. 여러 데이터베이스에 연결 : 서버를 시작한 후 다른 데이터베이스로 연결을 전환할 수 있습니다.
  3. 간단한 설치 : npx -y https://github.com/yuki777/mysql-mcp-server 에서만 실행 가능

연결 관리 사용 방법

  1. 자동 연결 없이 서버 시작 :
    npx -y https://github.com/yuki777/mysql-mcp-server
  2. 연결 도구를 사용하여 데이터베이스에 연결 :
    { "type": "tool_call", "request_id": "req_1", "tool": "connect_database", "arguments": { "host": "localhost", "port": 3306, "user": "root", "password": "your_password", "database": "your_db" } }
  3. 연결 상태 확인 :
    { "type": "tool_call", "request_id": "req_2", "tool": "get_connection_status", "arguments": {} }
  4. 연결 끊기 :
    { "type": "tool_call", "request_id": "req_3", "tool": "disconnect_database", "arguments": {} }

테스트 스크립트

리포지토리에는 test-connection-management.js 라는 테스트 스크립트가 포함되어 있습니다.이 스크립트를 사용하여 연결 관리 기능을 테스트 할 수 있습니다.

node test-connection-management.js

개발자 정보

개발 환경 설정

# リポジトリのクローン git clone [repository-url] cd mysql-mcp-server # 依存関係のインストール npm install # 開発モードでの実行 npm run dev

빌드

npm run build

라이센스

ISC

기여

버그 리포트, 기능 요청, 풀 요청을 환영합니다.

-
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 tool that connects to local MySQL databases and enables large language models (LLMs) to execute SQL queries through the Model Context Protocol (MCP).

  1. 要件
    1. 機能
      1. インストールと使用方法
        1. NPXでの一時実行
        2. オプション
        3. 接続情報の保存と再利用
        4. 設定ファイルの使用
      2. 通信方式
        1. 注意点
      3. 提供されるMCPツール
        1. データベース接続管理
        2. SQLクエリ操作
      4. 接続管理機能
        1. 接続管理の使用方法
        2. テスト用スクリプト
      5. 開発者向け情報
        1. 開発環境のセットアップ
        2. ビルド
      6. ライセンス
        1. 貢献

          Related MCP Servers

          • -
            security
            A
            license
            -
            quality
            A Model Context Protocol server that provides read-only access to MySQL databases, enabling LLMs to inspect database schemas and execute read-only queries.
            Last updated -
            1,219
            133
            TypeScript
            MIT License
            • Linux
            • Apple
          • -
            security
            A
            license
            -
            quality
            A Model Context Protocol server providing read-only access to MySQL databases, enabling LLMs to inspect database schemas and execute read-only queries.
            Last updated -
            1,219
            TypeScript
            MIT License
            • Linux
            • Apple
          • -
            security
            A
            license
            -
            quality
            A Model Context Protocol server that provides read-only access to MySQL databases, enabling LLMs to inspect database schemas and execute read-only queries.
            Last updated -
            1,219
            MIT License
          • -
            security
            A
            license
            -
            quality
            A Model Context Protocol (MCP) server that enables AI assistants to interact with MySQL databases by executing SQL queries and checking database connectivity.
            Last updated -
            TypeScript
            MIT License
            • Apple
            • Linux

          View all related MCP servers

          ID: 6mng75cdh9