Skip to main content
Glama
aqara-docs

MySQL MCP Server

by aqara-docs
README.md

# Smithery AI에 등록하는 방법을 알기 위해서 다음 사이트의 코드를 한글로만 바꿔서 올렸습니다.
#https://github.com/designcomputer/mysql_mcp_server

# MySQL MCP 서버
MySQL 데이터베이스와의 안전한 상호작용을 가능하게 하는 Model Context Protocol (MCP) 구현체입니다. 이 서버 컴포넌트는 AI 애플리케이션(호스트/클라이언트)과 MySQL 데이터베이스 간의 통신을 용이하게 하여, 제어된 인터페이스를 통해 데이터베이스 탐색 및 분석을 더 안전하고 구조화된 방식으로 수행할 수 있게 합니다.

> **참고**: MySQL MCP 서버는 독립 실행형 서버로 사용하도록 설계되지 않았으며, AI 애플리케이션과 MySQL 데이터베이스 간의 통신 프로토콜 구현체로 사용됩니다.

## 주요 기능
- 사용 가능한 MySQL 테이블을 리소스로 나열
- 테이블 내용 읽기
- 적절한 오류 처리가 포함된 SQL 쿼리 실행
- 환경 변수를 통한 안전한 데이터베이스 접근
- 포괄적인 로깅

## 설치
### 수동 설치
```bash
pip install mysql-mcp-server
```

### Smithery를 통한 설치
[Smithery](https://smithery.ai/server/mysql-mcp-server)를 통해 Claude Desktop용 MySQL MCP 서버를 자동으로 설치하려면:
```bash
npx -y @smithery/cli install mysql-mcp-server --client claude
```

## 설정
다음 환경 변수를 설정하세요:
```bash
MYSQL_HOST=localhost     # 데이터베이스 호스트
MYSQL_PORT=3306         # 선택사항: 데이터베이스 포트 (지정하지 않으면 기본값 3306)
MYSQL_USER=your_username
MYSQL_PASSWORD=your_password
MYSQL_DATABASE=your_database
```

## 사용법
### Claude Desktop과 함께 사용
`claude_desktop_config.json`에 다음을 추가하세요:
```json
{
  "mcpServers": {
    "mysql": {
      "command": "uv",
      "args": [
        "--directory", 
        "path/to/mysql_mcp_server",
        "run",
        "mysql_mcp_server"
      ],
      "env": {
        "MYSQL_HOST": "localhost",
        "MYSQL_PORT": "3306",
        "MYSQL_USER": "your_username",
        "MYSQL_PASSWORD": "your_password",
        "MYSQL_DATABASE": "your_database"
      }
    }
  }
}
```

### Visual Studio Code와 함께 사용
`mcp.json`에 다음을 추가하세요:
```json
{
  "servers": {
      "mysql": {
            "type": "stdio",
            "command": "uvx",
            "args": [
                "--from",
                "mysql-mcp-server",
                "mysql_mcp_server"
            ],
      "env": {
        "MYSQL_HOST": "localhost",
        "MYSQL_PORT": "3306",
        "MYSQL_USER": "your_username",
        "MYSQL_PASSWORD": "your_password",
        "MYSQL_DATABASE": "your_database"
      }
  }
}
```
참고: 이 기능을 사용하려면 uv를 설치해야 합니다.

### MCP Inspector로 디버깅
MySQL MCP 서버는 독립 실행형으로 또는 Python을 통해 직접 명령줄에서 실행하도록 설계되지 않았지만, MCP Inspector를 사용하여 디버깅할 수 있습니다.

MCP Inspector는 MCP 구현을 테스트하고 디버깅하는 편리한 방법을 제공합니다:

```bash
# 의존성 설치
pip install -r requirements.txt
# 디버깅을 위해 MCP Inspector 사용 (Python으로 직접 실행하지 마세요)
```

MySQL MCP 서버는 Claude Desktop과 같은 AI 애플리케이션과 통합되도록 설계되었으며, 독립 실행형 Python 프로그램으로 직접 실행해서는 안 됩니다.

## 개발
```bash
# 저장소 클론
git clone https://github.com/yourusername/mysql_mcp_server.git
cd mysql_mcp_server
# 가상 환경 생성
python -m venv venv
source venv/bin/activate  # Windows에서는 `venv\Scripts\activate`
# 개발 의존성 설치
pip install -r requirements-dev.txt
# 테스트 실행
pytest
```

## 보안 고려사항
- 환경 변수나 자격 증명을 절대 커밋하지 마세요
- 최소한의 필요한 권한만 가진 데이터베이스 사용자를 사용하세요
- 프로덕션 사용을 위해 쿼리 화이트리스팅 구현을 고려하세요
- 모든 데이터베이스 작업을 모니터링하고 로깅하세요

## 보안 모범 사례
이 MCP 구현은 기능을 위해 데이터베이스 접근이 필요합니다. 보안을 위해:
1. **최소 권한을 가진 전용 MySQL 사용자 생성**
2. **루트 자격 증명이나 관리자 계정을 절대 사용하지 않기**
3. **필요한 작업에만 데이터베이스 접근 제한**
4. **감사 목적으로 로깅 활성화**
5. **데이터베이스 접근에 대한 정기적인 보안 검토**

자세한 지침은 [MySQL 보안 설정 가이드](https://github.com/designcomputer/mysql_mcp_server/blob/main/SECURITY.md)를 참조하세요:
- 제한된 MySQL 사용자 생성
- 적절한 권한 설정
- 데이터베이스 접근 모니터링
- 보안 모범 사례

⚠️ 중요: 데이터베이스 접근을 구성할 때 항상 최소 권한 원칙을 따르세요.

## 라이선스
MIT 라이선스 - 자세한 내용은 LICENSE 파일을 참조하세요.

## 기여하기
1. 저장소를 포크하세요
2. 기능 브랜치를 생성하세요 (`git checkout -b feature/amazing-feature`)
3. 변경사항을 커밋하세요 (`git commit -m 'Add some amazing feature'`)
4. 브랜치에 푸시하세요 (`git push origin feature/amazing-feature`)
5. Pull Request를 열어주세요

TDQS

B3/5.0

Scored across 1 tool

Disambiguation5/5

Only one tool exists, so there is no ambiguity. An agent can easily identify the sole purpose of executing SQL queries.

Naming Consistency5/5

With a single tool, naming consistency is not a concern. The snake_case name 'execute_sql' is clear and follows a common convention.

Tool Count2/5

A MySQL server typically requires multiple tools for schema management, transaction control, and querying; a single tool feels insufficient for the scope.

Completeness1/5

The server is severely incomplete, lacking essential operations like listing tables, describing schemas, managing transactions, or handling multiple queries.