@berthojoris/mcp-mysql-server 1.8.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 +481 -6
- package/README.md +387 -22
- package/dist/config/featureConfig.js +10 -0
- package/dist/index.d.ts +117 -0
- package/dist/index.js +95 -0
- package/dist/mcp-server.js +218 -0
- package/dist/tools/schemaVersioningTools.d.ts +147 -0
- package/dist/tools/schemaVersioningTools.js +1007 -0
- package/package.json +1 -1
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,7 +9,7 @@ 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
|
|
@@ -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,13 @@ 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)
|
|
69
185
|
|
|
70
|
-
|
|
71
|
-
- Windows: `%APPDATA%\Claude\claude_desktop_config.json`
|
|
72
|
-
- macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
186
|
+
Claude Code uses a `.mcp.json` file in your project root or home directory.
|
|
73
187
|
|
|
74
|
-
**
|
|
188
|
+
**Project-level config (`.mcp.json` in project root):**
|
|
75
189
|
|
|
76
190
|
```json
|
|
77
191
|
{
|
|
@@ -89,7 +203,249 @@ npm run build
|
|
|
89
203
|
}
|
|
90
204
|
```
|
|
91
205
|
|
|
92
|
-
**
|
|
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)
|
|
425
|
+
|
|
426
|
+
Roo Code is a VS Code extension with MCP support.
|
|
427
|
+
|
|
428
|
+
**Configuration:**
|
|
429
|
+
|
|
430
|
+
```json
|
|
431
|
+
{
|
|
432
|
+
"mcpServers": {
|
|
433
|
+
"mysql": {
|
|
434
|
+
"command": "npx",
|
|
435
|
+
"args": [
|
|
436
|
+
"-y",
|
|
437
|
+
"@berthojoris/mcp-mysql-server",
|
|
438
|
+
"mysql://user:password@localhost:3306/database",
|
|
439
|
+
"list,read,utility"
|
|
440
|
+
]
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
```
|
|
445
|
+
|
|
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
|
|
|
@@ -541,7 +891,7 @@ The MCP server provides **100 powerful tools**:
|
|
|
541
891
|
| `import_from_csv` | Import data from CSV string into a table | `create` permission |
|
|
542
892
|
| `import_from_json` | Import data from JSON array into a table | `create` permission |
|
|
543
893
|
|
|
544
|
-
### Data Migration (5 tools)
|
|
894
|
+
### Data Migration (5 tools)
|
|
545
895
|
|
|
546
896
|
| Tool | Description | Requires |
|
|
547
897
|
|------|-------------|----------|
|
|
@@ -551,6 +901,20 @@ The MCP server provides **100 powerful tools**:
|
|
|
551
901
|
| `compare_table_structure` | Compare structure of two tables and identify differences | `list` permission |
|
|
552
902
|
| `sync_table_data` | Synchronize data between tables (insert_only, update_only, upsert) | `update` permission |
|
|
553
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
|
+
|
|
554
918
|
---
|
|
555
919
|
|
|
556
920
|
## 📚 Detailed Documentation
|
|
@@ -562,6 +926,7 @@ For comprehensive documentation on all features, please see **[DOCUMENTATIONS.md
|
|
|
562
926
|
- 📥 **Data Import Tools** - Import data from CSV and JSON sources
|
|
563
927
|
- 💾 **Database Backup & Restore** - Full backup/restore with SQL dumps
|
|
564
928
|
- 🔄 **Data Migration Tools** - Copy, move, clone, compare, and sync table data
|
|
929
|
+
- 🔄 **Schema Versioning & Migrations** - Version control for database schema changes
|
|
565
930
|
- 💎 **Transaction Management** - ACID transactions with BEGIN, COMMIT, ROLLBACK
|
|
566
931
|
- 🔧 **Stored Procedures** - Create and execute stored procedures with IN/OUT/INOUT parameters
|
|
567
932
|
- 📋 **Usage Examples** - Real-world examples for all tools
|
|
@@ -147,6 +147,16 @@ exports.toolCategoryMap = {
|
|
|
147
147
|
cloneTable: ToolCategory.DDL,
|
|
148
148
|
compareTableStructure: ToolCategory.LIST,
|
|
149
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,
|
|
150
160
|
};
|
|
151
161
|
/**
|
|
152
162
|
* Class to manage feature configuration based on runtime or environment variables
|
package/dist/index.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ export declare class MySQLMCP {
|
|
|
20
20
|
private processTools;
|
|
21
21
|
private backupRestoreTools;
|
|
22
22
|
private migrationTools;
|
|
23
|
+
private schemaVersioningTools;
|
|
23
24
|
private security;
|
|
24
25
|
private featureConfig;
|
|
25
26
|
constructor(permissionsConfig?: string);
|
|
@@ -463,6 +464,122 @@ export declare class MySQLMCP {
|
|
|
463
464
|
error?: string;
|
|
464
465
|
queryLog?: string;
|
|
465
466
|
}>;
|
|
467
|
+
/**
|
|
468
|
+
* Initialize the migrations tracking table
|
|
469
|
+
*/
|
|
470
|
+
initMigrationsTable(params: {
|
|
471
|
+
database?: string;
|
|
472
|
+
}): Promise<{
|
|
473
|
+
status: string;
|
|
474
|
+
data?: any;
|
|
475
|
+
error?: string;
|
|
476
|
+
queryLog?: string;
|
|
477
|
+
}>;
|
|
478
|
+
/**
|
|
479
|
+
* Create a new migration
|
|
480
|
+
*/
|
|
481
|
+
createMigration(params: {
|
|
482
|
+
name: string;
|
|
483
|
+
up_sql: string;
|
|
484
|
+
down_sql?: string;
|
|
485
|
+
description?: string;
|
|
486
|
+
version?: string;
|
|
487
|
+
database?: string;
|
|
488
|
+
}): Promise<{
|
|
489
|
+
status: string;
|
|
490
|
+
data?: any;
|
|
491
|
+
error?: string;
|
|
492
|
+
queryLog?: string;
|
|
493
|
+
}>;
|
|
494
|
+
/**
|
|
495
|
+
* Apply pending migrations
|
|
496
|
+
*/
|
|
497
|
+
applyMigrations(params: {
|
|
498
|
+
target_version?: string;
|
|
499
|
+
dry_run?: boolean;
|
|
500
|
+
database?: string;
|
|
501
|
+
}): Promise<{
|
|
502
|
+
status: string;
|
|
503
|
+
data?: any;
|
|
504
|
+
error?: string;
|
|
505
|
+
queryLog?: string;
|
|
506
|
+
}>;
|
|
507
|
+
/**
|
|
508
|
+
* Rollback migrations
|
|
509
|
+
*/
|
|
510
|
+
rollbackMigration(params: {
|
|
511
|
+
target_version?: string;
|
|
512
|
+
steps?: number;
|
|
513
|
+
dry_run?: boolean;
|
|
514
|
+
database?: string;
|
|
515
|
+
}): Promise<{
|
|
516
|
+
status: string;
|
|
517
|
+
data?: any;
|
|
518
|
+
error?: string;
|
|
519
|
+
queryLog?: string;
|
|
520
|
+
}>;
|
|
521
|
+
/**
|
|
522
|
+
* Get migration status and history
|
|
523
|
+
*/
|
|
524
|
+
getMigrationStatus(params: {
|
|
525
|
+
version?: string;
|
|
526
|
+
status?: "pending" | "applied" | "failed" | "rolled_back";
|
|
527
|
+
limit?: number;
|
|
528
|
+
database?: string;
|
|
529
|
+
}): Promise<{
|
|
530
|
+
status: string;
|
|
531
|
+
data?: any;
|
|
532
|
+
error?: string;
|
|
533
|
+
queryLog?: string;
|
|
534
|
+
}>;
|
|
535
|
+
/**
|
|
536
|
+
* Get current schema version
|
|
537
|
+
*/
|
|
538
|
+
getSchemaVersion(params: {
|
|
539
|
+
database?: string;
|
|
540
|
+
}): Promise<{
|
|
541
|
+
status: string;
|
|
542
|
+
data?: any;
|
|
543
|
+
error?: string;
|
|
544
|
+
queryLog?: string;
|
|
545
|
+
}>;
|
|
546
|
+
/**
|
|
547
|
+
* Validate migrations for issues
|
|
548
|
+
*/
|
|
549
|
+
validateMigrations(params: {
|
|
550
|
+
database?: string;
|
|
551
|
+
}): Promise<{
|
|
552
|
+
status: string;
|
|
553
|
+
data?: any;
|
|
554
|
+
error?: string;
|
|
555
|
+
queryLog?: string;
|
|
556
|
+
}>;
|
|
557
|
+
/**
|
|
558
|
+
* Reset a failed migration to pending status
|
|
559
|
+
*/
|
|
560
|
+
resetFailedMigration(params: {
|
|
561
|
+
version: string;
|
|
562
|
+
database?: string;
|
|
563
|
+
}): Promise<{
|
|
564
|
+
status: string;
|
|
565
|
+
data?: any;
|
|
566
|
+
error?: string;
|
|
567
|
+
queryLog?: string;
|
|
568
|
+
}>;
|
|
569
|
+
/**
|
|
570
|
+
* Generate a migration from table structure differences
|
|
571
|
+
*/
|
|
572
|
+
generateMigrationFromDiff(params: {
|
|
573
|
+
table1: string;
|
|
574
|
+
table2: string;
|
|
575
|
+
migration_name: string;
|
|
576
|
+
database?: string;
|
|
577
|
+
}): Promise<{
|
|
578
|
+
status: string;
|
|
579
|
+
data?: any;
|
|
580
|
+
error?: string;
|
|
581
|
+
queryLog?: string;
|
|
582
|
+
}>;
|
|
466
583
|
getFeatureStatus(): {
|
|
467
584
|
status: string;
|
|
468
585
|
data: {
|