@berthojoris/mcp-mysql-server 1.7.0 → 1.9.0
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/DOCUMENTATIONS.md +797 -33
- package/README.md +400 -138
- package/dist/config/featureConfig.js +16 -0
- package/dist/index.d.ts +180 -0
- package/dist/index.js +133 -0
- package/dist/mcp-server.js +421 -0
- package/dist/tools/migrationTools.d.ts +96 -0
- package/dist/tools/migrationTools.js +546 -0
- package/dist/tools/schemaVersioningTools.d.ts +147 -0
- package/dist/tools/schemaVersioningTools.js +1007 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# MySQL MCP Server
|
|
2
2
|
|
|
3
|
-
A fully-featured **Model Context Protocol (MCP)** server for MySQL database integration with AI agents like Claude
|
|
3
|
+
A fully-featured **Model Context Protocol (MCP)** server for MySQL database integration with AI agents like Claude Code, Cursor, Windsurf, Zed, Cline, Kilo Code, Roo Code, Gemini CLI, and other MCP-compatible tools.
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@berthojoris/mcp-mysql-server)
|
|
6
6
|
[](https://opensource.org/licenses/MIT)
|
|
@@ -9,9 +9,9 @@ A fully-featured **Model Context Protocol (MCP)** server for MySQL database inte
|
|
|
9
9
|
|
|
10
10
|
## 🌟 Features
|
|
11
11
|
|
|
12
|
-
- ✅ **Full MCP Protocol Support** - Works with Claude
|
|
12
|
+
- ✅ **Full MCP Protocol Support** - Works with Claude Code, Cursor, Windsurf, Zed, Cline, Kilo Code, Roo Code, Gemini CLI, and any MCP-compatible AI agent
|
|
13
13
|
- 🔐 **Secure by Default** - Parameterized queries, SQL injection protection, permission-based access control
|
|
14
|
-
- 🛠️ **
|
|
14
|
+
- 🛠️ **100 Powerful Tools** - Complete database operations (CRUD, DDL, queries, schema inspection, transactions, stored procedures, bulk operations, backup/restore, import/export, data migration)
|
|
15
15
|
- 🎛️ **Dynamic Per-Project Permissions** - Each AI agent can have different access levels
|
|
16
16
|
- 🗃️ **DDL Support** - Create, alter, and drop tables (when explicitly enabled)
|
|
17
17
|
- 💎 **Transaction Support** - Full ACID transaction management (BEGIN, COMMIT, ROLLBACK)
|
|
@@ -21,6 +21,120 @@ A fully-featured **Model Context Protocol (MCP)** server for MySQL database inte
|
|
|
21
21
|
|
|
22
22
|
---
|
|
23
23
|
|
|
24
|
+
## 🔄 MySQL MCP vs Manual Database Access: A Comprehensive Comparison
|
|
25
|
+
|
|
26
|
+
This MySQL MCP is a **powerful intermediary layer** between AI assistants and MySQL databases. Here's how it compares to manual database access:
|
|
27
|
+
|
|
28
|
+
### Data Access & Querying
|
|
29
|
+
|
|
30
|
+
| Feature | MySQL MCP | Manual Database Access |
|
|
31
|
+
|---------|-----------|------------------------|
|
|
32
|
+
| **Query Execution** | AI can run SELECT/INSERT/UPDATE/DELETE via natural language | Requires manual SQL writing in terminal/client |
|
|
33
|
+
| **Parameterized Queries** | Automatic protection against SQL injection | Must manually parameterize |
|
|
34
|
+
| **Bulk Operations** | Up to 10,000 records per batch with auto-batching | Manual scripting required |
|
|
35
|
+
| **Query Caching** | Built-in LRU cache with TTL | Must implement yourself |
|
|
36
|
+
|
|
37
|
+
### Data Analysis
|
|
38
|
+
|
|
39
|
+
| Feature | MySQL MCP | Manual Database Access |
|
|
40
|
+
|---------|-----------|------------------------|
|
|
41
|
+
| **Query Analysis** | Auto-detects complexity, joins, bottlenecks | Run EXPLAIN manually, interpret yourself |
|
|
42
|
+
| **Optimization Hints** | Auto-generates MySQL 8.0+ optimizer hints | Must know hint syntax |
|
|
43
|
+
| **Execution Plans** | Get EXPLAIN in JSON/TREE/TRADITIONAL formats | Run EXPLAIN manually |
|
|
44
|
+
| **Server Diagnostics** | 9 tools for status, processes, replication | Multiple manual commands |
|
|
45
|
+
|
|
46
|
+
### Data Validation
|
|
47
|
+
|
|
48
|
+
| Feature | MySQL MCP | Manual Database Access |
|
|
49
|
+
|---------|-----------|------------------------|
|
|
50
|
+
| **Input Validation** | Automatic type/length/format validation | Manual validation code |
|
|
51
|
+
| **SQL Injection Prevention** | Multi-layer protection (identifiers, keywords, params) | Depends on your code |
|
|
52
|
+
| **Permission Enforcement** | 10 granular permission categories | Configure in MySQL grants |
|
|
53
|
+
| **Dangerous Query Blocking** | Blocks GRANT, DROP USER, system schema access | No automatic protection |
|
|
54
|
+
|
|
55
|
+
### Schema Inspection
|
|
56
|
+
|
|
57
|
+
| Feature | MySQL MCP | Manual Database Access |
|
|
58
|
+
|---------|-----------|------------------------|
|
|
59
|
+
| **Table Structure** | One command shows columns, keys, indexes | Multiple SHOW/DESCRIBE commands |
|
|
60
|
+
| **Foreign Key Discovery** | Auto-discovers relationships | Manual INFORMATION_SCHEMA queries |
|
|
61
|
+
| **Full Schema Export** | Get entire DB schema (tables, views, procs, triggers) | Multiple manual exports |
|
|
62
|
+
| **Object Comparison** | Compare table structures automatically | Manual diff work |
|
|
63
|
+
|
|
64
|
+
### Debugging & Diagnostics
|
|
65
|
+
|
|
66
|
+
| Feature | MySQL MCP | Manual Database Access |
|
|
67
|
+
|---------|-----------|------------------------|
|
|
68
|
+
| **Query Logging** | Automatic logging with timing, params, status | Enable general_log manually |
|
|
69
|
+
| **Formatted Output** | SQL formatted with highlighted keywords | Raw output |
|
|
70
|
+
| **Process Management** | View/kill processes via simple commands | SHOW PROCESSLIST + KILL manually |
|
|
71
|
+
| **Cache Monitoring** | Hit rate, memory usage, statistics | No built-in tracking |
|
|
72
|
+
|
|
73
|
+
### Advanced Operations
|
|
74
|
+
|
|
75
|
+
| Feature | MySQL MCP | Manual Database Access |
|
|
76
|
+
|---------|-----------|------------------------|
|
|
77
|
+
| **Transactions** | Begin/Commit/Rollback via commands | Manual SQL |
|
|
78
|
+
| **Stored Procedures** | Create, execute, manage with parameter handling | Write DDL manually |
|
|
79
|
+
| **Data Migration** | Copy, move, clone, sync tables with one command | Complex scripts required |
|
|
80
|
+
| **Backup/Restore** | Full DB or table backup/restore | mysqldump + manual restore |
|
|
81
|
+
| **Import/Export** | CSV, JSON, SQL formats supported | Manual scripting |
|
|
82
|
+
|
|
83
|
+
### Key Benefits of Using This MCP
|
|
84
|
+
|
|
85
|
+
1. **Natural Language Interface** - Ask Claude "show me all users with orders > $100" instead of writing SQL
|
|
86
|
+
|
|
87
|
+
2. **Built-in Security** - 5+ validation layers protect against:
|
|
88
|
+
- SQL injection
|
|
89
|
+
- Privilege escalation
|
|
90
|
+
- Cross-database access
|
|
91
|
+
- Dangerous operations
|
|
92
|
+
|
|
93
|
+
3. **Audit Trail** - Every query automatically logged with timing and parameters
|
|
94
|
+
|
|
95
|
+
4. **100 Tools in 16 Categories** - Covers virtually every database task
|
|
96
|
+
|
|
97
|
+
5. **Permission Granularity** - Give AI read-only access in production, full access in dev
|
|
98
|
+
|
|
99
|
+
6. **Error Handling** - Detailed, human-readable error messages
|
|
100
|
+
|
|
101
|
+
### Example Workflows
|
|
102
|
+
|
|
103
|
+
**Without MCP (Manual):**
|
|
104
|
+
```sql
|
|
105
|
+
-- Connect to MySQL client
|
|
106
|
+
mysql -u user -p database
|
|
107
|
+
-- Write schema query
|
|
108
|
+
DESCRIBE users;
|
|
109
|
+
SHOW INDEX FROM users;
|
|
110
|
+
-- Write analysis query
|
|
111
|
+
EXPLAIN SELECT * FROM users WHERE email LIKE '%@gmail.com';
|
|
112
|
+
-- Check if safe, then run
|
|
113
|
+
SELECT * FROM users WHERE email LIKE '%@gmail.com';
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
**With MCP (AI-Assisted):**
|
|
117
|
+
> "Show me the users table structure and find all Gmail users"
|
|
118
|
+
- AI calls `read_table_schema`, `explain_query`, `read_records`
|
|
119
|
+
- Returns formatted results with execution time
|
|
120
|
+
- All queries logged, validated, parameterized automatically
|
|
121
|
+
|
|
122
|
+
### When to Use This MCP
|
|
123
|
+
|
|
124
|
+
| Use Case | Recommendation |
|
|
125
|
+
|----------|----------------|
|
|
126
|
+
| Quick data lookups | MCP - faster, safer |
|
|
127
|
+
| Complex analysis | MCP - AI can iterate and refine |
|
|
128
|
+
| Schema exploration | MCP - comprehensive tools |
|
|
129
|
+
| Production debugging | MCP with read-only permissions |
|
|
130
|
+
| Bulk data operations | MCP - auto-batching |
|
|
131
|
+
| Data migrations | MCP - 5 migration tools |
|
|
132
|
+
| Learning SQL | Both - MCP shows what it executes |
|
|
133
|
+
|
|
134
|
+
This MCP transforms database work from "write SQL, hope it's safe, interpret results" to "describe what you need, get validated results with full audit trail."
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
24
138
|
## 📦 Installation
|
|
25
139
|
|
|
26
140
|
### Option 1: Quick Start (npx)
|
|
@@ -65,13 +179,253 @@ npm run build
|
|
|
65
179
|
|
|
66
180
|
### 3. Configure AI Agent
|
|
67
181
|
|
|
68
|
-
|
|
182
|
+
This MCP server works with multiple AI coding assistants. Below are configuration examples for each platform.
|
|
183
|
+
|
|
184
|
+
#### Claude Code (CLI)
|
|
185
|
+
|
|
186
|
+
Claude Code uses a `.mcp.json` file in your project root or home directory.
|
|
187
|
+
|
|
188
|
+
**Project-level config (`.mcp.json` in project root):**
|
|
189
|
+
|
|
190
|
+
```json
|
|
191
|
+
{
|
|
192
|
+
"mcpServers": {
|
|
193
|
+
"mysql": {
|
|
194
|
+
"command": "npx",
|
|
195
|
+
"args": [
|
|
196
|
+
"-y",
|
|
197
|
+
"@berthojoris/mcp-mysql-server",
|
|
198
|
+
"mysql://user:password@localhost:3306/database",
|
|
199
|
+
"list,read,utility"
|
|
200
|
+
]
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
**Global config (`~/.mcp.json`):**
|
|
207
|
+
|
|
208
|
+
```json
|
|
209
|
+
{
|
|
210
|
+
"mcpServers": {
|
|
211
|
+
"mysql": {
|
|
212
|
+
"command": "npx",
|
|
213
|
+
"args": [
|
|
214
|
+
"-y",
|
|
215
|
+
"@berthojoris/mcp-mysql-server",
|
|
216
|
+
"mysql://user:password@localhost:3306/database",
|
|
217
|
+
"list,read,create,update,delete,ddl"
|
|
218
|
+
]
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
#### Cursor
|
|
225
|
+
|
|
226
|
+
Cursor uses `.cursor/mcp.json` in your project root.
|
|
227
|
+
|
|
228
|
+
**Configuration (`.cursor/mcp.json`):**
|
|
229
|
+
|
|
230
|
+
```json
|
|
231
|
+
{
|
|
232
|
+
"mcpServers": {
|
|
233
|
+
"mysql": {
|
|
234
|
+
"command": "npx",
|
|
235
|
+
"args": [
|
|
236
|
+
"-y",
|
|
237
|
+
"@berthojoris/mcp-mysql-server",
|
|
238
|
+
"mysql://user:password@localhost:3306/database",
|
|
239
|
+
"list,read,utility"
|
|
240
|
+
]
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
#### Windsurf
|
|
247
|
+
|
|
248
|
+
Windsurf uses `~/.codeium/windsurf/mcp_config.json`.
|
|
249
|
+
|
|
250
|
+
**Configuration:**
|
|
251
|
+
|
|
252
|
+
```json
|
|
253
|
+
{
|
|
254
|
+
"mcpServers": {
|
|
255
|
+
"mysql": {
|
|
256
|
+
"command": "npx",
|
|
257
|
+
"args": [
|
|
258
|
+
"-y",
|
|
259
|
+
"@berthojoris/mcp-mysql-server",
|
|
260
|
+
"mysql://user:password@localhost:3306/database",
|
|
261
|
+
"list,read,utility"
|
|
262
|
+
]
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
#### Cline (VS Code Extension)
|
|
269
|
+
|
|
270
|
+
Add to Cline MCP settings in VS Code settings or cline config file.
|
|
271
|
+
|
|
272
|
+
**Configuration:**
|
|
273
|
+
|
|
274
|
+
```json
|
|
275
|
+
{
|
|
276
|
+
"mcpServers": {
|
|
277
|
+
"mysql": {
|
|
278
|
+
"command": "npx",
|
|
279
|
+
"args": [
|
|
280
|
+
"-y",
|
|
281
|
+
"@berthojoris/mcp-mysql-server",
|
|
282
|
+
"mysql://user:password@localhost:3306/database",
|
|
283
|
+
"list,read,utility"
|
|
284
|
+
]
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
#### Gemini CLI
|
|
291
|
+
|
|
292
|
+
Gemini CLI uses `~/.gemini/settings.json`.
|
|
293
|
+
|
|
294
|
+
**Configuration:**
|
|
295
|
+
|
|
296
|
+
```json
|
|
297
|
+
{
|
|
298
|
+
"mcpServers": {
|
|
299
|
+
"mysql": {
|
|
300
|
+
"command": "npx",
|
|
301
|
+
"args": [
|
|
302
|
+
"-y",
|
|
303
|
+
"@berthojoris/mcp-mysql-server",
|
|
304
|
+
"mysql://user:password@localhost:3306/database",
|
|
305
|
+
"list,read,utility"
|
|
306
|
+
]
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
#### Trae AI
|
|
313
|
+
|
|
314
|
+
Trae AI uses MCP configuration in its settings.
|
|
315
|
+
|
|
316
|
+
**Configuration:**
|
|
317
|
+
|
|
318
|
+
```json
|
|
319
|
+
{
|
|
320
|
+
"mcpServers": {
|
|
321
|
+
"mysql": {
|
|
322
|
+
"command": "npx",
|
|
323
|
+
"args": [
|
|
324
|
+
"-y",
|
|
325
|
+
"@berthojoris/mcp-mysql-server",
|
|
326
|
+
"mysql://user:password@localhost:3306/database",
|
|
327
|
+
"list,read,utility"
|
|
328
|
+
]
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
#### Qwen Code
|
|
335
|
+
|
|
336
|
+
Qwen Code supports MCP servers with standard configuration.
|
|
337
|
+
|
|
338
|
+
**Configuration:**
|
|
339
|
+
|
|
340
|
+
```json
|
|
341
|
+
{
|
|
342
|
+
"mcpServers": {
|
|
343
|
+
"mysql": {
|
|
344
|
+
"command": "npx",
|
|
345
|
+
"args": [
|
|
346
|
+
"-y",
|
|
347
|
+
"@berthojoris/mcp-mysql-server",
|
|
348
|
+
"mysql://user:password@localhost:3306/database",
|
|
349
|
+
"list,read,utility"
|
|
350
|
+
]
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
#### Droid CLI
|
|
357
|
+
|
|
358
|
+
Droid CLI uses MCP configuration in its settings file.
|
|
359
|
+
|
|
360
|
+
**Configuration:**
|
|
361
|
+
|
|
362
|
+
```json
|
|
363
|
+
{
|
|
364
|
+
"mcpServers": {
|
|
365
|
+
"mysql": {
|
|
366
|
+
"command": "npx",
|
|
367
|
+
"args": [
|
|
368
|
+
"-y",
|
|
369
|
+
"@berthojoris/mcp-mysql-server",
|
|
370
|
+
"mysql://user:password@localhost:3306/database",
|
|
371
|
+
"list,read,utility"
|
|
372
|
+
]
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
#### Zed IDE
|
|
379
|
+
|
|
380
|
+
Zed IDE uses `~/.config/zed/settings.json` for MCP configuration.
|
|
381
|
+
|
|
382
|
+
**Configuration:**
|
|
383
|
+
|
|
384
|
+
```json
|
|
385
|
+
{
|
|
386
|
+
"context_servers": {
|
|
387
|
+
"mysql": {
|
|
388
|
+
"command": {
|
|
389
|
+
"path": "npx",
|
|
390
|
+
"args": [
|
|
391
|
+
"-y",
|
|
392
|
+
"@berthojoris/mcp-mysql-server",
|
|
393
|
+
"mysql://user:password@localhost:3306/database",
|
|
394
|
+
"list,read,utility"
|
|
395
|
+
]
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
#### Kilo Code (VS Code Extension)
|
|
403
|
+
|
|
404
|
+
Kilo Code is a VS Code extension that supports MCP servers.
|
|
405
|
+
|
|
406
|
+
**Configuration:**
|
|
407
|
+
|
|
408
|
+
```json
|
|
409
|
+
{
|
|
410
|
+
"mcpServers": {
|
|
411
|
+
"mysql": {
|
|
412
|
+
"command": "npx",
|
|
413
|
+
"args": [
|
|
414
|
+
"-y",
|
|
415
|
+
"@berthojoris/mcp-mysql-server",
|
|
416
|
+
"mysql://user:password@localhost:3306/database",
|
|
417
|
+
"list,read,utility"
|
|
418
|
+
]
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
#### Roo Code (VS Code Extension)
|
|
69
425
|
|
|
70
|
-
|
|
71
|
-
- Windows: `%APPDATA%\Claude\claude_desktop_config.json`
|
|
72
|
-
- macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
426
|
+
Roo Code is a VS Code extension with MCP support.
|
|
73
427
|
|
|
74
|
-
**Configuration
|
|
428
|
+
**Configuration:**
|
|
75
429
|
|
|
76
430
|
```json
|
|
77
431
|
{
|
|
@@ -89,7 +443,9 @@ npm run build
|
|
|
89
443
|
}
|
|
90
444
|
```
|
|
91
445
|
|
|
92
|
-
|
|
446
|
+
#### Local Path Configuration (for development)
|
|
447
|
+
|
|
448
|
+
If you've cloned the repository locally:
|
|
93
449
|
|
|
94
450
|
```json
|
|
95
451
|
{
|
|
@@ -97,7 +453,7 @@ npm run build
|
|
|
97
453
|
"mysql": {
|
|
98
454
|
"command": "node",
|
|
99
455
|
"args": [
|
|
100
|
-
"
|
|
456
|
+
"/path/to/mcp_mysql/bin/mcp-mysql.js",
|
|
101
457
|
"mysql://user:password@localhost:3306/database",
|
|
102
458
|
"list,read,utility"
|
|
103
459
|
]
|
|
@@ -106,7 +462,9 @@ npm run build
|
|
|
106
462
|
}
|
|
107
463
|
```
|
|
108
464
|
|
|
109
|
-
|
|
465
|
+
#### Environment Variables Configuration
|
|
466
|
+
|
|
467
|
+
Alternative approach using environment variables:
|
|
110
468
|
|
|
111
469
|
```json
|
|
112
470
|
{
|
|
@@ -114,13 +472,13 @@ npm run build
|
|
|
114
472
|
"mysql": {
|
|
115
473
|
"command": "node",
|
|
116
474
|
"args": [
|
|
117
|
-
"
|
|
475
|
+
"/path/to/mcp_mysql/dist/mcp-server.js"
|
|
118
476
|
],
|
|
119
477
|
"env": {
|
|
120
478
|
"DB_HOST": "localhost",
|
|
121
479
|
"DB_PORT": "3306",
|
|
122
480
|
"DB_USER": "root",
|
|
123
|
-
"DB_PASSWORD": "",
|
|
481
|
+
"DB_PASSWORD": "your_password",
|
|
124
482
|
"DB_NAME": "your_database",
|
|
125
483
|
"MCP_PERMISSIONS": "list,read,utility"
|
|
126
484
|
}
|
|
@@ -129,14 +487,6 @@ npm run build
|
|
|
129
487
|
}
|
|
130
488
|
```
|
|
131
489
|
|
|
132
|
-
#### Cline (VS Code Extension)
|
|
133
|
-
|
|
134
|
-
Add to Cline MCP settings (same JSON format as Claude Desktop).
|
|
135
|
-
|
|
136
|
-
#### Windsurf
|
|
137
|
-
|
|
138
|
-
Add to Windsurf MCP settings (same JSON format as Claude Desktop).
|
|
139
|
-
|
|
140
490
|
### 4. Restart AI Agent
|
|
141
491
|
|
|
142
492
|
Completely restart your AI agent application to load the MCP server.
|
|
@@ -227,7 +577,7 @@ Use the local path approach when you:
|
|
|
227
577
|
|
|
228
578
|
---
|
|
229
579
|
|
|
230
|
-
##
|
|
580
|
+
## 🔐 Permission System
|
|
231
581
|
|
|
232
582
|
### Permission Categories
|
|
233
583
|
|
|
@@ -347,123 +697,9 @@ You can have different databases with different permissions in the same AI agent
|
|
|
347
697
|
|
|
348
698
|
---
|
|
349
699
|
|
|
350
|
-
## 🚫 Permission Error Handling
|
|
351
|
-
|
|
352
|
-
The MySQL MCP Server provides clear, user-friendly error messages when operations are attempted without proper permissions. This helps users understand exactly what permissions are needed and how to enable them.
|
|
353
|
-
|
|
354
|
-
### Error Message Format
|
|
355
|
-
|
|
356
|
-
When a tool is called without the required permission, you'll receive a detailed error message like:
|
|
357
|
-
|
|
358
|
-
```
|
|
359
|
-
❌ Permission denied: Cannot use tool 'create_table'. This tool requires 'ddl' permission.
|
|
360
|
-
|
|
361
|
-
Current permissions: list,read,utility
|
|
362
|
-
To enable this tool, add 'ddl' to your permissions configuration.
|
|
363
|
-
|
|
364
|
-
Example configuration:
|
|
365
|
-
"args": ["mysql://user:pass@host:3306/db", "list,read,utility,ddl"]
|
|
366
|
-
|
|
367
|
-
Tool description: Create new tables with columns and indexes
|
|
368
|
-
```
|
|
369
|
-
|
|
370
|
-
### Common Permission Error Examples
|
|
371
|
-
|
|
372
|
-
#### Creating Tables Without DDL Permission
|
|
373
|
-
|
|
374
|
-
**User prompt:** *"Create a new table called 'products'"*
|
|
375
|
-
|
|
376
|
-
**Error response when DDL not enabled:**
|
|
377
|
-
```
|
|
378
|
-
❌ Permission denied: Cannot use tool 'create_table'. This tool requires 'ddl' permission.
|
|
379
|
-
|
|
380
|
-
Current permissions: list,read,utility
|
|
381
|
-
To enable this tool, add 'ddl' to your permissions configuration.
|
|
382
|
-
|
|
383
|
-
Example configuration:
|
|
384
|
-
"args": ["mysql://user:pass@host:3306/db", "list,read,utility,ddl"]
|
|
385
|
-
|
|
386
|
-
Tool description: Create new tables with columns and indexes
|
|
387
|
-
```
|
|
388
|
-
|
|
389
|
-
#### Inserting Data Without Create Permission
|
|
390
|
-
|
|
391
|
-
**User prompt:** *"Add a new user to the users table"*
|
|
392
|
-
|
|
393
|
-
**Error response when CREATE not enabled:**
|
|
394
|
-
```
|
|
395
|
-
❌ Permission denied: Cannot use tool 'create_record'. This tool requires 'create' permission.
|
|
396
|
-
|
|
397
|
-
Current permissions: list,read,utility
|
|
398
|
-
To enable this tool, add 'create' to your permissions configuration.
|
|
399
|
-
|
|
400
|
-
Example configuration:
|
|
401
|
-
"args": ["mysql://user:pass@host:3306/db", "list,read,utility,create"]
|
|
402
|
-
|
|
403
|
-
Tool description: Insert new records with automatic SQL generation
|
|
404
|
-
```
|
|
405
|
-
|
|
406
|
-
#### Updating Data Without Update Permission
|
|
407
|
-
|
|
408
|
-
**User prompt:** *"Update the email for user ID 123"*
|
|
409
|
-
|
|
410
|
-
**Error response when UPDATE not enabled:**
|
|
411
|
-
```
|
|
412
|
-
❌ Permission denied: Cannot use tool 'update_record'. This tool requires 'update' permission.
|
|
413
|
-
|
|
414
|
-
Current permissions: list,read,utility
|
|
415
|
-
To enable this tool, add 'update' to your permissions configuration.
|
|
416
|
-
|
|
417
|
-
Example configuration:
|
|
418
|
-
"args": ["mysql://user:pass@host:3306/db", "list,read,utility,update"]
|
|
419
|
-
|
|
420
|
-
Tool description: Update existing records based on conditions
|
|
421
|
-
```
|
|
422
|
-
|
|
423
|
-
### Permission Error Benefits
|
|
424
|
-
|
|
425
|
-
1. **🎯 Clear Guidance** - Exact permission needed and how to add it
|
|
426
|
-
2. **📋 Current State** - Shows what permissions are currently active
|
|
427
|
-
3. **💡 Example Configuration** - Ready-to-use configuration example
|
|
428
|
-
4. **📖 Tool Context** - Explains what the tool does
|
|
429
|
-
5. **🔐 Security** - Prevents unauthorized operations while being helpful
|
|
430
|
-
|
|
431
|
-
### Troubleshooting Permission Errors
|
|
432
|
-
|
|
433
|
-
If you encounter permission errors:
|
|
434
|
-
|
|
435
|
-
1. **Check your configuration** - Verify the permissions string in your MCP configuration
|
|
436
|
-
2. **Add required permission** - Add the missing permission to your configuration
|
|
437
|
-
3. **Restart your AI agent** - Changes require a restart to take effect
|
|
438
|
-
4. **Test with a simple operation** - Verify the permission is working
|
|
439
|
-
|
|
440
|
-
**Example fix for DDL operations:**
|
|
441
|
-
|
|
442
|
-
Before (DDL disabled):
|
|
443
|
-
```json
|
|
444
|
-
{
|
|
445
|
-
"args": [
|
|
446
|
-
"mysql://user:pass@localhost:3306/db",
|
|
447
|
-
"list,read,utility"
|
|
448
|
-
]
|
|
449
|
-
}
|
|
450
|
-
```
|
|
451
|
-
|
|
452
|
-
After (DDL enabled):
|
|
453
|
-
```json
|
|
454
|
-
{
|
|
455
|
-
"args": [
|
|
456
|
-
"mysql://user:pass@localhost:3306/db",
|
|
457
|
-
"list,read,utility,ddl"
|
|
458
|
-
]
|
|
459
|
-
}
|
|
460
|
-
```
|
|
461
|
-
|
|
462
|
-
---
|
|
463
|
-
|
|
464
700
|
## 🛠️ Available Tools
|
|
465
701
|
|
|
466
|
-
The MCP server provides **
|
|
702
|
+
The MCP server provides **100 powerful tools**:
|
|
467
703
|
|
|
468
704
|
### Database Discovery (4 tools)
|
|
469
705
|
|
|
@@ -645,7 +881,7 @@ The MCP server provides **95 powerful tools**:
|
|
|
645
881
|
| `get_create_table_statement` | Get CREATE TABLE statement for a table | `list` permission |
|
|
646
882
|
| `get_database_schema` | Get complete database schema (tables, views, procedures, functions, triggers) | `list` permission |
|
|
647
883
|
|
|
648
|
-
### Data Import/Export (5 tools)
|
|
884
|
+
### Data Import/Export (5 tools)
|
|
649
885
|
|
|
650
886
|
| Tool | Description | Requires |
|
|
651
887
|
|------|-------------|----------|
|
|
@@ -655,6 +891,30 @@ The MCP server provides **95 powerful tools**:
|
|
|
655
891
|
| `import_from_csv` | Import data from CSV string into a table | `create` permission |
|
|
656
892
|
| `import_from_json` | Import data from JSON array into a table | `create` permission |
|
|
657
893
|
|
|
894
|
+
### Data Migration (5 tools)
|
|
895
|
+
|
|
896
|
+
| Tool | Description | Requires |
|
|
897
|
+
|------|-------------|----------|
|
|
898
|
+
| `copy_table_data` | Copy data from one table to another with optional column mapping | `create` permission |
|
|
899
|
+
| `move_table_data` | Move data (copy + delete from source) | `create`, `delete` permission |
|
|
900
|
+
| `clone_table` | Clone table structure with optional data | `ddl` permission |
|
|
901
|
+
| `compare_table_structure` | Compare structure of two tables and identify differences | `list` permission |
|
|
902
|
+
| `sync_table_data` | Synchronize data between tables (insert_only, update_only, upsert) | `update` permission |
|
|
903
|
+
|
|
904
|
+
### Schema Versioning & Migrations (9 tools) - NEW!
|
|
905
|
+
|
|
906
|
+
| Tool | Description | Requires |
|
|
907
|
+
|------|-------------|----------|
|
|
908
|
+
| `init_migrations_table` | Initialize the migrations tracking table | `ddl` permission |
|
|
909
|
+
| `create_migration` | Create a new migration with up/down SQL | `ddl` permission |
|
|
910
|
+
| `apply_migrations` | Apply pending migrations (with dry-run support) | `ddl` permission |
|
|
911
|
+
| `rollback_migration` | Rollback applied migrations by steps or version | `ddl` permission |
|
|
912
|
+
| `get_migration_status` | Get migration history and status | `list` permission |
|
|
913
|
+
| `get_schema_version` | Get current schema version | `list` permission |
|
|
914
|
+
| `validate_migrations` | Validate migrations for issues | `list` permission |
|
|
915
|
+
| `reset_failed_migration` | Reset failed migration to pending | `ddl` permission |
|
|
916
|
+
| `generate_migration_from_diff` | Generate migration from table comparison | `ddl` permission |
|
|
917
|
+
|
|
658
918
|
---
|
|
659
919
|
|
|
660
920
|
## 📚 Detailed Documentation
|
|
@@ -665,6 +925,8 @@ For comprehensive documentation on all features, please see **[DOCUMENTATIONS.md
|
|
|
665
925
|
- 📤 **Data Export Tools** - Export data to CSV, JSON, and SQL formats
|
|
666
926
|
- 📥 **Data Import Tools** - Import data from CSV and JSON sources
|
|
667
927
|
- 💾 **Database Backup & Restore** - Full backup/restore with SQL dumps
|
|
928
|
+
- 🔄 **Data Migration Tools** - Copy, move, clone, compare, and sync table data
|
|
929
|
+
- 🔄 **Schema Versioning & Migrations** - Version control for database schema changes
|
|
668
930
|
- 💎 **Transaction Management** - ACID transactions with BEGIN, COMMIT, ROLLBACK
|
|
669
931
|
- 🔧 **Stored Procedures** - Create and execute stored procedures with IN/OUT/INOUT parameters
|
|
670
932
|
- 📋 **Usage Examples** - Real-world examples for all tools
|
|
@@ -141,6 +141,22 @@ exports.toolCategoryMap = {
|
|
|
141
141
|
exportTableToSql: ToolCategory.UTILITY,
|
|
142
142
|
importFromCSV: ToolCategory.CREATE,
|
|
143
143
|
importFromJSON: ToolCategory.CREATE,
|
|
144
|
+
// Data migration tools
|
|
145
|
+
copyTableData: ToolCategory.CREATE,
|
|
146
|
+
moveTableData: ToolCategory.DELETE,
|
|
147
|
+
cloneTable: ToolCategory.DDL,
|
|
148
|
+
compareTableStructure: ToolCategory.LIST,
|
|
149
|
+
syncTableData: ToolCategory.UPDATE,
|
|
150
|
+
// Schema versioning and migrations tools
|
|
151
|
+
initMigrationsTable: ToolCategory.DDL,
|
|
152
|
+
createMigration: ToolCategory.DDL,
|
|
153
|
+
applyMigrations: ToolCategory.DDL,
|
|
154
|
+
rollbackMigration: ToolCategory.DDL,
|
|
155
|
+
getMigrationStatus: ToolCategory.LIST,
|
|
156
|
+
getSchemaVersion: ToolCategory.LIST,
|
|
157
|
+
validateMigrations: ToolCategory.LIST,
|
|
158
|
+
resetFailedMigration: ToolCategory.DDL,
|
|
159
|
+
generateMigrationFromDiff: ToolCategory.DDL,
|
|
144
160
|
};
|
|
145
161
|
/**
|
|
146
162
|
* Class to manage feature configuration based on runtime or environment variables
|