Skip to main content
Glama
daedalus

mcp-mysql-connector

by daedalus

mcp-mysql-connector

MySQL 데이터베이스 기능을 LLM 에이전트용 도구로 제공하는 MCP 서버입니다.

mcp-name: io.github.daedalus/mcp-mysql-connector

PyPI Python Coverage Ruff

개요

mcp-mysql-connector는 MySQL 데이터베이스 작업을 LLM 에이전트용 도구로 제공하는 Model Context Protocol (MCP) 서버입니다. 표준화된 프로토콜을 통해 AI 어시스턴트가 MySQL 데이터베이스와 상호작용할 수 있게 하며, 다음과 같은 기능을 지원합니다:

  • 데이터베이스 및 테이블 관리

  • 쿼리 실행

  • 사용자 인증 및 권한 관리

  • 스키마 조회

  • 트랜잭션 제어

Related MCP server: MCP Server MySQL

설치

pip install mcp-mysql-connector

빠른 시작

서버 실행

# Run with stdio transport (default)
mcp-mysql-connector

# Or run programmatically
python -c "from mcp_mysql import mcp; mcp.run()"

설정

connect 도구를 사용하여 MySQL에 연결합니다:

{
  "host": "localhost",
  "port": 3306,
  "user": "root",
  "password": "your_password",
  "database": "your_database"
}

MCP 도구

연결 관리

도구

설명

connect

MySQL 데이터베이스에 연결

disconnect

MySQL 연결 해제

is_connected

연결 상태 확인

commit

현재 트랜잭션 커밋

rollback

현재 트랜잭션 롤백

쿼리 실행

도구

설명

execute_query

원시 SQL 쿼리를 실행하고 결과 반환

데이터베이스 작업

도구

설명

list_databases

서버의 모든 데이터베이스 나열

create_database

새 데이터베이스 생성

drop_database

데이터베이스 삭제

database_exists

데이터베이스 존재 여부 확인

테이블 작업

도구

설명

list_tables

데이터베이스의 테이블 나열

describe_table

테이블 스키마 조회

create_table

새 테이블 생성

drop_table

테이블 삭제

table_exists

테이블 존재 여부 확인

컬럼 및 인덱스 작업

도구

설명

show_columns

컬럼 세부 정보 표시

show_indexes

인덱스 세부 정보 표시

create_index

인덱스 생성

drop_index

인덱스 삭제

사용자 관리

도구

설명

create_user

MySQL 사용자 생성

drop_user

MySQL 사용자 삭제

grant_privileges

사용자에게 권한 부여

revoke_privileges

사용자 권한 회수

show_privileges

사용자 권한 표시

서버 정보

도구

설명

server_status

MySQL 서버 상태 확인

MCP 리소스

서버는 데이터베이스 및 테이블 메타데이터에 대한 동적 리소스를 제공합니다:

  • database://{name} - 테이블 목록을 포함한 데이터베이스 메타데이터

  • table://{db}/{table} - 스키마, 컬럼, 인덱스를 포함한 테이블 메타데이터

사용 예시

연결 및 쿼리

# First, connect to database
connect(host="localhost", user="root", password="secret", database="mydb")

# Execute a query
execute_query(sql="SELECT * FROM users WHERE active = true")

# List all tables
list_tables(database="mydb")

데이터베이스 및 테이블 생성

# Create a database
create_database(name="newapp")

# Create a table
create_table(name="users", schema="id INT PRIMARY KEY AUTO_INCREMENT, name VARCHAR(255), email VARCHAR(255) UNIQUE")

사용자 관리

# Create a new user with password
create_user(username="app_user", host="localhost", password="secure_password")

# Grant privileges
grant_privileges(privileges="SELECT,INSERT,UPDATE,DELETE", on="newapp.*", username="app_user", host="localhost")

트랜잭션 제어

# Start transaction
execute_query(sql="BEGIN")

# Execute operations
execute_query(sql="INSERT INTO accounts (balance) VALUES (100)")

# Commit or rollback
commit()  # or rollback()

환경 변수

서버는 환경 변수를 통한 설정을 지원합니다:

export MYSQL_HOST=localhost
export MYSQL_PORT=3306
export MYSQL_USER=root
export MYSQL_PASSWORD=secret
export MYSQL_DATABASE=mydb

개발

# Clone repository
git clone https://github.com/daedalus/mcp-mysql-connector.git
cd mcp-mysql-connector

# Create virtual environment
python -m venv venv
source venv/bin/activate

# Install dependencies
pip install -e ".[test]"

# Run tests
pytest

# Format code
ruff format src/ tests/

# Lint
ruff check src/ tests/

# Type check
mypy src/

아키텍처

mcp-mysql-connector/
├── src/mcp_mysql/
│   ├── core/models.py       # Data models (QueryResult, TableSchema, etc.)
│   ├── adapters/mysql.py    # MySQL connection & pooling
│   ├── services/connection.py  # Connection manager
│   ├── tools/mysql_tools.py   # MCP tool implementations
│   └── mcp.py              # FastMCP server setup
└── tests/                   # Test suite

요구 사항

  • Python 3.11+

  • fastmcp >= 2.0.0

  • pymysql >= 1.1.0

  • sqlparse >= 0.4.0

라이선스

MIT License - 자세한 내용은 LICENSE를 참조하세요.

Related MCP Connectors

Related MCP Servers

  • A
    license
    B
    quality
    D
    maintenance
    Enables AI models to perform MySQL database operations through a standardized interface, supporting secure connections, query execution, and comprehensive schema management.
    7
    218 npm
    33
    MIT
  • A
    license
    A
    quality
    C
    maintenance
    Enables LLMs to interact with MySQL databases through standardized protocol, supporting database management, table operations, data queries, and modifications with configurable permission controls.
    15
    39 npm
    1
    MIT
  • A
    license
    A
    quality
    D
    maintenance
    Enables AI agents to safely interact with MySQL/MariaDB databases, supporting read-only queries by default with optional write operations and access control.
    8
    MIT
  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables AI agents to interact with a MySQL database using natural language, automating SQL tasks like querying, inserting, updating, and deleting data.
    1
    -