@cano721/mysql-mcp-server 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +127 -82
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -1,71 +1,70 @@
|
|
|
1
1
|
[](https://www.npmjs.com/package/@cano721/mysql-mcp-server)
|
|
2
2
|
|
|
3
|
+
# MySQL 데이터베이스 접근 MCP 서버 (@cano721/mysql-mcp-server)
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
이 MCP 서버는 MySQL 데이터베이스에 읽기 전용 접근을 제공합니다. 다음과 같은 기능을 제공합니다:
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
- 사용 가능한 데이터베이스 목록 조회
|
|
8
|
+
- 데이터베이스의 테이블 목록 조회
|
|
9
|
+
- 테이블 스키마 설명
|
|
10
|
+
- 읽기 전용 SQL 쿼리 실행
|
|
7
11
|
|
|
8
|
-
|
|
9
|
-
- List tables in a database
|
|
10
|
-
- Describe table schemas
|
|
11
|
-
- Execute read-only SQL queries
|
|
12
|
+
## 보안 기능
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
- **읽기 전용 접근**: SELECT, SHOW, DESCRIBE, EXPLAIN 문만 허용
|
|
15
|
+
- **쿼리 검증**: SQL 인젝션 방지 및 데이터 수정 시도 차단
|
|
16
|
+
- **쿼리 타임아웃**: 장시간 실행되는 쿼리로부터 리소스 보호
|
|
17
|
+
- **행 제한**: 과도한 데이터 반환 방지 (최대 1000행)
|
|
14
18
|
|
|
15
|
-
|
|
16
|
-
- **Query validation**: Prevents SQL injection and blocks any data modification attempts
|
|
17
|
-
- **Query timeout**: Prevents long-running queries from consuming resources
|
|
18
|
-
- **Row limit**: Prevents excessive data return
|
|
19
|
+
## 설치
|
|
19
20
|
|
|
20
|
-
|
|
21
|
+
### 1. 다음 방법 중 하나로 설치:
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
#### Install from NPM
|
|
23
|
+
#### NPM에서 설치
|
|
25
24
|
|
|
26
25
|
```bash
|
|
27
|
-
#
|
|
26
|
+
# 전역 설치
|
|
28
27
|
npm install -g @cano721/mysql-mcp-server
|
|
29
28
|
|
|
30
|
-
#
|
|
29
|
+
# 또는 프로젝트에 로컬 설치
|
|
31
30
|
npm install @cano721/mysql-mcp-server
|
|
32
31
|
```
|
|
33
32
|
|
|
34
|
-
####
|
|
33
|
+
#### 소스에서 빌드
|
|
35
34
|
|
|
36
35
|
```bash
|
|
37
|
-
#
|
|
36
|
+
# 저장소 복제
|
|
38
37
|
git clone https://github.com/cano721/mysql-mcp-server.git
|
|
39
38
|
cd mysql-mcp-server
|
|
40
39
|
|
|
41
|
-
#
|
|
40
|
+
# 의존성 설치 및 빌드
|
|
42
41
|
npm install
|
|
43
42
|
npm run build
|
|
44
43
|
```
|
|
45
44
|
|
|
46
|
-
####
|
|
45
|
+
#### Smithery를 통한 설치
|
|
47
46
|
|
|
48
|
-
|
|
47
|
+
Claude AI용 MySQL 데이터베이스 접근 MCP 서버를 Smithery를 통해 자동으로 설치:
|
|
49
48
|
|
|
50
49
|
```bash
|
|
51
50
|
npx -y @smithery/cli install @cano721/mysql-mcp-server --client claude
|
|
52
51
|
```
|
|
53
52
|
|
|
54
|
-
### 2.
|
|
53
|
+
### 2. 환경 변수 설정
|
|
55
54
|
|
|
56
|
-
|
|
55
|
+
서버는 다음 환경 변수가 필요합니다:
|
|
57
56
|
|
|
58
|
-
- `MYSQL_HOST`:
|
|
59
|
-
- `MYSQL_PORT`:
|
|
60
|
-
- `MYSQL_USER`:
|
|
61
|
-
- `MYSQL_PASSWORD`:
|
|
62
|
-
- `MYSQL_DATABASE`:
|
|
57
|
+
- `MYSQL_HOST`: 데이터베이스 서버 호스트명
|
|
58
|
+
- `MYSQL_PORT`: 데이터베이스 서버 포트 (기본값: 3306)
|
|
59
|
+
- `MYSQL_USER`: 데이터베이스 사용자명
|
|
60
|
+
- `MYSQL_PASSWORD`: 데이터베이스 비밀번호 (선택사항, 보안 연결에 권장)
|
|
61
|
+
- `MYSQL_DATABASE`: 기본 데이터베이스명 (선택사항)
|
|
63
62
|
|
|
64
|
-
### 3.
|
|
63
|
+
### 3. MCP 설정에 추가
|
|
65
64
|
|
|
66
|
-
|
|
65
|
+
MCP 설정 파일에 다음 구성을 추가하세요:
|
|
67
66
|
|
|
68
|
-
|
|
67
|
+
npm으로 설치한 경우 (옵션 1):
|
|
69
68
|
```json
|
|
70
69
|
{
|
|
71
70
|
"mcpServers": {
|
|
@@ -86,7 +85,7 @@ If you installed via npm (Option 1):
|
|
|
86
85
|
}
|
|
87
86
|
```
|
|
88
87
|
|
|
89
|
-
|
|
88
|
+
소스에서 빌드한 경우 (옵션 2):
|
|
90
89
|
```json
|
|
91
90
|
{
|
|
92
91
|
"mcpServers": {
|
|
@@ -107,15 +106,15 @@ If you built from source (Option 2):
|
|
|
107
106
|
}
|
|
108
107
|
```
|
|
109
108
|
|
|
110
|
-
##
|
|
109
|
+
## 사용 가능한 도구
|
|
111
110
|
|
|
112
111
|
### list_databases
|
|
113
112
|
|
|
114
|
-
|
|
113
|
+
MySQL 서버에서 접근 가능한 모든 데이터베이스를 나열합니다.
|
|
115
114
|
|
|
116
|
-
|
|
115
|
+
**매개변수**: 없음
|
|
117
116
|
|
|
118
|
-
|
|
117
|
+
**예제**:
|
|
119
118
|
```json
|
|
120
119
|
{
|
|
121
120
|
"server_name": "mysql",
|
|
@@ -126,12 +125,12 @@ Lists all accessible databases on the MySQL server.
|
|
|
126
125
|
|
|
127
126
|
### list_tables
|
|
128
127
|
|
|
129
|
-
|
|
128
|
+
지정된 데이터베이스의 모든 테이블을 나열합니다.
|
|
130
129
|
|
|
131
|
-
|
|
132
|
-
- `database` (
|
|
130
|
+
**매개변수**:
|
|
131
|
+
- `database` (선택사항): 데이터베이스명 (지정하지 않으면 기본값 사용)
|
|
133
132
|
|
|
134
|
-
|
|
133
|
+
**예제**:
|
|
135
134
|
```json
|
|
136
135
|
{
|
|
137
136
|
"server_name": "mysql",
|
|
@@ -144,13 +143,13 @@ Lists all tables in a specified database.
|
|
|
144
143
|
|
|
145
144
|
### describe_table
|
|
146
145
|
|
|
147
|
-
|
|
146
|
+
특정 테이블의 스키마를 보여줍니다.
|
|
148
147
|
|
|
149
|
-
|
|
150
|
-
- `database` (
|
|
151
|
-
- `table` (
|
|
148
|
+
**매개변수**:
|
|
149
|
+
- `database` (선택사항): 데이터베이스명 (지정하지 않으면 기본값 사용)
|
|
150
|
+
- `table` (필수): 테이블명
|
|
152
151
|
|
|
153
|
-
|
|
152
|
+
**예제**:
|
|
154
153
|
```json
|
|
155
154
|
{
|
|
156
155
|
"server_name": "mysql",
|
|
@@ -164,13 +163,13 @@ Shows the schema for a specific table.
|
|
|
164
163
|
|
|
165
164
|
### execute_query
|
|
166
165
|
|
|
167
|
-
|
|
166
|
+
읽기 전용 SQL 쿼리를 실행합니다.
|
|
168
167
|
|
|
169
|
-
|
|
170
|
-
- `query` (
|
|
171
|
-
- `database` (
|
|
168
|
+
**매개변수**:
|
|
169
|
+
- `query` (필수): SQL 쿼리 (SELECT, SHOW, DESCRIBE, EXPLAIN 문만 허용)
|
|
170
|
+
- `database` (선택사항): 데이터베이스명 (지정하지 않으면 기본값 사용)
|
|
172
171
|
|
|
173
|
-
|
|
172
|
+
**예제**:
|
|
174
173
|
```json
|
|
175
174
|
{
|
|
176
175
|
"server_name": "mysql",
|
|
@@ -182,9 +181,9 @@ Executes a read-only SQL query.
|
|
|
182
181
|
}
|
|
183
182
|
```
|
|
184
183
|
|
|
185
|
-
##
|
|
184
|
+
## 고급 연결 풀 설정
|
|
186
185
|
|
|
187
|
-
|
|
186
|
+
MySQL 연결 풀 동작을 더 세밀하게 제어하려면 추가 매개변수를 설정할 수 있습니다:
|
|
188
187
|
|
|
189
188
|
```json
|
|
190
189
|
{
|
|
@@ -212,74 +211,120 @@ For more control over the MySQL connection pool behavior, you can configure addi
|
|
|
212
211
|
}
|
|
213
212
|
```
|
|
214
213
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
- `MYSQL_CONNECTION_LIMIT`: Control the maximum number of connections in the pool (default: 10)
|
|
218
|
-
- `MYSQL_QUEUE_LIMIT`: Set the maximum number of connection requests to queue (default: 0, unlimited)
|
|
219
|
-
- `MYSQL_CONNECT_TIMEOUT`: Adjust the connection timeout in milliseconds (default: 10000)
|
|
220
|
-
- `MYSQL_IDLE_TIMEOUT`: Configure how long a connection can be idle before being released (in milliseconds)
|
|
221
|
-
- `MYSQL_MAX_IDLE`: Set the maximum number of idle connections to keep in the pool
|
|
214
|
+
이러한 고급 옵션을 통해 다음을 제어할 수 있습니다:
|
|
222
215
|
|
|
216
|
+
- `MYSQL_CONNECTION_LIMIT`: 풀의 최대 연결 수 제어 (기본값: 10)
|
|
217
|
+
- `MYSQL_QUEUE_LIMIT`: 대기열에 넣을 최대 연결 요청 수 설정 (기본값: 0, 무제한)
|
|
218
|
+
- `MYSQL_CONNECT_TIMEOUT`: 연결 타임아웃을 밀리초 단위로 조정 (기본값: 10000)
|
|
219
|
+
- `MYSQL_IDLE_TIMEOUT`: 연결이 해제되기 전까지 유휴 상태로 있을 수 있는 시간 (밀리초 단위)
|
|
220
|
+
- `MYSQL_MAX_IDLE`: 풀에 유지할 최대 유휴 연결 수 설정
|
|
223
221
|
|
|
224
|
-
##
|
|
222
|
+
## 테스트
|
|
225
223
|
|
|
226
|
-
|
|
224
|
+
서버에는 MySQL 설정으로 기능을 확인하는 테스트 스크립트가 포함되어 있습니다:
|
|
227
225
|
|
|
228
|
-
### 1.
|
|
226
|
+
### 1. 테스트 데이터베이스 설정
|
|
229
227
|
|
|
230
|
-
|
|
228
|
+
이 스크립트는 테스트 데이터베이스, 테이블 및 샘플 데이터를 생성합니다:
|
|
231
229
|
|
|
232
230
|
```bash
|
|
233
|
-
#
|
|
231
|
+
# MySQL 자격 증명을 환경 변수로 설정
|
|
234
232
|
export MYSQL_HOST=localhost
|
|
235
233
|
export MYSQL_PORT=3306
|
|
236
234
|
export MYSQL_USER=your_username
|
|
237
235
|
export MYSQL_PASSWORD=your_password
|
|
238
236
|
|
|
239
|
-
#
|
|
237
|
+
# 설정 스크립트 실행
|
|
240
238
|
npm run test:setup
|
|
241
239
|
```
|
|
242
240
|
|
|
243
|
-
### 2.
|
|
241
|
+
### 2. MCP 도구 테스트
|
|
244
242
|
|
|
245
|
-
|
|
243
|
+
이 스크립트는 테스트 데이터베이스에 대해 각 MCP 도구를 테스트합니다:
|
|
246
244
|
|
|
247
245
|
```bash
|
|
248
|
-
#
|
|
246
|
+
# MySQL 자격 증명을 환경 변수로 설정
|
|
249
247
|
export MYSQL_HOST=localhost
|
|
250
248
|
export MYSQL_PORT=3306
|
|
251
249
|
export MYSQL_USER=your_username
|
|
252
250
|
export MYSQL_PASSWORD=your_password
|
|
253
251
|
export MYSQL_DATABASE=mcp_test_db
|
|
254
252
|
|
|
255
|
-
#
|
|
253
|
+
# 도구 테스트 스크립트 실행
|
|
256
254
|
npm run test:tools
|
|
257
255
|
```
|
|
258
256
|
|
|
259
|
-
### 3.
|
|
257
|
+
### 3. 모든 테스트 실행
|
|
260
258
|
|
|
261
|
-
|
|
259
|
+
설정 및 도구 테스트를 모두 실행하려면:
|
|
262
260
|
|
|
263
261
|
```bash
|
|
264
|
-
#
|
|
262
|
+
# MySQL 자격 증명을 환경 변수로 설정
|
|
265
263
|
export MYSQL_HOST=localhost
|
|
266
264
|
export MYSQL_PORT=3306
|
|
267
265
|
export MYSQL_USER=your_username
|
|
268
266
|
export MYSQL_PASSWORD=your_password
|
|
269
267
|
|
|
270
|
-
#
|
|
268
|
+
# 모든 테스트 실행
|
|
271
269
|
npm test
|
|
272
270
|
```
|
|
273
271
|
|
|
274
|
-
##
|
|
272
|
+
## 실제 사용 예제
|
|
273
|
+
|
|
274
|
+
### Kiro IDE에서 사용하기
|
|
275
|
+
|
|
276
|
+
Kiro IDE에서 이 MCP 서버를 사용하는 예제:
|
|
277
|
+
|
|
278
|
+
```json
|
|
279
|
+
{
|
|
280
|
+
"mcpServers": {
|
|
281
|
+
"mysql": {
|
|
282
|
+
"command": "npx",
|
|
283
|
+
"args": ["@cano721/mysql-mcp-server"],
|
|
284
|
+
"env": {
|
|
285
|
+
"MYSQL_HOST": "localhost",
|
|
286
|
+
"MYSQL_PORT": "4307",
|
|
287
|
+
"MYSQL_USER": "developer"
|
|
288
|
+
},
|
|
289
|
+
"disabled": false,
|
|
290
|
+
"autoApprove": []
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
### 테스트 결과
|
|
297
|
+
|
|
298
|
+
이 MCP 서버는 다음과 같은 실제 환경에서 테스트되었습니다:
|
|
299
|
+
|
|
300
|
+
- ✅ **데이터베이스 목록 조회**: 38개의 데이터베이스 성공적으로 조회
|
|
301
|
+
- ✅ **테이블 목록 조회**: MySQL 시스템 데이터베이스의 40개 테이블 조회
|
|
302
|
+
- ✅ **테이블 스키마 조회**: user 테이블의 46개 컬럼 정보 조회
|
|
303
|
+
- ✅ **SQL 쿼리 실행**: 사용자 정보 조회 쿼리 성공적으로 실행
|
|
304
|
+
|
|
305
|
+
## 문제 해결
|
|
306
|
+
|
|
307
|
+
문제가 발생하면:
|
|
308
|
+
|
|
309
|
+
1. 서버 로그에서 오류 메시지 확인
|
|
310
|
+
2. MySQL 자격 증명 및 연결 세부 정보 확인
|
|
311
|
+
3. MySQL 사용자에게 적절한 권한이 있는지 확인
|
|
312
|
+
4. 쿼리가 읽기 전용이고 올바르게 형식화되었는지 확인
|
|
313
|
+
|
|
314
|
+
### 일반적인 오류
|
|
315
|
+
|
|
316
|
+
- **연결 오류**: `MYSQL_HOST`, `MYSQL_PORT`, `MYSQL_USER` 환경 변수 확인
|
|
317
|
+
- **권한 오류**: MySQL 사용자에게 데이터베이스 접근 권한이 있는지 확인
|
|
318
|
+
- **쿼리 오류**: SELECT, SHOW, DESCRIBE, EXPLAIN 문만 사용 가능
|
|
319
|
+
|
|
320
|
+
## 라이선스
|
|
321
|
+
|
|
322
|
+
이 프로젝트는 MIT 라이선스에 따라 라이선스가 부여됩니다 - 자세한 내용은 [LICENSE](LICENSE) 파일을 참조하세요.
|
|
275
323
|
|
|
276
|
-
|
|
324
|
+
## 기여
|
|
277
325
|
|
|
278
|
-
|
|
279
|
-
2. Verify your MySQL credentials and connection details
|
|
280
|
-
3. Ensure your MySQL user has appropriate permissions
|
|
281
|
-
4. Check that your query is read-only and properly formatted
|
|
326
|
+
기여를 환영합니다! 이슈를 제출하거나 풀 리퀘스트를 보내주세요.
|
|
282
327
|
|
|
283
|
-
##
|
|
328
|
+
## 지원
|
|
284
329
|
|
|
285
|
-
|
|
330
|
+
문제가 있거나 질문이 있으시면 [GitHub Issues](https://github.com/cano721/mysql-mcp-server/issues)에서 이슈를 생성해주세요.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cano721/mysql-mcp-server",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "An MCP server that provides read-only access to MySQL databases.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -32,6 +32,9 @@
|
|
|
32
32
|
},
|
|
33
33
|
"author": "cano721",
|
|
34
34
|
"license": "MIT",
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
},
|
|
35
38
|
"dependencies": {
|
|
36
39
|
"@modelcontextprotocol/sdk": "0.6.0",
|
|
37
40
|
"mysql2": "^3.12.0"
|