@berthojoris/mcp-mysql-server 1.6.2 β 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/CHANGELOG.md +17 -0
- package/DOCUMENTATIONS.md +259 -25
- package/README.md +25 -3
- package/dist/config/featureConfig.js +77 -0
- package/dist/index.d.ts +122 -0
- package/dist/index.js +75 -0
- package/dist/mcp-server.js +348 -0
- package/dist/security/securityLayer.js +9 -4
- 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/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,23 @@ All notable changes to the MySQL MCP Server will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.6.3] - 2025-11-23
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
- **Missing tools in toolCategoryMap** - Added 42 missing tools to the permission system
|
|
12
|
+
- View tools: listViews, getViewInfo, createView, alterView, dropView, showCreateView
|
|
13
|
+
- Trigger tools: listTriggers, getTriggerInfo, createTrigger, dropTrigger, showCreateTrigger
|
|
14
|
+
- Function tools: listFunctions, getFunctionInfo, createFunction, dropFunction, showCreateFunction, executeFunction
|
|
15
|
+
- Index tools: listIndexes, getIndexInfo, createIndex, dropIndex, analyzeIndex
|
|
16
|
+
- Constraint tools: listForeignKeys, listConstraints, addForeignKey, dropForeignKey, addUniqueConstraint, dropConstraint, addCheckConstraint
|
|
17
|
+
- Maintenance tools: analyzeTable, optimizeTable, checkTable, repairTable, truncateTable, getTableStatus, flushTable, getTableSize
|
|
18
|
+
- Server tools: showProcessList, killProcess, showStatus, showVariables, explainQuery, showEngineStatus, getServerInfo, showBinaryLogs, showReplicationStatus
|
|
19
|
+
|
|
20
|
+
- **Security keyword false positives in run_query** - Refined dangerous keywords to avoid blocking common table/column names
|
|
21
|
+
- Removed generic keywords: `USER`, `PASSWORD`, `MYSQL`, `SYS` that blocked legitimate queries
|
|
22
|
+
- Added specific security patterns: `MYSQL.USER`, `MYSQL.DB`, `CREATE USER`, `DROP USER`, `ALTER USER`, `SET PASSWORD`, `LOAD_FILE`, `INFORMATION_SCHEMA.USER_PRIVILEGES`
|
|
23
|
+
- Queries like `SELECT * FROM users` or `SELECT user, password FROM accounts` now work correctly
|
|
24
|
+
|
|
8
25
|
## [1.6.2] - 2025-11-22
|
|
9
26
|
|
|
10
27
|
### Fixed
|
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
|
|
@@ -76,6 +76,71 @@ exports.toolCategoryMap = {
|
|
|
76
76
|
// Query optimization tools
|
|
77
77
|
analyzeQuery: ToolCategory.UTILITY,
|
|
78
78
|
getOptimizationHints: ToolCategory.UTILITY,
|
|
79
|
+
// View tools
|
|
80
|
+
listViews: ToolCategory.LIST,
|
|
81
|
+
getViewInfo: ToolCategory.LIST,
|
|
82
|
+
createView: ToolCategory.DDL,
|
|
83
|
+
alterView: ToolCategory.DDL,
|
|
84
|
+
dropView: ToolCategory.DDL,
|
|
85
|
+
showCreateView: ToolCategory.LIST,
|
|
86
|
+
// Trigger tools
|
|
87
|
+
listTriggers: ToolCategory.LIST,
|
|
88
|
+
getTriggerInfo: ToolCategory.LIST,
|
|
89
|
+
createTrigger: ToolCategory.DDL,
|
|
90
|
+
dropTrigger: ToolCategory.DDL,
|
|
91
|
+
showCreateTrigger: ToolCategory.LIST,
|
|
92
|
+
// Function tools
|
|
93
|
+
listFunctions: ToolCategory.LIST,
|
|
94
|
+
getFunctionInfo: ToolCategory.LIST,
|
|
95
|
+
createFunction: ToolCategory.PROCEDURE,
|
|
96
|
+
dropFunction: ToolCategory.PROCEDURE,
|
|
97
|
+
showCreateFunction: ToolCategory.LIST,
|
|
98
|
+
executeFunction: ToolCategory.PROCEDURE,
|
|
99
|
+
// Index tools
|
|
100
|
+
listIndexes: ToolCategory.LIST,
|
|
101
|
+
getIndexInfo: ToolCategory.LIST,
|
|
102
|
+
createIndex: ToolCategory.DDL,
|
|
103
|
+
dropIndex: ToolCategory.DDL,
|
|
104
|
+
analyzeIndex: ToolCategory.UTILITY,
|
|
105
|
+
// Constraint tools
|
|
106
|
+
listForeignKeys: ToolCategory.LIST,
|
|
107
|
+
listConstraints: ToolCategory.LIST,
|
|
108
|
+
addForeignKey: ToolCategory.DDL,
|
|
109
|
+
dropForeignKey: ToolCategory.DDL,
|
|
110
|
+
addUniqueConstraint: ToolCategory.DDL,
|
|
111
|
+
dropConstraint: ToolCategory.DDL,
|
|
112
|
+
addCheckConstraint: ToolCategory.DDL,
|
|
113
|
+
// Table maintenance tools
|
|
114
|
+
analyzeTable: ToolCategory.UTILITY,
|
|
115
|
+
optimizeTable: ToolCategory.UTILITY,
|
|
116
|
+
checkTable: ToolCategory.UTILITY,
|
|
117
|
+
repairTable: ToolCategory.UTILITY,
|
|
118
|
+
truncateTable: ToolCategory.DDL,
|
|
119
|
+
getTableStatus: ToolCategory.LIST,
|
|
120
|
+
flushTable: ToolCategory.UTILITY,
|
|
121
|
+
getTableSize: ToolCategory.LIST,
|
|
122
|
+
// Process and server management tools
|
|
123
|
+
showProcessList: ToolCategory.LIST,
|
|
124
|
+
killProcess: ToolCategory.EXECUTE,
|
|
125
|
+
showStatus: ToolCategory.LIST,
|
|
126
|
+
showVariables: ToolCategory.LIST,
|
|
127
|
+
explainQuery: ToolCategory.UTILITY,
|
|
128
|
+
showEngineStatus: ToolCategory.LIST,
|
|
129
|
+
getServerInfo: ToolCategory.LIST,
|
|
130
|
+
showBinaryLogs: ToolCategory.LIST,
|
|
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,
|
|
79
144
|
};
|
|
80
145
|
/**
|
|
81
146
|
* Class to manage feature configuration based on runtime or environment variables
|
|
@@ -165,6 +230,18 @@ class FeatureConfig {
|
|
|
165
230
|
executeStoredProcedure: "execute stored procedures",
|
|
166
231
|
exportTableToCSV: "export table data to CSV",
|
|
167
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",
|
|
168
245
|
};
|
|
169
246
|
const toolDescription = toolDescriptions[toolName] || actionDescriptions[category];
|
|
170
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: {
|