@berthojoris/mcp-mysql-server 1.10.1 β 1.10.2
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 +262 -26
- package/README.md +65 -271
- package/package.json +1 -1
package/DOCUMENTATIONS.md
CHANGED
|
@@ -7,32 +7,33 @@ This file contains detailed documentation for all features of the MySQL MCP Serv
|
|
|
7
7
|
## Table of Contents
|
|
8
8
|
|
|
9
9
|
1. [π Category Filtering System](#π-category-filtering-system) - NEW!
|
|
10
|
-
2. [
|
|
11
|
-
3. [
|
|
12
|
-
4. [Data
|
|
13
|
-
5. [
|
|
14
|
-
6. [
|
|
15
|
-
7. [
|
|
16
|
-
8. [
|
|
17
|
-
9. [
|
|
18
|
-
10. [
|
|
19
|
-
11. [
|
|
20
|
-
12. [
|
|
21
|
-
13. [
|
|
22
|
-
14. [
|
|
23
|
-
15. [
|
|
24
|
-
16. [
|
|
25
|
-
17. [
|
|
26
|
-
18. [
|
|
27
|
-
19. [
|
|
28
|
-
20. [
|
|
29
|
-
21. [
|
|
30
|
-
22. [Query
|
|
31
|
-
23. [
|
|
32
|
-
24. [
|
|
33
|
-
25. [
|
|
34
|
-
26. [
|
|
35
|
-
27. [
|
|
10
|
+
2. [π§ Complete Tools Reference](#π§-complete-tools-reference) - All 119 tools organized by category
|
|
11
|
+
3. [DDL Operations](#ποΈ-ddl-operations)
|
|
12
|
+
4. [Data Export Tools](#π€-data-export-tools)
|
|
13
|
+
5. [Data Import Tools](#π₯-data-import-tools)
|
|
14
|
+
6. [Database Backup & Restore](#πΎ-database-backup--restore)
|
|
15
|
+
7. [Data Migration Tools](#π-data-migration-tools)
|
|
16
|
+
8. [Schema Versioning & Migrations](#π-schema-versioning-and-migrations)
|
|
17
|
+
9. [Transaction Management](#π°-transaction-management)
|
|
18
|
+
10. [Stored Procedures](#π§-stored-procedures)
|
|
19
|
+
11. [Views Management](#ποΈ-views-management)
|
|
20
|
+
12. [Triggers Management](#β‘-triggers-management)
|
|
21
|
+
13. [Functions Management](#π’-functions-management)
|
|
22
|
+
14. [Index Management](#π-index-management)
|
|
23
|
+
15. [Constraint Management](#π-constraint-management)
|
|
24
|
+
16. [Table Maintenance](#π§-table-maintenance)
|
|
25
|
+
17. [Process & Server Management](#π-process--server-management)
|
|
26
|
+
18. [Performance Monitoring](#π-performance-monitoring)
|
|
27
|
+
19. [Usage Examples](#π-usage-examples)
|
|
28
|
+
20. [Query Logging & Automatic SQL Display](#π-query-logging--automatic-sql-display)
|
|
29
|
+
21. [Security Features](#π-security-features)
|
|
30
|
+
22. [Query Result Caching](#πΎ-query-result-caching)
|
|
31
|
+
23. [Query Optimization Hints](#π―-query-optimization-hints)
|
|
32
|
+
24. [Bulk Operations](#π-bulk-operations)
|
|
33
|
+
25. [OpenAI Codex Integration](#π€-openai-codex-integration)
|
|
34
|
+
26. [Troubleshooting](#π οΈ-troubleshooting)
|
|
35
|
+
27. [License](#π-license)
|
|
36
|
+
28. [Roadmap](#πΊοΈ-roadmap)
|
|
36
37
|
|
|
37
38
|
---
|
|
38
39
|
|
|
@@ -264,6 +265,241 @@ Add 'bulk_operations' to the categories argument.
|
|
|
264
265
|
|
|
265
266
|
---
|
|
266
267
|
|
|
268
|
+
## π§ Complete Tools Reference
|
|
269
|
+
|
|
270
|
+
This section provides a comprehensive reference of all 119 available tools organized by category.
|
|
271
|
+
|
|
272
|
+
### Database Discovery
|
|
273
|
+
|
|
274
|
+
| Tool | Description |
|
|
275
|
+
|------|-------------|
|
|
276
|
+
| `list_databases` | Lists all databases on the MySQL server |
|
|
277
|
+
| `list_tables` | Lists all tables in the current/specified database |
|
|
278
|
+
| `read_table_schema` | Gets detailed schema (columns, types, keys, indexes) |
|
|
279
|
+
| `get_table_relationships` | Discovers foreign key relationships |
|
|
280
|
+
|
|
281
|
+
### Data Operations - CRUD
|
|
282
|
+
|
|
283
|
+
| Tool | Description |
|
|
284
|
+
|------|-------------|
|
|
285
|
+
| `create_record` | Insert new records with automatic SQL generation |
|
|
286
|
+
| `read_records` | Query records with filtering, pagination, and sorting |
|
|
287
|
+
| `update_record` | Update records based on conditions |
|
|
288
|
+
| `delete_record` | Delete records with safety checks |
|
|
289
|
+
|
|
290
|
+
### Bulk Operations
|
|
291
|
+
|
|
292
|
+
| Tool | Description | Performance |
|
|
293
|
+
|------|-------------|-------------|
|
|
294
|
+
| `bulk_insert` | Insert multiple records in batches | Up to 10,000 records/batch |
|
|
295
|
+
| `bulk_update` | Update multiple records with different conditions | Up to 1,000 ops/batch |
|
|
296
|
+
| `bulk_delete` | Delete multiple record sets | Up to 1,000 ops/batch |
|
|
297
|
+
|
|
298
|
+
### Custom Queries
|
|
299
|
+
|
|
300
|
+
| Tool | Description |
|
|
301
|
+
|------|-------------|
|
|
302
|
+
| `run_query` | Execute read-only SELECT queries |
|
|
303
|
+
| `execute_sql` | Execute write operations (INSERT, UPDATE, DELETE, or DDL) |
|
|
304
|
+
|
|
305
|
+
### Schema Management - DDL
|
|
306
|
+
|
|
307
|
+
| Tool | Description | Requires |
|
|
308
|
+
|------|-------------|----------|
|
|
309
|
+
| `create_table` | Create new tables with columns and indexes | `ddl` |
|
|
310
|
+
| `alter_table` | Modify table structure | `ddl` |
|
|
311
|
+
| `drop_table` | Delete tables | `ddl` |
|
|
312
|
+
| `execute_ddl` | Execute raw DDL SQL | `ddl` |
|
|
313
|
+
|
|
314
|
+
### Utilities
|
|
315
|
+
|
|
316
|
+
| Tool | Description |
|
|
317
|
+
|------|-------------|
|
|
318
|
+
| `test_connection` | Test database connectivity and measure latency |
|
|
319
|
+
| `describe_connection` | Get current connection information |
|
|
320
|
+
| `export_table_to_csv` | Export table data to CSV format |
|
|
321
|
+
| `export_query_to_csv` | Export query results to CSV format |
|
|
322
|
+
|
|
323
|
+
### Transaction Management
|
|
324
|
+
|
|
325
|
+
| Tool | Description |
|
|
326
|
+
|------|-------------|
|
|
327
|
+
| `begin_transaction` | Start a new database transaction |
|
|
328
|
+
| `commit_transaction` | Commit the current transaction |
|
|
329
|
+
| `rollback_transaction` | Rollback the current transaction |
|
|
330
|
+
| `get_transaction_status` | Check if a transaction is active |
|
|
331
|
+
| `execute_in_transaction` | Execute SQL within a transaction context |
|
|
332
|
+
|
|
333
|
+
### Stored Procedures
|
|
334
|
+
|
|
335
|
+
| Tool | Description | Requires |
|
|
336
|
+
|------|-------------|----------|
|
|
337
|
+
| `list_stored_procedures` | List all stored procedures | `procedure` |
|
|
338
|
+
| `create_stored_procedure` | Create new stored procedures | `procedure` |
|
|
339
|
+
| `get_stored_procedure_info` | Get procedure details | `procedure` |
|
|
340
|
+
| `execute_stored_procedure` | Execute with IN/OUT/INOUT params | `procedure` |
|
|
341
|
+
| `drop_stored_procedure` | Delete stored procedures | `procedure` |
|
|
342
|
+
| `show_create_procedure` | Show CREATE statement | `procedure` |
|
|
343
|
+
|
|
344
|
+
### Views Management
|
|
345
|
+
|
|
346
|
+
| Tool | Description | Requires |
|
|
347
|
+
|------|-------------|----------|
|
|
348
|
+
| `list_views` | List all views in the database | `list` |
|
|
349
|
+
| `get_view_info` | Get detailed view information | `list` |
|
|
350
|
+
| `create_view` | Create a new view | `ddl` |
|
|
351
|
+
| `alter_view` | Alter an existing view | `ddl` |
|
|
352
|
+
| `drop_view` | Drop a view | `ddl` |
|
|
353
|
+
| `show_create_view` | Show CREATE statement | `list` |
|
|
354
|
+
|
|
355
|
+
### Triggers Management
|
|
356
|
+
|
|
357
|
+
| Tool | Description | Requires |
|
|
358
|
+
|------|-------------|----------|
|
|
359
|
+
| `list_triggers` | List all triggers | `list` |
|
|
360
|
+
| `get_trigger_info` | Get trigger details | `list` |
|
|
361
|
+
| `create_trigger` | Create a new trigger | `ddl` |
|
|
362
|
+
| `drop_trigger` | Drop a trigger | `ddl` |
|
|
363
|
+
| `show_create_trigger` | Show CREATE statement | `list` |
|
|
364
|
+
|
|
365
|
+
### Functions Management
|
|
366
|
+
|
|
367
|
+
| Tool | Description | Requires |
|
|
368
|
+
|------|-------------|----------|
|
|
369
|
+
| `list_functions` | List all user-defined functions | `list` |
|
|
370
|
+
| `get_function_info` | Get function details | `list` |
|
|
371
|
+
| `create_function` | Create a new function | `ddl` |
|
|
372
|
+
| `drop_function` | Drop a function | `ddl` |
|
|
373
|
+
| `show_create_function` | Show CREATE statement | `list` |
|
|
374
|
+
| `execute_function` | Execute and return result | `read` |
|
|
375
|
+
|
|
376
|
+
### Index Management
|
|
377
|
+
|
|
378
|
+
| Tool | Description | Requires |
|
|
379
|
+
|------|-------------|----------|
|
|
380
|
+
| `list_indexes` | List all indexes for a table | `list` |
|
|
381
|
+
| `get_index_info` | Get index details | `list` |
|
|
382
|
+
| `create_index` | Create index (BTREE, HASH, FULLTEXT, SPATIAL) | `ddl` |
|
|
383
|
+
| `drop_index` | Drop an index | `ddl` |
|
|
384
|
+
| `analyze_index` | Analyze index statistics | `utility` |
|
|
385
|
+
|
|
386
|
+
### Constraint Management
|
|
387
|
+
|
|
388
|
+
| Tool | Description | Requires |
|
|
389
|
+
|------|-------------|----------|
|
|
390
|
+
| `list_foreign_keys` | List all foreign keys | `list` |
|
|
391
|
+
| `list_constraints` | List all constraints (PK, FK, UNIQUE, CHECK) | `list` |
|
|
392
|
+
| `add_foreign_key` | Add a foreign key constraint | `ddl` |
|
|
393
|
+
| `drop_foreign_key` | Drop a foreign key | `ddl` |
|
|
394
|
+
| `add_unique_constraint` | Add a unique constraint | `ddl` |
|
|
395
|
+
| `drop_constraint` | Drop UNIQUE or CHECK constraint | `ddl` |
|
|
396
|
+
| `add_check_constraint` | Add CHECK constraint (MySQL 8.0.16+) | `ddl` |
|
|
397
|
+
|
|
398
|
+
### Table Maintenance
|
|
399
|
+
|
|
400
|
+
| Tool | Description | Requires |
|
|
401
|
+
|------|-------------|----------|
|
|
402
|
+
| `analyze_table` | Update index statistics | `utility` |
|
|
403
|
+
| `optimize_table` | Reclaim space and defragment | `utility` |
|
|
404
|
+
| `check_table` | Check table for errors | `utility` |
|
|
405
|
+
| `repair_table` | Repair corrupted table | `utility` |
|
|
406
|
+
| `truncate_table` | Remove all rows quickly | `ddl` |
|
|
407
|
+
| `get_table_status` | Get table status and statistics | `list` |
|
|
408
|
+
| `flush_table` | Close and reopen table(s) | `utility` |
|
|
409
|
+
| `get_table_size` | Get size information | `list` |
|
|
410
|
+
|
|
411
|
+
### Process & Server Management
|
|
412
|
+
|
|
413
|
+
| Tool | Description | Requires |
|
|
414
|
+
|------|-------------|----------|
|
|
415
|
+
| `show_process_list` | Show running MySQL processes | `utility` |
|
|
416
|
+
| `kill_process` | Kill a MySQL process/connection | `utility` |
|
|
417
|
+
| `show_status` | Show server status variables | `utility` |
|
|
418
|
+
| `show_variables` | Show server configuration | `utility` |
|
|
419
|
+
| `explain_query` | Show query execution plan | `utility` |
|
|
420
|
+
| `show_engine_status` | Show storage engine status | `utility` |
|
|
421
|
+
| `get_server_info` | Get comprehensive server info | `utility` |
|
|
422
|
+
| `show_binary_logs` | Show binary log files | `utility` |
|
|
423
|
+
| `show_replication_status` | Show replication status | `utility` |
|
|
424
|
+
|
|
425
|
+
### Performance Monitoring
|
|
426
|
+
|
|
427
|
+
| Tool | Description | Requires |
|
|
428
|
+
|------|-------------|----------|
|
|
429
|
+
| `get_performance_metrics` | Get comprehensive performance metrics | `utility` |
|
|
430
|
+
| `get_top_queries_by_time` | Find slowest queries by execution time | `utility` |
|
|
431
|
+
| `get_top_queries_by_count` | Find most frequently executed queries | `utility` |
|
|
432
|
+
| `get_slow_queries` | Identify queries exceeding time threshold | `utility` |
|
|
433
|
+
| `get_table_io_stats` | Monitor table I/O operations | `utility` |
|
|
434
|
+
| `get_index_usage_stats` | Track index usage statistics | `utility` |
|
|
435
|
+
| `get_unused_indexes` | Identify unused indexes | `utility` |
|
|
436
|
+
| `get_connection_pool_stats` | Monitor connection pool health | `utility` |
|
|
437
|
+
| `get_database_health_check` | Comprehensive health assessment | `utility` |
|
|
438
|
+
| `reset_performance_stats` | Reset performance schema statistics | `utility` |
|
|
439
|
+
|
|
440
|
+
### Cache Management
|
|
441
|
+
|
|
442
|
+
| Tool | Description |
|
|
443
|
+
|------|-------------|
|
|
444
|
+
| `get_cache_stats` | Get query cache statistics |
|
|
445
|
+
| `get_cache_config` | Get current cache configuration |
|
|
446
|
+
| `configure_cache` | Configure cache settings |
|
|
447
|
+
| `clear_cache` | Clear all cached results |
|
|
448
|
+
| `invalidate_table_cache` | Invalidate cache for specific table |
|
|
449
|
+
|
|
450
|
+
### Query Optimization
|
|
451
|
+
|
|
452
|
+
| Tool | Description |
|
|
453
|
+
|------|-------------|
|
|
454
|
+
| `analyze_query` | Analyze query and get optimization suggestions |
|
|
455
|
+
| `get_optimization_hints` | Get optimizer hints for SPEED, MEMORY, or STABILITY |
|
|
456
|
+
|
|
457
|
+
### Database Backup & Restore
|
|
458
|
+
|
|
459
|
+
| Tool | Description | Requires |
|
|
460
|
+
|------|-------------|----------|
|
|
461
|
+
| `backup_table` | Backup single table to SQL dump | `utility` |
|
|
462
|
+
| `backup_database` | Backup entire database to SQL dump | `utility` |
|
|
463
|
+
| `restore_from_sql` | Restore from SQL dump content | `ddl` |
|
|
464
|
+
| `get_create_table_statement` | Get CREATE TABLE statement | `list` |
|
|
465
|
+
| `get_database_schema` | Get complete database schema | `list` |
|
|
466
|
+
|
|
467
|
+
### Data Import/Export
|
|
468
|
+
|
|
469
|
+
| Tool | Description | Requires |
|
|
470
|
+
|------|-------------|----------|
|
|
471
|
+
| `export_table_to_json` | Export table to JSON format | `utility` |
|
|
472
|
+
| `export_query_to_json` | Export query results to JSON | `utility` |
|
|
473
|
+
| `export_table_to_sql` | Export to SQL INSERT statements | `utility` |
|
|
474
|
+
| `import_from_csv` | Import from CSV string | `create` |
|
|
475
|
+
| `import_from_json` | Import from JSON array | `create` |
|
|
476
|
+
|
|
477
|
+
### Data Migration
|
|
478
|
+
|
|
479
|
+
| Tool | Description | Requires |
|
|
480
|
+
|------|-------------|----------|
|
|
481
|
+
| `copy_table_data` | Copy data with optional column mapping | `create` |
|
|
482
|
+
| `move_table_data` | Move data (copy + delete source) | `create`, `delete` |
|
|
483
|
+
| `clone_table` | Clone table structure with optional data | `ddl` |
|
|
484
|
+
| `compare_table_structure` | Compare two table structures | `list` |
|
|
485
|
+
| `sync_table_data` | Sync data between tables | `update` |
|
|
486
|
+
|
|
487
|
+
### Schema Versioning & Migrations
|
|
488
|
+
|
|
489
|
+
| Tool | Description | Requires |
|
|
490
|
+
|------|-------------|----------|
|
|
491
|
+
| `init_migrations_table` | Initialize migrations tracking table | `ddl` |
|
|
492
|
+
| `create_migration` | Create migration with up/down SQL | `ddl` |
|
|
493
|
+
| `apply_migrations` | Apply pending migrations (dry-run support) | `ddl` |
|
|
494
|
+
| `rollback_migration` | Rollback by steps or version | `ddl` |
|
|
495
|
+
| `get_migration_status` | Get migration history and status | `list` |
|
|
496
|
+
| `get_schema_version` | Get current schema version | `list` |
|
|
497
|
+
| `validate_migrations` | Validate migrations for issues | `list` |
|
|
498
|
+
| `reset_failed_migration` | Reset failed migration to pending | `ddl` |
|
|
499
|
+
| `generate_migration_from_diff` | Generate migration from table diff | `ddl` |
|
|
500
|
+
|
|
501
|
+
---
|
|
502
|
+
|
|
267
503
|
## ποΈ DDL Operations
|
|
268
504
|
|
|
269
505
|
DDL (Data Definition Language) operations allow AI to create, modify, and delete tables.
|
package/README.md
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
**A production-ready Model Context Protocol (MCP) server for MySQL database integration with AI agents**
|
|
6
6
|
|
|
7
|
-
[](https://www.npmjs.com/package/@berthojoris/
|
|
8
|
-
[](https://www.npmjs.com/package/@berthojoris/mysql-mcp)
|
|
8
|
+
[](https://www.npmjs.com/package/@berthojoris/mysql-mcp)
|
|
9
9
|
[](https://opensource.org/licenses/MIT)
|
|
10
10
|
[](https://www.typescriptlang.org/)
|
|
11
11
|
[](https://modelcontextprotocol.io/)
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
```bash
|
|
22
22
|
# Run directly with npx (no installation needed)
|
|
23
|
-
npx @berthojoris/
|
|
23
|
+
npx @berthojoris/mysql-mcp mysql://user:pass@localhost:3306/mydb "list,read,utility"
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
Add to your AI agent config (`.mcp.json`, `.cursor/mcp.json`, etc.):
|
|
@@ -30,7 +30,7 @@ Add to your AI agent config (`.mcp.json`, `.cursor/mcp.json`, etc.):
|
|
|
30
30
|
"mcpServers": {
|
|
31
31
|
"mysql": {
|
|
32
32
|
"command": "npx",
|
|
33
|
-
"args": ["-y", "@berthojoris/
|
|
33
|
+
"args": ["-y", "@berthojoris/mysql-mcp", "mysql://user:pass@localhost:3306/mydb", "list,read,utility"]
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
}
|
|
@@ -79,13 +79,13 @@ Add to your AI agent config (`.mcp.json`, `.cursor/mcp.json`, etc.):
|
|
|
79
79
|
No installation required - run directly:
|
|
80
80
|
|
|
81
81
|
```bash
|
|
82
|
-
npx @berthojoris/
|
|
82
|
+
npx @berthojoris/mysql-mcp mysql://user:pass@localhost:3306/db "list,read,utility"
|
|
83
83
|
```
|
|
84
84
|
|
|
85
85
|
### Option 2: Global Installation
|
|
86
86
|
|
|
87
87
|
```bash
|
|
88
|
-
npm install -g @berthojoris/
|
|
88
|
+
npm install -g @berthojoris/mysql-mcp
|
|
89
89
|
mcp-mysql mysql://user:pass@localhost:3306/db "list,read,utility"
|
|
90
90
|
```
|
|
91
91
|
|
|
@@ -153,6 +153,7 @@ Most AI agents use a similar JSON configuration format. Use the appropriate conf
|
|
|
153
153
|
|
|
154
154
|
**Universal Configuration Template:**
|
|
155
155
|
|
|
156
|
+
**Option 1: Single-Layer (Permissions Only) - Simple Setup**
|
|
156
157
|
```json
|
|
157
158
|
{
|
|
158
159
|
"mcpServers": {
|
|
@@ -160,7 +161,7 @@ Most AI agents use a similar JSON configuration format. Use the appropriate conf
|
|
|
160
161
|
"command": "npx",
|
|
161
162
|
"args": [
|
|
162
163
|
"-y",
|
|
163
|
-
"@berthojoris/
|
|
164
|
+
"@berthojoris/mysql-mcp",
|
|
164
165
|
"mysql://user:password@localhost:3306/database",
|
|
165
166
|
"list,read,utility"
|
|
166
167
|
]
|
|
@@ -169,6 +170,26 @@ Most AI agents use a similar JSON configuration format. Use the appropriate conf
|
|
|
169
170
|
}
|
|
170
171
|
```
|
|
171
172
|
|
|
173
|
+
**Option 2: Dual-Layer (Permissions + Categories) - Recommended for Fine Control**
|
|
174
|
+
```json
|
|
175
|
+
{
|
|
176
|
+
"mcpServers": {
|
|
177
|
+
"mysql": {
|
|
178
|
+
"command": "npx",
|
|
179
|
+
"args": [
|
|
180
|
+
"-y",
|
|
181
|
+
"@berthojoris/mysql-mcp",
|
|
182
|
+
"mysql://user:password@localhost:3306/database",
|
|
183
|
+
"list,read,utility",
|
|
184
|
+
"database-discovery,data-read,schema-inspection"
|
|
185
|
+
]
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
> **π‘ Tip:** The dual-layer approach provides granular control. The 4th argument (permissions) controls broad access levels, while the 5th argument (categories) fine-tunes which specific tools are available.
|
|
192
|
+
|
|
172
193
|
<details>
|
|
173
194
|
<summary><strong>Multiple Database Configuration</strong></summary>
|
|
174
195
|
|
|
@@ -179,7 +200,7 @@ Most AI agents use a similar JSON configuration format. Use the appropriate conf
|
|
|
179
200
|
"command": "npx",
|
|
180
201
|
"args": [
|
|
181
202
|
"-y",
|
|
182
|
-
"@berthojoris/
|
|
203
|
+
"@berthojoris/mysql-mcp",
|
|
183
204
|
"mysql://reader:pass@prod-server:3306/prod_db",
|
|
184
205
|
"list,read,utility"
|
|
185
206
|
]
|
|
@@ -188,7 +209,7 @@ Most AI agents use a similar JSON configuration format. Use the appropriate conf
|
|
|
188
209
|
"command": "npx",
|
|
189
210
|
"args": [
|
|
190
211
|
"-y",
|
|
191
|
-
"@berthojoris/
|
|
212
|
+
"@berthojoris/mysql-mcp",
|
|
192
213
|
"mysql://root:pass@localhost:3306/dev_db",
|
|
193
214
|
"list,read,create,update,delete,execute,ddl,utility"
|
|
194
215
|
]
|
|
@@ -208,7 +229,7 @@ OpenAI Codex uses TOML format in `~/.codex/config.toml`.
|
|
|
208
229
|
**Quick setup via CLI:**
|
|
209
230
|
|
|
210
231
|
```bash
|
|
211
|
-
codex mcp add mysql -- npx -y @berthojoris/
|
|
232
|
+
codex mcp add mysql -- npx -y @berthojoris/mysql-mcp mysql://user:pass@localhost:3306/db list,read,utility
|
|
212
233
|
```
|
|
213
234
|
|
|
214
235
|
**Manual TOML configuration:**
|
|
@@ -216,7 +237,7 @@ codex mcp add mysql -- npx -y @berthojoris/mcp-mysql-server mysql://user:pass@lo
|
|
|
216
237
|
```toml
|
|
217
238
|
[mcp_servers.mysql]
|
|
218
239
|
command = "npx"
|
|
219
|
-
args = ["-y", "@berthojoris/
|
|
240
|
+
args = ["-y", "@berthojoris/mysql-mcp", "mysql://user:pass@localhost:3306/db", "list,read,utility"]
|
|
220
241
|
startup_timeout_sec = 20
|
|
221
242
|
```
|
|
222
243
|
|
|
@@ -228,7 +249,7 @@ startup_timeout_sec = 20
|
|
|
228
249
|
```toml
|
|
229
250
|
[mcp_servers.mysql]
|
|
230
251
|
command = "npx"
|
|
231
|
-
args = ["-y", "@berthojoris/
|
|
252
|
+
args = ["-y", "@berthojoris/mysql-mcp"]
|
|
232
253
|
|
|
233
254
|
[mcp_servers.mysql.env]
|
|
234
255
|
DB_HOST = "localhost"
|
|
@@ -245,13 +266,13 @@ MCP_PERMISSIONS = "list,read,utility"
|
|
|
245
266
|
# Production - Read Only
|
|
246
267
|
[mcp_servers.mysql-prod]
|
|
247
268
|
command = "npx"
|
|
248
|
-
args = ["-y", "@berthojoris/
|
|
269
|
+
args = ["-y", "@berthojoris/mysql-mcp", "mysql://reader:pass@prod:3306/prod_db", "list,read,utility"]
|
|
249
270
|
startup_timeout_sec = 30
|
|
250
271
|
|
|
251
272
|
# Development - Full Access
|
|
252
273
|
[mcp_servers.mysql-dev]
|
|
253
274
|
command = "npx"
|
|
254
|
-
args = ["-y", "@berthojoris/
|
|
275
|
+
args = ["-y", "@berthojoris/mysql-mcp", "mysql://root:pass@localhost:3306/dev_db", "list,read,create,update,delete,execute,ddl,utility"]
|
|
255
276
|
```
|
|
256
277
|
|
|
257
278
|
**Advanced options:**
|
|
@@ -259,7 +280,7 @@ args = ["-y", "@berthojoris/mcp-mysql-server", "mysql://root:pass@localhost:3306
|
|
|
259
280
|
```toml
|
|
260
281
|
[mcp_servers.mysql]
|
|
261
282
|
command = "npx"
|
|
262
|
-
args = ["-y", "@berthojoris/
|
|
283
|
+
args = ["-y", "@berthojoris/mysql-mcp", "mysql://user:pass@localhost:3306/db", "list,read,utility"]
|
|
263
284
|
startup_timeout_sec = 20 # Server startup timeout (default: 10)
|
|
264
285
|
tool_timeout_sec = 120 # Per-tool execution timeout (default: 60)
|
|
265
286
|
enabled = true # Set false to disable without deleting
|
|
@@ -292,7 +313,7 @@ Zed IDE uses a different structure in `~/.config/zed/settings.json`:
|
|
|
292
313
|
"path": "npx",
|
|
293
314
|
"args": [
|
|
294
315
|
"-y",
|
|
295
|
-
"@berthojoris/
|
|
316
|
+
"@berthojoris/mysql-mcp",
|
|
296
317
|
"mysql://user:password@localhost:3306/database",
|
|
297
318
|
"list,read,utility"
|
|
298
319
|
]
|
|
@@ -313,7 +334,7 @@ Alternative approach using environment variables instead of connection string:
|
|
|
313
334
|
"mcpServers": {
|
|
314
335
|
"mysql": {
|
|
315
336
|
"command": "npx",
|
|
316
|
-
"args": ["-y", "@berthojoris/
|
|
337
|
+
"args": ["-y", "@berthojoris/mysql-mcp"],
|
|
317
338
|
"env": {
|
|
318
339
|
"DB_HOST": "localhost",
|
|
319
340
|
"DB_PORT": "3306",
|
|
@@ -565,261 +586,34 @@ The MCP server provides **119 powerful tools** organized into categories:
|
|
|
565
586
|
|
|
566
587
|
### Quick Reference
|
|
567
588
|
|
|
589
|
+
**119 Tools Available** - Organized into 22 categories
|
|
590
|
+
|
|
568
591
|
| Category | Count | Key Tools |
|
|
569
592
|
|----------|-------|-----------|
|
|
570
|
-
|
|
|
571
|
-
|
|
|
572
|
-
|
|
|
573
|
-
|
|
|
574
|
-
|
|
|
575
|
-
|
|
|
576
|
-
|
|
|
577
|
-
|
|
|
578
|
-
|
|
|
579
|
-
|
|
|
580
|
-
|
|
|
581
|
-
|
|
|
582
|
-
|
|
|
583
|
-
|
|
|
584
|
-
|
|
|
585
|
-
|
|
|
586
|
-
|
|
|
587
|
-
|
|
|
588
|
-
|
|
|
589
|
-
|
|
|
590
|
-
|
|
|
591
|
-
|
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
### Database Discovery
|
|
596
|
-
|
|
597
|
-
| Tool | Description |
|
|
598
|
-
|------|-------------|
|
|
599
|
-
| `list_databases` | Lists all databases on the MySQL server |
|
|
600
|
-
| `list_tables` | Lists all tables in the current/specified database |
|
|
601
|
-
| `read_table_schema` | Gets detailed schema (columns, types, keys, indexes) |
|
|
602
|
-
| `get_table_relationships` | Discovers foreign key relationships |
|
|
603
|
-
|
|
604
|
-
### Data Operations - CRUD
|
|
605
|
-
|
|
606
|
-
| Tool | Description |
|
|
607
|
-
|------|-------------|
|
|
608
|
-
| `create_record` | Insert new records with automatic SQL generation |
|
|
609
|
-
| `read_records` | Query records with filtering, pagination, and sorting |
|
|
610
|
-
| `update_record` | Update records based on conditions |
|
|
611
|
-
| `delete_record` | Delete records with safety checks |
|
|
612
|
-
|
|
613
|
-
### Bulk Operations
|
|
614
|
-
|
|
615
|
-
| Tool | Description | Performance |
|
|
616
|
-
|------|-------------|-------------|
|
|
617
|
-
| `bulk_insert` | Insert multiple records in batches | Up to 10,000 records/batch |
|
|
618
|
-
| `bulk_update` | Update multiple records with different conditions | Up to 1,000 ops/batch |
|
|
619
|
-
| `bulk_delete` | Delete multiple record sets | Up to 1,000 ops/batch |
|
|
620
|
-
|
|
621
|
-
### Custom Queries
|
|
622
|
-
|
|
623
|
-
| Tool | Description |
|
|
624
|
-
|------|-------------|
|
|
625
|
-
| `run_query` | Execute read-only SELECT queries |
|
|
626
|
-
| `execute_sql` | Execute write operations (INSERT, UPDATE, DELETE, or DDL) |
|
|
627
|
-
|
|
628
|
-
### Schema Management - DDL
|
|
629
|
-
|
|
630
|
-
| Tool | Description | Requires |
|
|
631
|
-
|------|-------------|----------|
|
|
632
|
-
| `create_table` | Create new tables with columns and indexes | `ddl` |
|
|
633
|
-
| `alter_table` | Modify table structure | `ddl` |
|
|
634
|
-
| `drop_table` | Delete tables | `ddl` |
|
|
635
|
-
| `execute_ddl` | Execute raw DDL SQL | `ddl` |
|
|
636
|
-
|
|
637
|
-
### Utilities
|
|
638
|
-
|
|
639
|
-
| Tool | Description |
|
|
640
|
-
|------|-------------|
|
|
641
|
-
| `test_connection` | Test database connectivity and measure latency |
|
|
642
|
-
| `describe_connection` | Get current connection information |
|
|
643
|
-
| `export_table_to_csv` | Export table data to CSV format |
|
|
644
|
-
| `export_query_to_csv` | Export query results to CSV format |
|
|
645
|
-
|
|
646
|
-
### Transaction Management
|
|
647
|
-
|
|
648
|
-
| Tool | Description |
|
|
649
|
-
|------|-------------|
|
|
650
|
-
| `begin_transaction` | Start a new database transaction |
|
|
651
|
-
| `commit_transaction` | Commit the current transaction |
|
|
652
|
-
| `rollback_transaction` | Rollback the current transaction |
|
|
653
|
-
| `get_transaction_status` | Check if a transaction is active |
|
|
654
|
-
| `execute_in_transaction` | Execute SQL within a transaction context |
|
|
655
|
-
|
|
656
|
-
### Stored Procedures
|
|
657
|
-
|
|
658
|
-
| Tool | Description | Requires |
|
|
659
|
-
|------|-------------|----------|
|
|
660
|
-
| `list_stored_procedures` | List all stored procedures | `procedure` |
|
|
661
|
-
| `create_stored_procedure` | Create new stored procedures | `procedure` |
|
|
662
|
-
| `get_stored_procedure_info` | Get procedure details | `procedure` |
|
|
663
|
-
| `execute_stored_procedure` | Execute with IN/OUT/INOUT params | `procedure` |
|
|
664
|
-
| `drop_stored_procedure` | Delete stored procedures | `procedure` |
|
|
665
|
-
| `show_create_procedure` | Show CREATE statement | `procedure` |
|
|
666
|
-
|
|
667
|
-
### Views Management
|
|
668
|
-
|
|
669
|
-
| Tool | Description | Requires |
|
|
670
|
-
|------|-------------|----------|
|
|
671
|
-
| `list_views` | List all views in the database | `list` |
|
|
672
|
-
| `get_view_info` | Get detailed view information | `list` |
|
|
673
|
-
| `create_view` | Create a new view | `ddl` |
|
|
674
|
-
| `alter_view` | Alter an existing view | `ddl` |
|
|
675
|
-
| `drop_view` | Drop a view | `ddl` |
|
|
676
|
-
| `show_create_view` | Show CREATE statement | `list` |
|
|
677
|
-
|
|
678
|
-
### Triggers Management
|
|
679
|
-
|
|
680
|
-
| Tool | Description | Requires |
|
|
681
|
-
|------|-------------|----------|
|
|
682
|
-
| `list_triggers` | List all triggers | `list` |
|
|
683
|
-
| `get_trigger_info` | Get trigger details | `list` |
|
|
684
|
-
| `create_trigger` | Create a new trigger | `ddl` |
|
|
685
|
-
| `drop_trigger` | Drop a trigger | `ddl` |
|
|
686
|
-
| `show_create_trigger` | Show CREATE statement | `list` |
|
|
687
|
-
|
|
688
|
-
### Functions Management
|
|
689
|
-
|
|
690
|
-
| Tool | Description | Requires |
|
|
691
|
-
|------|-------------|----------|
|
|
692
|
-
| `list_functions` | List all user-defined functions | `list` |
|
|
693
|
-
| `get_function_info` | Get function details | `list` |
|
|
694
|
-
| `create_function` | Create a new function | `ddl` |
|
|
695
|
-
| `drop_function` | Drop a function | `ddl` |
|
|
696
|
-
| `show_create_function` | Show CREATE statement | `list` |
|
|
697
|
-
| `execute_function` | Execute and return result | `read` |
|
|
698
|
-
|
|
699
|
-
### Index Management
|
|
700
|
-
|
|
701
|
-
| Tool | Description | Requires |
|
|
702
|
-
|------|-------------|----------|
|
|
703
|
-
| `list_indexes` | List all indexes for a table | `list` |
|
|
704
|
-
| `get_index_info` | Get index details | `list` |
|
|
705
|
-
| `create_index` | Create index (BTREE, HASH, FULLTEXT, SPATIAL) | `ddl` |
|
|
706
|
-
| `drop_index` | Drop an index | `ddl` |
|
|
707
|
-
| `analyze_index` | Analyze index statistics | `utility` |
|
|
708
|
-
|
|
709
|
-
### Constraint Management
|
|
710
|
-
|
|
711
|
-
| Tool | Description | Requires |
|
|
712
|
-
|------|-------------|----------|
|
|
713
|
-
| `list_foreign_keys` | List all foreign keys | `list` |
|
|
714
|
-
| `list_constraints` | List all constraints (PK, FK, UNIQUE, CHECK) | `list` |
|
|
715
|
-
| `add_foreign_key` | Add a foreign key constraint | `ddl` |
|
|
716
|
-
| `drop_foreign_key` | Drop a foreign key | `ddl` |
|
|
717
|
-
| `add_unique_constraint` | Add a unique constraint | `ddl` |
|
|
718
|
-
| `drop_constraint` | Drop UNIQUE or CHECK constraint | `ddl` |
|
|
719
|
-
| `add_check_constraint` | Add CHECK constraint (MySQL 8.0.16+) | `ddl` |
|
|
720
|
-
|
|
721
|
-
### Table Maintenance
|
|
722
|
-
|
|
723
|
-
| Tool | Description | Requires |
|
|
724
|
-
|------|-------------|----------|
|
|
725
|
-
| `analyze_table` | Update index statistics | `utility` |
|
|
726
|
-
| `optimize_table` | Reclaim space and defragment | `utility` |
|
|
727
|
-
| `check_table` | Check table for errors | `utility` |
|
|
728
|
-
| `repair_table` | Repair corrupted table | `utility` |
|
|
729
|
-
| `truncate_table` | Remove all rows quickly | `ddl` |
|
|
730
|
-
| `get_table_status` | Get table status and statistics | `list` |
|
|
731
|
-
| `flush_table` | Close and reopen table(s) | `utility` |
|
|
732
|
-
| `get_table_size` | Get size information | `list` |
|
|
733
|
-
|
|
734
|
-
### Process & Server Management
|
|
735
|
-
|
|
736
|
-
| Tool | Description | Requires |
|
|
737
|
-
|------|-------------|----------|
|
|
738
|
-
| `show_process_list` | Show running MySQL processes | `utility` |
|
|
739
|
-
| `kill_process` | Kill a MySQL process/connection | `utility` |
|
|
740
|
-
| `show_status` | Show server status variables | `utility` |
|
|
741
|
-
| `show_variables` | Show server configuration | `utility` |
|
|
742
|
-
| `explain_query` | Show query execution plan | `utility` |
|
|
743
|
-
| `show_engine_status` | Show storage engine status | `utility` |
|
|
744
|
-
| `get_server_info` | Get comprehensive server info | `utility` |
|
|
745
|
-
| `show_binary_logs` | Show binary log files | `utility` |
|
|
746
|
-
| `show_replication_status` | Show replication status | `utility` |
|
|
747
|
-
|
|
748
|
-
### Performance Monitoring
|
|
749
|
-
|
|
750
|
-
| Tool | Description | Requires |
|
|
751
|
-
|------|-------------|----------|
|
|
752
|
-
| `get_performance_metrics` | Get comprehensive performance metrics | `utility` |
|
|
753
|
-
| `get_top_queries_by_time` | Find slowest queries by execution time | `utility` |
|
|
754
|
-
| `get_top_queries_by_count` | Find most frequently executed queries | `utility` |
|
|
755
|
-
| `get_slow_queries` | Identify queries exceeding time threshold | `utility` |
|
|
756
|
-
| `get_table_io_stats` | Monitor table I/O operations | `utility` |
|
|
757
|
-
| `get_index_usage_stats` | Track index usage statistics | `utility` |
|
|
758
|
-
| `get_unused_indexes` | Identify unused indexes | `utility` |
|
|
759
|
-
| `get_connection_pool_stats` | Monitor connection pool health | `utility` |
|
|
760
|
-
| `get_database_health_check` | Comprehensive health assessment | `utility` |
|
|
761
|
-
| `reset_performance_stats` | Reset performance schema statistics | `utility` |
|
|
762
|
-
|
|
763
|
-
### Cache Management
|
|
764
|
-
|
|
765
|
-
| Tool | Description |
|
|
766
|
-
|------|-------------|
|
|
767
|
-
| `get_cache_stats` | Get query cache statistics |
|
|
768
|
-
| `get_cache_config` | Get current cache configuration |
|
|
769
|
-
| `configure_cache` | Configure cache settings |
|
|
770
|
-
| `clear_cache` | Clear all cached results |
|
|
771
|
-
| `invalidate_table_cache` | Invalidate cache for specific table |
|
|
772
|
-
|
|
773
|
-
### Query Optimization
|
|
774
|
-
|
|
775
|
-
| Tool | Description |
|
|
776
|
-
|------|-------------|
|
|
777
|
-
| `analyze_query` | Analyze query and get optimization suggestions |
|
|
778
|
-
| `get_optimization_hints` | Get optimizer hints for SPEED, MEMORY, or STABILITY |
|
|
779
|
-
|
|
780
|
-
### Database Backup & Restore
|
|
781
|
-
|
|
782
|
-
| Tool | Description | Requires |
|
|
783
|
-
|------|-------------|----------|
|
|
784
|
-
| `backup_table` | Backup single table to SQL dump | `utility` |
|
|
785
|
-
| `backup_database` | Backup entire database to SQL dump | `utility` |
|
|
786
|
-
| `restore_from_sql` | Restore from SQL dump content | `ddl` |
|
|
787
|
-
| `get_create_table_statement` | Get CREATE TABLE statement | `list` |
|
|
788
|
-
| `get_database_schema` | Get complete database schema | `list` |
|
|
789
|
-
|
|
790
|
-
### Data Import/Export
|
|
791
|
-
|
|
792
|
-
| Tool | Description | Requires |
|
|
793
|
-
|------|-------------|----------|
|
|
794
|
-
| `export_table_to_json` | Export table to JSON format | `utility` |
|
|
795
|
-
| `export_query_to_json` | Export query results to JSON | `utility` |
|
|
796
|
-
| `export_table_to_sql` | Export to SQL INSERT statements | `utility` |
|
|
797
|
-
| `import_from_csv` | Import from CSV string | `create` |
|
|
798
|
-
| `import_from_json` | Import from JSON array | `create` |
|
|
799
|
-
|
|
800
|
-
### Data Migration
|
|
801
|
-
|
|
802
|
-
| Tool | Description | Requires |
|
|
803
|
-
|------|-------------|----------|
|
|
804
|
-
| `copy_table_data` | Copy data with optional column mapping | `create` |
|
|
805
|
-
| `move_table_data` | Move data (copy + delete source) | `create`, `delete` |
|
|
806
|
-
| `clone_table` | Clone table structure with optional data | `ddl` |
|
|
807
|
-
| `compare_table_structure` | Compare two table structures | `list` |
|
|
808
|
-
| `sync_table_data` | Sync data between tables | `update` |
|
|
809
|
-
|
|
810
|
-
### Schema Versioning & Migrations
|
|
811
|
-
|
|
812
|
-
| Tool | Description | Requires |
|
|
813
|
-
|------|-------------|----------|
|
|
814
|
-
| `init_migrations_table` | Initialize migrations tracking table | `ddl` |
|
|
815
|
-
| `create_migration` | Create migration with up/down SQL | `ddl` |
|
|
816
|
-
| `apply_migrations` | Apply pending migrations (dry-run support) | `ddl` |
|
|
817
|
-
| `rollback_migration` | Rollback by steps or version | `ddl` |
|
|
818
|
-
| `get_migration_status` | Get migration history and status | `list` |
|
|
819
|
-
| `get_schema_version` | Get current schema version | `list` |
|
|
820
|
-
| `validate_migrations` | Validate migrations for issues | `list` |
|
|
821
|
-
| `reset_failed_migration` | Reset failed migration to pending | `ddl` |
|
|
822
|
-
| `generate_migration_from_diff` | Generate migration from table diff | `ddl` |
|
|
593
|
+
| Database Discovery | 4 | `list_databases`, `list_tables`, `read_table_schema` |
|
|
594
|
+
| CRUD Operations | 4 | `create_record`, `read_records`, `update_record`, `delete_record` |
|
|
595
|
+
| Bulk Operations | 3 | `bulk_insert`, `bulk_update`, `bulk_delete` |
|
|
596
|
+
| Custom Queries | 2 | `run_query`, `execute_sql` |
|
|
597
|
+
| Schema Management | 4 | `create_table`, `alter_table`, `drop_table` |
|
|
598
|
+
| Transactions | 5 | `begin_transaction`, `commit_transaction`, `rollback_transaction` |
|
|
599
|
+
| Stored Procedures | 6 | `create_stored_procedure`, `execute_stored_procedure` |
|
|
600
|
+
| Views | 6 | `create_view`, `alter_view`, `drop_view` |
|
|
601
|
+
| Triggers | 5 | `create_trigger`, `drop_trigger` |
|
|
602
|
+
| Functions | 6 | `create_function`, `execute_function` |
|
|
603
|
+
| Indexes | 5 | `create_index`, `drop_index`, `analyze_index` |
|
|
604
|
+
| Constraints | 7 | `add_foreign_key`, `add_unique_constraint` |
|
|
605
|
+
| Table Maintenance | 8 | `analyze_table`, `optimize_table`, `repair_table` |
|
|
606
|
+
| Server Management | 9 | `show_process_list`, `explain_query` |
|
|
607
|
+
| Performance Monitoring | 10 | `get_performance_metrics`, `get_database_health_check` |
|
|
608
|
+
| Cache | 5 | `get_cache_stats`, `clear_cache` |
|
|
609
|
+
| Query Optimization | 2 | `analyze_query`, `get_optimization_hints` |
|
|
610
|
+
| Backup & Restore | 5 | `backup_database`, `restore_from_sql` |
|
|
611
|
+
| Import/Export | 5 | `export_table_to_json`, `import_from_csv` |
|
|
612
|
+
| Data Migration | 5 | `copy_table_data`, `sync_table_data` |
|
|
613
|
+
| Schema Migrations | 9 | `create_migration`, `apply_migrations` |
|
|
614
|
+
| Utilities | 4 | `test_connection`, `export_table_to_csv` |
|
|
615
|
+
|
|
616
|
+
> **π For detailed tool descriptions, parameters, and examples, see [DOCUMENTATIONS.md](DOCUMENTATIONS.md#π§-complete-tools-reference)**
|
|
823
617
|
|
|
824
618
|
---
|
|
825
619
|
|
|
@@ -872,6 +666,6 @@ MIT License - see [LICENSE](LICENSE) file for details.
|
|
|
872
666
|
|
|
873
667
|
*Enabling AI agents to interact with MySQL databases safely and efficiently*
|
|
874
668
|
|
|
875
|
-
[Report Bug](https://github.com/berthojoris/
|
|
669
|
+
[Report Bug](https://github.com/berthojoris/mysql-mcp/issues) Β· [Request Feature](https://github.com/berthojoris/mysql-mcp/issues) Β· [Documentation](DOCUMENTATIONS.md)
|
|
876
670
|
|
|
877
671
|
</div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@berthojoris/mcp-mysql-server",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.2",
|
|
4
4
|
"description": "Model Context Protocol server for MySQL database integration with dynamic per-project permissions, backup/restore, data import/export, and data migration capabilities",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|