@berthojoris/mcp-mysql-server 1.6.3 β 1.7.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 +259 -25
- package/README.md +25 -3
- package/dist/config/featureConfig.js +24 -0
- package/dist/index.d.ts +122 -0
- package/dist/index.js +75 -0
- package/dist/mcp-server.js +348 -0
- package/dist/tools/backupRestoreTools.d.ts +91 -0
- package/dist/tools/backupRestoreTools.js +584 -0
- package/dist/tools/dataExportTools.d.ts +91 -2
- package/dist/tools/dataExportTools.js +726 -66
- package/package.json +2 -2
package/DOCUMENTATIONS.md
CHANGED
|
@@ -8,24 +8,26 @@ This file contains detailed documentation for all features of the MySQL MCP Serv
|
|
|
8
8
|
|
|
9
9
|
1. [DDL Operations](#ποΈ-ddl-operations)
|
|
10
10
|
2. [Data Export Tools](#π€-data-export-tools)
|
|
11
|
-
3. [
|
|
12
|
-
4. [
|
|
13
|
-
5. [
|
|
14
|
-
6. [
|
|
15
|
-
7. [
|
|
16
|
-
8. [
|
|
17
|
-
9. [
|
|
18
|
-
10. [
|
|
19
|
-
11. [
|
|
20
|
-
12. [
|
|
21
|
-
13. [
|
|
22
|
-
14. [
|
|
23
|
-
15. [Query
|
|
24
|
-
16. [
|
|
25
|
-
17. [
|
|
26
|
-
18. [
|
|
27
|
-
19. [
|
|
28
|
-
20. [
|
|
11
|
+
3. [Data Import Tools](#π₯-data-import-tools) - NEW!
|
|
12
|
+
4. [Database Backup & Restore](#πΎ-database-backup--restore) - NEW!
|
|
13
|
+
5. [Transaction Management](#π°-transaction-management)
|
|
14
|
+
6. [Stored Procedures](#π§-stored-procedures)
|
|
15
|
+
7. [Views Management](#ποΈ-views-management)
|
|
16
|
+
8. [Triggers Management](#β‘-triggers-management)
|
|
17
|
+
9. [Functions Management](#π’-functions-management)
|
|
18
|
+
10. [Index Management](#π-index-management)
|
|
19
|
+
11. [Constraint Management](#π-constraint-management)
|
|
20
|
+
12. [Table Maintenance](#π§-table-maintenance)
|
|
21
|
+
13. [Process & Server Management](#π-process--server-management)
|
|
22
|
+
14. [Usage Examples](#π-usage-examples)
|
|
23
|
+
15. [Query Logging & Automatic SQL Display](#π-query-logging--automatic-sql-display)
|
|
24
|
+
16. [Security Features](#π-security-features)
|
|
25
|
+
17. [Query Result Caching](#πΎ-query-result-caching)
|
|
26
|
+
18. [Query Optimization Hints](#π―-query-optimization-hints)
|
|
27
|
+
19. [Bulk Operations](#π-bulk-operations)
|
|
28
|
+
20. [Troubleshooting](#π οΈ-troubleshooting)
|
|
29
|
+
21. [License](#π-license)
|
|
30
|
+
22. [Roadmap](#πΊοΈ-roadmap)
|
|
29
31
|
|
|
30
32
|
---
|
|
31
33
|
|
|
@@ -248,6 +250,237 @@ Both tools support:
|
|
|
248
250
|
|
|
249
251
|
---
|
|
250
252
|
|
|
253
|
+
## π₯ Data Import Tools
|
|
254
|
+
|
|
255
|
+
The MySQL MCP Server provides tools to import data from various formats into your database tables.
|
|
256
|
+
|
|
257
|
+
### Data Import Tools Overview
|
|
258
|
+
|
|
259
|
+
| Tool | Description | Permission |
|
|
260
|
+
|------|-------------|------------|
|
|
261
|
+
| `import_from_csv` | Import data from CSV string | `create` |
|
|
262
|
+
| `import_from_json` | Import data from JSON array | `create` |
|
|
263
|
+
|
|
264
|
+
### Import from CSV
|
|
265
|
+
|
|
266
|
+
Import data from a CSV string into a table with optional column mapping and error handling.
|
|
267
|
+
|
|
268
|
+
```json
|
|
269
|
+
{
|
|
270
|
+
"tool": "import_from_csv",
|
|
271
|
+
"arguments": {
|
|
272
|
+
"table_name": "users",
|
|
273
|
+
"csv_data": "name,email,age\nJohn,john@example.com,30\nJane,jane@example.com,25",
|
|
274
|
+
"has_headers": true,
|
|
275
|
+
"skip_errors": false,
|
|
276
|
+
"batch_size": 100
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
**With Column Mapping:**
|
|
282
|
+
```json
|
|
283
|
+
{
|
|
284
|
+
"tool": "import_from_csv",
|
|
285
|
+
"arguments": {
|
|
286
|
+
"table_name": "users",
|
|
287
|
+
"csv_data": "full_name,mail\nJohn Doe,john@example.com",
|
|
288
|
+
"has_headers": true,
|
|
289
|
+
"column_mapping": {
|
|
290
|
+
"full_name": "name",
|
|
291
|
+
"mail": "email"
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
### Import from JSON
|
|
298
|
+
|
|
299
|
+
Import data from a JSON array string into a table.
|
|
300
|
+
|
|
301
|
+
```json
|
|
302
|
+
{
|
|
303
|
+
"tool": "import_from_json",
|
|
304
|
+
"arguments": {
|
|
305
|
+
"table_name": "products",
|
|
306
|
+
"json_data": "[{\"name\":\"Widget\",\"price\":9.99},{\"name\":\"Gadget\",\"price\":19.99}]",
|
|
307
|
+
"skip_errors": false,
|
|
308
|
+
"batch_size": 100
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
### Import Response
|
|
314
|
+
|
|
315
|
+
```json
|
|
316
|
+
{
|
|
317
|
+
"status": "success",
|
|
318
|
+
"data": {
|
|
319
|
+
"message": "Import completed successfully",
|
|
320
|
+
"rows_imported": 150,
|
|
321
|
+
"rows_failed": 0
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
### Import Best Practices
|
|
327
|
+
|
|
328
|
+
1. **Validate data format** - Ensure CSV/JSON is well-formed before importing
|
|
329
|
+
2. **Use batch_size** - Adjust batch size for optimal performance (default: 100)
|
|
330
|
+
3. **Enable skip_errors** - For large imports, set `skip_errors: true` to continue on individual row failures
|
|
331
|
+
4. **Column mapping** - Use when source column names don't match table columns
|
|
332
|
+
|
|
333
|
+
---
|
|
334
|
+
|
|
335
|
+
## πΎ Database Backup & Restore
|
|
336
|
+
|
|
337
|
+
Enterprise-grade backup and restore functionality for MySQL databases.
|
|
338
|
+
|
|
339
|
+
### Backup & Restore Tools Overview
|
|
340
|
+
|
|
341
|
+
| Tool | Description | Permission |
|
|
342
|
+
|------|-------------|------------|
|
|
343
|
+
| `backup_table` | Backup single table to SQL dump | `utility` |
|
|
344
|
+
| `backup_database` | Backup entire database to SQL dump | `utility` |
|
|
345
|
+
| `restore_from_sql` | Restore from SQL dump content | `ddl` |
|
|
346
|
+
| `get_create_table_statement` | Get CREATE TABLE statement | `list` |
|
|
347
|
+
| `get_database_schema` | Get complete database schema | `list` |
|
|
348
|
+
|
|
349
|
+
### Backup Single Table
|
|
350
|
+
|
|
351
|
+
```json
|
|
352
|
+
{
|
|
353
|
+
"tool": "backup_table",
|
|
354
|
+
"arguments": {
|
|
355
|
+
"table_name": "users",
|
|
356
|
+
"include_data": true,
|
|
357
|
+
"include_drop": true
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
**Response:**
|
|
363
|
+
```json
|
|
364
|
+
{
|
|
365
|
+
"status": "success",
|
|
366
|
+
"data": {
|
|
367
|
+
"table_name": "users",
|
|
368
|
+
"sql_dump": "-- MySQL Dump...\nDROP TABLE IF EXISTS `users`;\nCREATE TABLE...\nINSERT INTO...",
|
|
369
|
+
"row_count": 1500,
|
|
370
|
+
"include_data": true,
|
|
371
|
+
"include_drop": true
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
### Backup Entire Database
|
|
377
|
+
|
|
378
|
+
```json
|
|
379
|
+
{
|
|
380
|
+
"tool": "backup_database",
|
|
381
|
+
"arguments": {
|
|
382
|
+
"include_data": true,
|
|
383
|
+
"include_drop": true
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
**Backup Specific Tables:**
|
|
389
|
+
```json
|
|
390
|
+
{
|
|
391
|
+
"tool": "backup_database",
|
|
392
|
+
"arguments": {
|
|
393
|
+
"tables": ["users", "orders", "products"],
|
|
394
|
+
"include_data": true
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
### Restore from SQL Dump
|
|
400
|
+
|
|
401
|
+
```json
|
|
402
|
+
{
|
|
403
|
+
"tool": "restore_from_sql",
|
|
404
|
+
"arguments": {
|
|
405
|
+
"sql_dump": "DROP TABLE IF EXISTS `users`;\nCREATE TABLE `users` (...);",
|
|
406
|
+
"stop_on_error": true
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
**Response:**
|
|
412
|
+
```json
|
|
413
|
+
{
|
|
414
|
+
"status": "success",
|
|
415
|
+
"data": {
|
|
416
|
+
"message": "Restore completed successfully",
|
|
417
|
+
"statements_executed": 25,
|
|
418
|
+
"statements_failed": 0
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
### Get Database Schema
|
|
424
|
+
|
|
425
|
+
Get a complete overview of all database objects:
|
|
426
|
+
|
|
427
|
+
```json
|
|
428
|
+
{
|
|
429
|
+
"tool": "get_database_schema",
|
|
430
|
+
"arguments": {
|
|
431
|
+
"include_views": true,
|
|
432
|
+
"include_procedures": true,
|
|
433
|
+
"include_functions": true,
|
|
434
|
+
"include_triggers": true
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
### Export to JSON Format
|
|
440
|
+
|
|
441
|
+
```json
|
|
442
|
+
{
|
|
443
|
+
"tool": "export_table_to_json",
|
|
444
|
+
"arguments": {
|
|
445
|
+
"table_name": "users",
|
|
446
|
+
"pretty": true,
|
|
447
|
+
"filters": [
|
|
448
|
+
{ "field": "status", "operator": "eq", "value": "active" }
|
|
449
|
+
]
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
### Export to SQL INSERT Statements
|
|
455
|
+
|
|
456
|
+
```json
|
|
457
|
+
{
|
|
458
|
+
"tool": "export_table_to_sql",
|
|
459
|
+
"arguments": {
|
|
460
|
+
"table_name": "products",
|
|
461
|
+
"include_create_table": true,
|
|
462
|
+
"batch_size": 100
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
### Backup Best Practices
|
|
468
|
+
|
|
469
|
+
1. **Regular backups** - Schedule regular database backups
|
|
470
|
+
2. **Test restores** - Periodically test your backup restoration process
|
|
471
|
+
3. **Include structure** - Always include `include_drop: true` for clean restores
|
|
472
|
+
4. **Schema-only backups** - Use `include_data: false` for structure-only backups
|
|
473
|
+
5. **Selective backups** - Use `tables` array to backup only critical tables
|
|
474
|
+
|
|
475
|
+
### Backup Safety Features
|
|
476
|
+
|
|
477
|
+
- **Transactional integrity** - Backups include transaction markers
|
|
478
|
+
- **Foreign key handling** - `SET FOREIGN_KEY_CHECKS=0` included in dumps
|
|
479
|
+
- **Binary data support** - Proper escaping for BLOB and binary columns
|
|
480
|
+
- **Character encoding** - UTF-8 encoding preserved in exports
|
|
481
|
+
|
|
482
|
+
---
|
|
483
|
+
|
|
251
484
|
## π° Transaction Management
|
|
252
485
|
|
|
253
486
|
The MySQL MCP Server provides full ACID transaction support, allowing you to group multiple database operations into atomic units.
|
|
@@ -1860,8 +2093,8 @@ MIT License - see [LICENSE](LICENSE) file for details.
|
|
|
1860
2093
|
- β
**Process Management** - Server processes, status, and query analysis - **COMPLETED!**
|
|
1861
2094
|
|
|
1862
2095
|
### Enterprise Features
|
|
1863
|
-
- [
|
|
1864
|
-
- [
|
|
2096
|
+
- [x] **Database backup and restore tools** - **COMPLETED!**
|
|
2097
|
+
- [x] **Data export/import utilities** (CSV, JSON, SQL dumps) - **COMPLETED!**
|
|
1865
2098
|
- [ ] **Performance monitoring and metrics**
|
|
1866
2099
|
- [ ] **Connection pool monitoring**
|
|
1867
2100
|
- [ ] **Audit logging and compliance**
|
|
@@ -1884,9 +2117,9 @@ MIT License - see [LICENSE](LICENSE) file for details.
|
|
|
1884
2117
|
- [ ] **Database health checks** - Comprehensive system health monitoring
|
|
1885
2118
|
|
|
1886
2119
|
#### **Phase 2: Data Management** π
|
|
1887
|
-
- [
|
|
2120
|
+
- [x] **Database backup and restore tools** - Essential for production data safety - **COMPLETED!**
|
|
1888
2121
|
- [ ] **Data migration utilities** - Move data between databases and environments
|
|
1889
|
-
- [
|
|
2122
|
+
- [x] **Enhanced export/import** - Support for JSON, SQL dump formats - **COMPLETED!**
|
|
1890
2123
|
- [ ] **Query history & analytics** - Track and analyze database usage patterns
|
|
1891
2124
|
|
|
1892
2125
|
#### **Phase 3: Enterprise Features** π’
|
|
@@ -1914,9 +2147,10 @@ MIT License - see [LICENSE](LICENSE) file for details.
|
|
|
1914
2147
|
| Table Maintenance | High | Low | 7 | β
COMPLETED |
|
|
1915
2148
|
| Process Management | High | Medium | 8 | β
COMPLETED |
|
|
1916
2149
|
| Query Optimization | Medium | Medium | 9 | β
COMPLETED |
|
|
1917
|
-
| Database Backup/Restore | High | High | 10 |
|
|
1918
|
-
|
|
|
1919
|
-
|
|
|
2150
|
+
| Database Backup/Restore | High | High | 10 | β
COMPLETED |
|
|
2151
|
+
| Data Export/Import (JSON, SQL) | High | Medium | 11 | β
COMPLETED |
|
|
2152
|
+
| Performance Monitoring | High | Medium | 12 | Pending |
|
|
2153
|
+
| Data Migration | High | High | 13 | Pending |
|
|
1920
2154
|
| PostgreSQL Adapter | High | High | 13 | Pending |
|
|
1921
2155
|
| Audit Logging | Medium | Low | 14 | Pending |
|
|
1922
2156
|
| Schema Versioning | Medium | Medium | 15 | Pending |
|
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ A fully-featured **Model Context Protocol (MCP)** server for MySQL database inte
|
|
|
11
11
|
|
|
12
12
|
- β
**Full MCP Protocol Support** - Works with Claude Desktop, Cline, Windsurf, and any MCP-compatible AI agent
|
|
13
13
|
- π **Secure by Default** - Parameterized queries, SQL injection protection, permission-based access control
|
|
14
|
-
- π οΈ **
|
|
14
|
+
- π οΈ **95 Powerful Tools** - Complete database operations (CRUD, DDL, queries, schema inspection, transactions, stored procedures, bulk operations, backup/restore, import/export)
|
|
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)
|
|
@@ -463,7 +463,7 @@ After (DDL enabled):
|
|
|
463
463
|
|
|
464
464
|
## π οΈ Available Tools
|
|
465
465
|
|
|
466
|
-
The MCP server provides **
|
|
466
|
+
The MCP server provides **95 powerful tools**:
|
|
467
467
|
|
|
468
468
|
### Database Discovery (4 tools)
|
|
469
469
|
|
|
@@ -635,6 +635,26 @@ The MCP server provides **85 powerful tools**:
|
|
|
635
635
|
| `analyze_query` | Analyze query and get optimization suggestions |
|
|
636
636
|
| `get_optimization_hints` | Get optimizer hints for SPEED, MEMORY, or STABILITY goals |
|
|
637
637
|
|
|
638
|
+
### Database Backup & Restore (5 tools) - NEW!
|
|
639
|
+
|
|
640
|
+
| Tool | Description | Requires |
|
|
641
|
+
|------|-------------|----------|
|
|
642
|
+
| `backup_table` | Backup single table to SQL dump format | `utility` permission |
|
|
643
|
+
| `backup_database` | Backup entire database to SQL dump | `utility` permission |
|
|
644
|
+
| `restore_from_sql` | Restore database from SQL dump content | `ddl` permission |
|
|
645
|
+
| `get_create_table_statement` | Get CREATE TABLE statement for a table | `list` permission |
|
|
646
|
+
| `get_database_schema` | Get complete database schema (tables, views, procedures, functions, triggers) | `list` permission |
|
|
647
|
+
|
|
648
|
+
### Data Import/Export (5 tools) - NEW!
|
|
649
|
+
|
|
650
|
+
| Tool | Description | Requires |
|
|
651
|
+
|------|-------------|----------|
|
|
652
|
+
| `export_table_to_json` | Export table data to JSON format | `utility` permission |
|
|
653
|
+
| `export_query_to_json` | Export query results to JSON format | `utility` permission |
|
|
654
|
+
| `export_table_to_sql` | Export table data to SQL INSERT statements | `utility` permission |
|
|
655
|
+
| `import_from_csv` | Import data from CSV string into a table | `create` permission |
|
|
656
|
+
| `import_from_json` | Import data from JSON array into a table | `create` permission |
|
|
657
|
+
|
|
638
658
|
---
|
|
639
659
|
|
|
640
660
|
## π Detailed Documentation
|
|
@@ -642,7 +662,9 @@ The MCP server provides **85 powerful tools**:
|
|
|
642
662
|
For comprehensive documentation on all features, please see **[DOCUMENTATIONS.md](DOCUMENTATIONS.md)** which includes:
|
|
643
663
|
|
|
644
664
|
- ποΈ **DDL Operations** - Create, alter, and drop tables
|
|
645
|
-
- π€ **Data Export Tools** - Export data to CSV
|
|
665
|
+
- π€ **Data Export Tools** - Export data to CSV, JSON, and SQL formats
|
|
666
|
+
- π₯ **Data Import Tools** - Import data from CSV and JSON sources
|
|
667
|
+
- πΎ **Database Backup & Restore** - Full backup/restore with SQL dumps
|
|
646
668
|
- π **Transaction Management** - ACID transactions with BEGIN, COMMIT, ROLLBACK
|
|
647
669
|
- π§ **Stored Procedures** - Create and execute stored procedures with IN/OUT/INOUT parameters
|
|
648
670
|
- π **Usage Examples** - Real-world examples for all tools
|
|
@@ -129,6 +129,18 @@ exports.toolCategoryMap = {
|
|
|
129
129
|
getServerInfo: ToolCategory.LIST,
|
|
130
130
|
showBinaryLogs: ToolCategory.LIST,
|
|
131
131
|
showReplicationStatus: ToolCategory.LIST,
|
|
132
|
+
// Backup and restore tools
|
|
133
|
+
backupTable: ToolCategory.UTILITY,
|
|
134
|
+
backupDatabase: ToolCategory.UTILITY,
|
|
135
|
+
restoreFromSql: ToolCategory.DDL,
|
|
136
|
+
getCreateTableStatement: ToolCategory.LIST,
|
|
137
|
+
getDatabaseSchema: ToolCategory.LIST,
|
|
138
|
+
// Extended data export/import tools
|
|
139
|
+
exportTableToJSON: ToolCategory.UTILITY,
|
|
140
|
+
exportQueryToJSON: ToolCategory.UTILITY,
|
|
141
|
+
exportTableToSql: ToolCategory.UTILITY,
|
|
142
|
+
importFromCSV: ToolCategory.CREATE,
|
|
143
|
+
importFromJSON: ToolCategory.CREATE,
|
|
132
144
|
};
|
|
133
145
|
/**
|
|
134
146
|
* Class to manage feature configuration based on runtime or environment variables
|
|
@@ -218,6 +230,18 @@ class FeatureConfig {
|
|
|
218
230
|
executeStoredProcedure: "execute stored procedures",
|
|
219
231
|
exportTableToCSV: "export table data to CSV",
|
|
220
232
|
exportQueryToCSV: "export query results to CSV",
|
|
233
|
+
// Backup and restore
|
|
234
|
+
backupTable: "backup table to SQL dump",
|
|
235
|
+
backupDatabase: "backup database to SQL dump",
|
|
236
|
+
restoreFromSql: "restore database from SQL dump",
|
|
237
|
+
getCreateTableStatement: "get CREATE TABLE statement",
|
|
238
|
+
getDatabaseSchema: "get database schema overview",
|
|
239
|
+
// Extended export/import
|
|
240
|
+
exportTableToJSON: "export table data to JSON",
|
|
241
|
+
exportQueryToJSON: "export query results to JSON",
|
|
242
|
+
exportTableToSql: "export table data to SQL INSERT statements",
|
|
243
|
+
importFromCSV: "import data from CSV",
|
|
244
|
+
importFromJSON: "import data from JSON",
|
|
221
245
|
};
|
|
222
246
|
const toolDescription = toolDescriptions[toolName] || actionDescriptions[category];
|
|
223
247
|
const requiredPermission = category;
|
package/dist/index.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export declare class MySQLMCP {
|
|
|
18
18
|
private constraintTools;
|
|
19
19
|
private maintenanceTools;
|
|
20
20
|
private processTools;
|
|
21
|
+
private backupRestoreTools;
|
|
21
22
|
private security;
|
|
22
23
|
private featureConfig;
|
|
23
24
|
constructor(permissionsConfig?: string);
|
|
@@ -278,6 +279,127 @@ export declare class MySQLMCP {
|
|
|
278
279
|
error?: string;
|
|
279
280
|
queryLog?: string;
|
|
280
281
|
}>;
|
|
282
|
+
exportTableToJSON(params: {
|
|
283
|
+
table_name: string;
|
|
284
|
+
filters?: any[];
|
|
285
|
+
pagination?: {
|
|
286
|
+
page: number;
|
|
287
|
+
limit: number;
|
|
288
|
+
};
|
|
289
|
+
sorting?: {
|
|
290
|
+
field: string;
|
|
291
|
+
direction: "asc" | "desc";
|
|
292
|
+
};
|
|
293
|
+
pretty?: boolean;
|
|
294
|
+
database?: string;
|
|
295
|
+
}): Promise<{
|
|
296
|
+
status: string;
|
|
297
|
+
data?: any;
|
|
298
|
+
error?: string;
|
|
299
|
+
queryLog?: string;
|
|
300
|
+
}>;
|
|
301
|
+
exportQueryToJSON(params: {
|
|
302
|
+
query: string;
|
|
303
|
+
params?: any[];
|
|
304
|
+
pretty?: boolean;
|
|
305
|
+
}): Promise<{
|
|
306
|
+
status: string;
|
|
307
|
+
data?: any;
|
|
308
|
+
error?: string;
|
|
309
|
+
queryLog?: string;
|
|
310
|
+
}>;
|
|
311
|
+
exportTableToSql(params: {
|
|
312
|
+
table_name: string;
|
|
313
|
+
filters?: any[];
|
|
314
|
+
include_create_table?: boolean;
|
|
315
|
+
batch_size?: number;
|
|
316
|
+
database?: string;
|
|
317
|
+
}): Promise<{
|
|
318
|
+
status: string;
|
|
319
|
+
data?: any;
|
|
320
|
+
error?: string;
|
|
321
|
+
queryLog?: string;
|
|
322
|
+
}>;
|
|
323
|
+
importFromCSV(params: {
|
|
324
|
+
table_name: string;
|
|
325
|
+
csv_data: string;
|
|
326
|
+
has_headers?: boolean;
|
|
327
|
+
column_mapping?: Record<string, string>;
|
|
328
|
+
skip_errors?: boolean;
|
|
329
|
+
batch_size?: number;
|
|
330
|
+
database?: string;
|
|
331
|
+
}): Promise<{
|
|
332
|
+
status: string;
|
|
333
|
+
data?: any;
|
|
334
|
+
error?: string;
|
|
335
|
+
queryLog?: string;
|
|
336
|
+
}>;
|
|
337
|
+
importFromJSON(params: {
|
|
338
|
+
table_name: string;
|
|
339
|
+
json_data: string;
|
|
340
|
+
column_mapping?: Record<string, string>;
|
|
341
|
+
skip_errors?: boolean;
|
|
342
|
+
batch_size?: number;
|
|
343
|
+
database?: string;
|
|
344
|
+
}): Promise<{
|
|
345
|
+
status: string;
|
|
346
|
+
data?: any;
|
|
347
|
+
error?: string;
|
|
348
|
+
queryLog?: string;
|
|
349
|
+
}>;
|
|
350
|
+
backupTable(params: {
|
|
351
|
+
table_name: string;
|
|
352
|
+
include_data?: boolean;
|
|
353
|
+
include_drop?: boolean;
|
|
354
|
+
database?: string;
|
|
355
|
+
}): Promise<{
|
|
356
|
+
status: string;
|
|
357
|
+
data?: any;
|
|
358
|
+
error?: string;
|
|
359
|
+
queryLog?: string;
|
|
360
|
+
}>;
|
|
361
|
+
backupDatabase(params: {
|
|
362
|
+
include_data?: boolean;
|
|
363
|
+
include_drop?: boolean;
|
|
364
|
+
tables?: string[];
|
|
365
|
+
database?: string;
|
|
366
|
+
}): Promise<{
|
|
367
|
+
status: string;
|
|
368
|
+
data?: any;
|
|
369
|
+
error?: string;
|
|
370
|
+
queryLog?: string;
|
|
371
|
+
}>;
|
|
372
|
+
restoreFromSql(params: {
|
|
373
|
+
sql_dump: string;
|
|
374
|
+
stop_on_error?: boolean;
|
|
375
|
+
database?: string;
|
|
376
|
+
}): Promise<{
|
|
377
|
+
status: string;
|
|
378
|
+
data?: any;
|
|
379
|
+
error?: string;
|
|
380
|
+
queryLog?: string;
|
|
381
|
+
}>;
|
|
382
|
+
getCreateTableStatement(params: {
|
|
383
|
+
table_name: string;
|
|
384
|
+
database?: string;
|
|
385
|
+
}): Promise<{
|
|
386
|
+
status: string;
|
|
387
|
+
data?: any;
|
|
388
|
+
error?: string;
|
|
389
|
+
queryLog?: string;
|
|
390
|
+
}>;
|
|
391
|
+
getDatabaseSchema(params: {
|
|
392
|
+
database?: string;
|
|
393
|
+
include_views?: boolean;
|
|
394
|
+
include_procedures?: boolean;
|
|
395
|
+
include_functions?: boolean;
|
|
396
|
+
include_triggers?: boolean;
|
|
397
|
+
}): Promise<{
|
|
398
|
+
status: string;
|
|
399
|
+
data?: any;
|
|
400
|
+
error?: string;
|
|
401
|
+
queryLog?: string;
|
|
402
|
+
}>;
|
|
281
403
|
getFeatureStatus(): {
|
|
282
404
|
status: string;
|
|
283
405
|
data: {
|
package/dist/index.js
CHANGED
|
@@ -19,6 +19,7 @@ const indexTools_1 = require("./tools/indexTools");
|
|
|
19
19
|
const constraintTools_1 = require("./tools/constraintTools");
|
|
20
20
|
const maintenanceTools_1 = require("./tools/maintenanceTools");
|
|
21
21
|
const processTools_1 = require("./tools/processTools");
|
|
22
|
+
const backupRestoreTools_1 = require("./tools/backupRestoreTools");
|
|
22
23
|
const securityLayer_1 = __importDefault(require("./security/securityLayer"));
|
|
23
24
|
const connection_1 = __importDefault(require("./db/connection"));
|
|
24
25
|
const featureConfig_1 = require("./config/featureConfig");
|
|
@@ -45,6 +46,7 @@ class MySQLMCP {
|
|
|
45
46
|
this.constraintTools = new constraintTools_1.ConstraintTools(this.security);
|
|
46
47
|
this.maintenanceTools = new maintenanceTools_1.MaintenanceTools(this.security);
|
|
47
48
|
this.processTools = new processTools_1.ProcessTools(this.security);
|
|
49
|
+
this.backupRestoreTools = new backupRestoreTools_1.BackupRestoreTools(this.security);
|
|
48
50
|
}
|
|
49
51
|
// Helper method to check if tool is enabled
|
|
50
52
|
checkToolEnabled(toolName) {
|
|
@@ -284,6 +286,79 @@ class MySQLMCP {
|
|
|
284
286
|
}
|
|
285
287
|
return await this.dataExportTools.exportQueryToCSV(params);
|
|
286
288
|
}
|
|
289
|
+
// Extended Data Export Tools (JSON, SQL)
|
|
290
|
+
async exportTableToJSON(params) {
|
|
291
|
+
const check = this.checkToolEnabled("exportTableToJSON");
|
|
292
|
+
if (!check.enabled) {
|
|
293
|
+
return { status: "error", error: check.error };
|
|
294
|
+
}
|
|
295
|
+
return await this.dataExportTools.exportTableToJSON(params);
|
|
296
|
+
}
|
|
297
|
+
async exportQueryToJSON(params) {
|
|
298
|
+
const check = this.checkToolEnabled("exportQueryToJSON");
|
|
299
|
+
if (!check.enabled) {
|
|
300
|
+
return { status: "error", error: check.error };
|
|
301
|
+
}
|
|
302
|
+
return await this.dataExportTools.exportQueryToJSON(params);
|
|
303
|
+
}
|
|
304
|
+
async exportTableToSql(params) {
|
|
305
|
+
const check = this.checkToolEnabled("exportTableToSql");
|
|
306
|
+
if (!check.enabled) {
|
|
307
|
+
return { status: "error", error: check.error };
|
|
308
|
+
}
|
|
309
|
+
return await this.dataExportTools.exportTableToSql(params);
|
|
310
|
+
}
|
|
311
|
+
// Data Import Tools
|
|
312
|
+
async importFromCSV(params) {
|
|
313
|
+
const check = this.checkToolEnabled("importFromCSV");
|
|
314
|
+
if (!check.enabled) {
|
|
315
|
+
return { status: "error", error: check.error };
|
|
316
|
+
}
|
|
317
|
+
return await this.dataExportTools.importFromCSV(params);
|
|
318
|
+
}
|
|
319
|
+
async importFromJSON(params) {
|
|
320
|
+
const check = this.checkToolEnabled("importFromJSON");
|
|
321
|
+
if (!check.enabled) {
|
|
322
|
+
return { status: "error", error: check.error };
|
|
323
|
+
}
|
|
324
|
+
return await this.dataExportTools.importFromJSON(params);
|
|
325
|
+
}
|
|
326
|
+
// Backup and Restore Tools
|
|
327
|
+
async backupTable(params) {
|
|
328
|
+
const check = this.checkToolEnabled("backupTable");
|
|
329
|
+
if (!check.enabled) {
|
|
330
|
+
return { status: "error", error: check.error };
|
|
331
|
+
}
|
|
332
|
+
return await this.backupRestoreTools.backupTable(params);
|
|
333
|
+
}
|
|
334
|
+
async backupDatabase(params) {
|
|
335
|
+
const check = this.checkToolEnabled("backupDatabase");
|
|
336
|
+
if (!check.enabled) {
|
|
337
|
+
return { status: "error", error: check.error };
|
|
338
|
+
}
|
|
339
|
+
return await this.backupRestoreTools.backupDatabase(params);
|
|
340
|
+
}
|
|
341
|
+
async restoreFromSql(params) {
|
|
342
|
+
const check = this.checkToolEnabled("restoreFromSql");
|
|
343
|
+
if (!check.enabled) {
|
|
344
|
+
return { status: "error", error: check.error };
|
|
345
|
+
}
|
|
346
|
+
return await this.backupRestoreTools.restoreFromSql(params);
|
|
347
|
+
}
|
|
348
|
+
async getCreateTableStatement(params) {
|
|
349
|
+
const check = this.checkToolEnabled("getCreateTableStatement");
|
|
350
|
+
if (!check.enabled) {
|
|
351
|
+
return { status: "error", error: check.error };
|
|
352
|
+
}
|
|
353
|
+
return await this.backupRestoreTools.getCreateTableStatement(params);
|
|
354
|
+
}
|
|
355
|
+
async getDatabaseSchema(params) {
|
|
356
|
+
const check = this.checkToolEnabled("getDatabaseSchema");
|
|
357
|
+
if (!check.enabled) {
|
|
358
|
+
return { status: "error", error: check.error };
|
|
359
|
+
}
|
|
360
|
+
return await this.backupRestoreTools.getDatabaseSchema(params);
|
|
361
|
+
}
|
|
287
362
|
// Get feature configuration status
|
|
288
363
|
getFeatureStatus() {
|
|
289
364
|
return {
|