@berthojoris/mcp-mysql-server 1.4.7 → 1.4.13

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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # MySQL MCP Server
1
+ # MySQL MCP Server
2
2
 
3
3
  A fully-featured **Model Context Protocol (MCP)** server for MySQL database integration with AI agents like Claude Desktop, Cline, Windsurf, and other MCP-compatible tools.
4
4
 
@@ -7,21 +7,21 @@ A fully-featured **Model Context Protocol (MCP)** server for MySQL database inte
7
7
 
8
8
  ---
9
9
 
10
- ## 🌟 Features
10
+ ## 🌟 Features
11
11
 
12
- - **Full MCP Protocol Support** - Works with Claude Desktop, Cline, Windsurf, and any MCP-compatible AI agent
13
- - 🔒 **Secure by Default** - Parameterized queries, SQL injection protection, permission-based access control
14
- - 🛠️ **30 Powerful Tools** - Complete database operations (CRUD, DDL, queries, schema inspection, transactions, stored procedures, bulk operations)
15
- - 🎛️ **Dynamic Per-Project Permissions** - Each AI agent can have different access levels
16
- - 🏗️ **DDL Support** - Create, alter, and drop tables (when explicitly enabled)
17
- - 💰 **Transaction Support** - Full ACID transaction management (BEGIN, COMMIT, ROLLBACK)
18
- - 🌐 **Dual Mode** - Run as MCP server OR as REST API
19
- - 📊 **Rich Metadata** - Table schemas, relationships, connection info
20
- - **TypeScript** - Fully typed with TypeScript definitions
12
+ - ✅ **Full MCP Protocol Support** - Works with Claude Desktop, Cline, Windsurf, and any MCP-compatible AI agent
13
+ - 🔒 **Secure by Default** - Parameterized queries, SQL injection protection, permission-based access control
14
+ - 🛠️ **30 Powerful Tools** - Complete database operations (CRUD, DDL, queries, schema inspection, transactions, stored procedures, bulk operations)
15
+ - 🎛️ **Dynamic Per-Project Permissions** - Each AI agent can have different access levels
16
+ - 🏗️ **DDL Support** - Create, alter, and drop tables (when explicitly enabled)
17
+ - 💰 **Transaction Support** - Full ACID transaction management (BEGIN, COMMIT, ROLLBACK)
18
+ - 🌐 **Dual Mode** - Run as MCP server OR as REST API
19
+ - 📊 **Rich Metadata** - Table schemas, relationships, connection info
20
+ - âš¡ **TypeScript** - Fully typed with TypeScript definitions
21
21
 
22
22
  ---
23
23
 
24
- ## 📦 Installation
24
+ ## 📦 Installation
25
25
 
26
26
  ### Option 1: Quick Start (npx)
27
27
 
@@ -40,7 +40,7 @@ mcp-mysql mysql://user:pass@localhost:3306/db "list,read,utility"
40
40
 
41
41
  ---
42
42
 
43
- ## 🚀 Quick Start
43
+ ## 🚀 Quick Start
44
44
 
45
45
  ### 1. Set Up Environment
46
46
 
@@ -89,6 +89,46 @@ npm run build
89
89
  }
90
90
  ```
91
91
 
92
+ **Configuration (using local path - for development):**
93
+
94
+ ```json
95
+ {
96
+ "mcpServers": {
97
+ "mysql": {
98
+ "command": "node",
99
+ "args": [
100
+ "C:\\DEKSTOP\\MCP\\mcp_mysql\\bin\\mcp-mysql.js",
101
+ "mysql://user:password@localhost:3306/database",
102
+ "list,read,utility"
103
+ ]
104
+ }
105
+ }
106
+ }
107
+ ```
108
+
109
+ **Configuration (using environment variables - alternative local approach):**
110
+
111
+ ```json
112
+ {
113
+ "mcpServers": {
114
+ "mysql": {
115
+ "command": "node",
116
+ "args": [
117
+ "C:\\DEKSTOP\\MCP\\mcp_mysql\\dist\\mcp-server.js"
118
+ ],
119
+ "env": {
120
+ "DB_HOST": "localhost",
121
+ "DB_PORT": "3306",
122
+ "DB_USER": "root",
123
+ "DB_PASSWORD": "",
124
+ "DB_NAME": "your_database",
125
+ "MCP_PERMISSIONS": "list,read,utility"
126
+ }
127
+ }
128
+ }
129
+ }
130
+ ```
131
+
92
132
  #### Cline (VS Code Extension)
93
133
 
94
134
  Add to Cline MCP settings (same JSON format as Claude Desktop).
@@ -111,6 +151,82 @@ Try asking your AI:
111
151
 
112
152
  ---
113
153
 
154
+ ## Local vs NPX Configuration
155
+
156
+ ### When to Use Local Path Configuration
157
+
158
+ Use the local path approach when you:
159
+ - **Want full control** over the version and source code
160
+ - **Need offline access** without internet dependency
161
+ - **Want to modify the source** for custom functionality
162
+ - **Need faster startup** without package download
163
+ - **Are developing/debugging** the MCP server
164
+ - **Have network restrictions** or security policies
165
+
166
+ ### Local Configuration Benefits
167
+
168
+ | Feature | Local Path | NPX |
169
+ |---------|------------|-----|
170
+ | **Control** | Full control over code | Depends on npm registry |
171
+ | **Offline** | Works completely offline | Requires internet download |
172
+ | **Speed** | Instant startup | Download time |
173
+ | **Customization** | Can modify source code | Limited to published version |
174
+ | **Debugging** | Full source access available | Limited debugging |
175
+ | **Updates** | Manual updates | Automatic updates |
176
+ | **Setup** | Requires building project | Zero setup |
177
+
178
+ ### Local Setup Requirements
179
+
180
+ 1. **Build the project:**
181
+ ```bash
182
+ cd "C:\DEKSTOP\MCP\mcp_mysql"
183
+ npm run build
184
+ ```
185
+
186
+ 2. **Ensure paths are absolute** - Use full paths to avoid ambiguity
187
+ 3. **Use correct binaries:**
188
+ - `bin/mcp-mysql.js` - CLI wrapper with argument parsing
189
+ - `dist/mcp-server.js` - Direct server executable
190
+
191
+ ### Common Local Configuration Patterns
192
+
193
+ **Direct binary with arguments:**
194
+ ```json
195
+ {
196
+ "command": "node",
197
+ "args": [
198
+ "C:\\DEKSTOP\\MCP\\mcp_mysql\\bin\\mcp-mysql.js",
199
+ "mysql://user:pass@localhost:3306/database",
200
+ "permissions"
201
+ ]
202
+ }
203
+ ```
204
+
205
+ **Direct server with environment variables:**
206
+ ```json
207
+ {
208
+ "command": "node",
209
+ "args": ["C:\\DEKSTOP\\MCP\\mcp_mysql\\dist\\mcp-server.js"],
210
+ "env": {
211
+ "DB_HOST": "localhost",
212
+ "DB_PORT": "3306",
213
+ "DB_USER": "root",
214
+ "DB_PASSWORD": "",
215
+ "DB_NAME": "database",
216
+ "MCP_PERMISSIONS": "permissions"
217
+ }
218
+ }
219
+ ```
220
+
221
+ ### Path Tips
222
+
223
+ - **Windows paths:** Use double backslashes `\\` in JSON
224
+ - **Cross-platform:** Use forward slashes `/` if supported by your AI agent
225
+ - **Environment variables:** Can use `%USERPROFILE%` or `$HOME` in some systems
226
+ - **Relative paths:** Not recommended - use absolute paths for reliability
227
+
228
+ ---
229
+
114
230
  ## Permission System
115
231
 
116
232
  ### Permission Categories
@@ -138,7 +254,7 @@ Control access with these permission categories:
138
254
  {
139
255
  "args": [
140
256
  "mysql://user:pass@localhost:3306/db",
141
- "list,read,utility" // Permissions here
257
+ "list,read,utility" // ← Permissions here
142
258
  ]
143
259
  }
144
260
  ```
@@ -179,6 +295,7 @@ list,ddl,utility
179
295
 
180
296
  You can have different databases with different permissions in the same AI agent:
181
297
 
298
+ **Using NPX:**
182
299
  ```json
183
300
  {
184
301
  "mcpServers": {
@@ -204,9 +321,33 @@ You can have different databases with different permissions in the same AI agent
204
321
  }
205
322
  ```
206
323
 
324
+ **Using Local Paths:**
325
+ ```json
326
+ {
327
+ "mcpServers": {
328
+ "mysql-prod": {
329
+ "command": "node",
330
+ "args": [
331
+ "C:\\DEKSTOP\\MCP\\mcp_mysql\\bin\\mcp-mysql.js",
332
+ "mysql://reader:pass@prod-server:3306/prod_db",
333
+ "list,read,utility"
334
+ ]
335
+ },
336
+ "mysql-dev": {
337
+ "command": "node",
338
+ "args": [
339
+ "C:\\DEKSTOP\\MCP\\mcp_mysql\\bin\\mcp-mysql.js",
340
+ "mysql://root:pass@localhost:3306/dev_db",
341
+ "list,read,create,update,delete,execute,ddl,utility"
342
+ ]
343
+ }
344
+ }
345
+ }
346
+ ```
347
+
207
348
  ---
208
349
 
209
- ## 🚫 Permission Error Handling
350
+ ## 🚫 Permission Error Handling
210
351
 
211
352
  The MySQL MCP Server provides clear, user-friendly error messages when operations are attempted without proper permissions. This helps users understand exactly what permissions are needed and how to enable them.
212
353
 
@@ -215,7 +356,7 @@ The MySQL MCP Server provides clear, user-friendly error messages when operation
215
356
  When a tool is called without the required permission, you'll receive a detailed error message like:
216
357
 
217
358
  ```
218
- Permission denied: Cannot use tool 'create_table'. This tool requires 'ddl' permission.
359
+ ❌ Permission denied: Cannot use tool 'create_table'. This tool requires 'ddl' permission.
219
360
 
220
361
  Current permissions: list,read,utility
221
362
  To enable this tool, add 'ddl' to your permissions configuration.
@@ -234,7 +375,7 @@ Tool description: Create new tables with columns and indexes
234
375
 
235
376
  **Error response when DDL not enabled:**
236
377
  ```
237
- Permission denied: Cannot use tool 'create_table'. This tool requires 'ddl' permission.
378
+ ❌ Permission denied: Cannot use tool 'create_table'. This tool requires 'ddl' permission.
238
379
 
239
380
  Current permissions: list,read,utility
240
381
  To enable this tool, add 'ddl' to your permissions configuration.
@@ -251,7 +392,7 @@ Tool description: Create new tables with columns and indexes
251
392
 
252
393
  **Error response when CREATE not enabled:**
253
394
  ```
254
- Permission denied: Cannot use tool 'create_record'. This tool requires 'create' permission.
395
+ ❌ Permission denied: Cannot use tool 'create_record'. This tool requires 'create' permission.
255
396
 
256
397
  Current permissions: list,read,utility
257
398
  To enable this tool, add 'create' to your permissions configuration.
@@ -268,7 +409,7 @@ Tool description: Insert new records with automatic SQL generation
268
409
 
269
410
  **Error response when UPDATE not enabled:**
270
411
  ```
271
- Permission denied: Cannot use tool 'update_record'. This tool requires 'update' permission.
412
+ ❌ Permission denied: Cannot use tool 'update_record'. This tool requires 'update' permission.
272
413
 
273
414
  Current permissions: list,read,utility
274
415
  To enable this tool, add 'update' to your permissions configuration.
@@ -281,11 +422,11 @@ Tool description: Update existing records based on conditions
281
422
 
282
423
  ### Permission Error Benefits
283
424
 
284
- 1. **🎯 Clear Guidance** - Exact permission needed and how to add it
285
- 2. **📋 Current State** - Shows what permissions are currently active
286
- 3. **💡 Example Configuration** - Ready-to-use configuration example
287
- 4. **📖 Tool Context** - Explains what the tool does
288
- 5. **🔒 Security** - Prevents unauthorized operations while being helpful
425
+ 1. **🎯 Clear Guidance** - Exact permission needed and how to add it
426
+ 2. **📋 Current State** - Shows what permissions are currently active
427
+ 3. **💡 Example Configuration** - Ready-to-use configuration example
428
+ 4. **📖 Tool Context** - Explains what the tool does
429
+ 5. **🔒 Security** - Prevents unauthorized operations while being helpful
289
430
 
290
431
  ### Troubleshooting Permission Errors
291
432
 
@@ -320,7 +461,7 @@ After (DDL enabled):
320
461
 
321
462
  ---
322
463
 
323
- ## 🛠️ Available Tools
464
+ ## 🛠️ Available Tools
324
465
 
325
466
  The MCP server provides **30 powerful tools**:
326
467
 
@@ -397,1117 +538,31 @@ The MCP server provides **30 powerful tools**:
397
538
 
398
539
  ---
399
540
 
400
- ## 🏗️ DDL Operations
401
-
402
- DDL (Data Definition Language) operations allow AI to create, modify, and delete tables.
403
-
404
- ### ⚠️ Enable DDL with Caution
405
-
406
- DDL operations are **disabled by default** for safety. Add `ddl` to permissions to enable:
407
-
408
- ```json
409
- {
410
- "args": [
411
- "mysql://user:pass@localhost:3306/db",
412
- "list,read,create,update,delete,ddl,utility"
413
- ]
414
- }
415
- ```
416
-
417
- ### DDL Tool Examples
418
-
419
- #### Create Table
420
-
421
- **User prompt:** *"Create a users table with id, username, email, and created_at"*
422
-
423
- **AI will execute:**
424
- ```json
425
- {
426
- "tool": "create_table",
427
- "arguments": {
428
- "table_name": "users",
429
- "columns": [
430
- {"name": "id", "type": "INT", "primary_key": true, "auto_increment": true},
431
- {"name": "username", "type": "VARCHAR(255)", "nullable": false},
432
- {"name": "email", "type": "VARCHAR(255)", "nullable": false},
433
- {"name": "created_at", "type": "DATETIME", "default": "CURRENT_TIMESTAMP"}
434
- ]
435
- }
436
- }
437
- ```
438
-
439
- #### Alter Table
440
-
441
- **User prompt:** *"Add a phone column to the users table"*
442
-
443
- **AI will execute:**
444
- ```json
445
- {
446
- "tool": "alter_table",
447
- "arguments": {
448
- "table_name": "users",
449
- "operations": [
450
- {
451
- "type": "add_column",
452
- "column_name": "phone",
453
- "column_type": "VARCHAR(20)",
454
- "nullable": true
455
- }
456
- ]
457
- }
458
- }
459
- ```
460
-
461
- #### Drop Table
462
-
463
- **User prompt:** *"Drop the temp_data table"*
464
-
465
- **AI will execute:**
466
- ```json
467
- {
468
- "tool": "drop_table",
469
- "arguments": {
470
- "table_name": "temp_data",
471
- "if_exists": true
472
- }
473
- }
474
- ```
475
-
476
- ### DDL Safety Guidelines
477
-
478
- 1. ✅ **Enable only in development** - Keep DDL disabled for production
479
- 2. ✅ **Backup before major changes** - DDL operations are usually irreversible
480
- 3. ✅ **Test in dev first** - Try schema changes in development environment
481
- 4. ✅ **Use proper MySQL user permissions** - Grant only necessary privileges
482
-
483
- ---
484
-
485
- ## 📤 Data Export Tools
486
-
487
- The MySQL MCP Server provides powerful data export capabilities, allowing AI agents to export database content in CSV format for analysis, reporting, and data sharing.
488
-
489
- ### Data Export Tools Overview
490
-
491
- - **`export_table_to_csv`** - Export all or filtered data from a table to CSV format
492
- - **`export_query_to_csv`** - Export the results of a custom SELECT query to CSV format
493
-
494
- Both tools support:
495
- - Filtering data with conditions
496
- - Pagination for large datasets
497
- - Sorting results
498
- - Optional column headers
499
- - Proper CSV escaping for special characters
500
-
501
- ### Data Export Tool Examples
502
-
503
- #### Export Table to CSV
504
-
505
- **User prompt:** *"Export the first 100 users ordered by registration date to CSV"*
506
-
507
- **AI will execute:**
508
- ```json
509
- {
510
- "tool": "export_table_to_csv",
511
- "arguments": {
512
- "table_name": "users",
513
- "sorting": {
514
- "field": "registration_date",
515
- "direction": "desc"
516
- },
517
- "pagination": {
518
- "page": 1,
519
- "limit": 100
520
- },
521
- "include_headers": true
522
- }
523
- }
524
- ```
525
-
526
- #### Export Filtered Data to CSV
527
-
528
- **User prompt:** *"Export all users from the marketing department to CSV"*
529
-
530
- **AI will execute:**
531
- ```json
532
- {
533
- "tool": "export_table_to_csv",
534
- "arguments": {
535
- "table_name": "users",
536
- "filters": [
537
- {
538
- "field": "department",
539
- "operator": "eq",
540
- "value": "marketing"
541
- }
542
- ],
543
- "include_headers": true
544
- }
545
- }
546
- ```
547
-
548
- #### Export Query Results to CSV
549
-
550
- **User prompt:** *"Export a report of total sales by product category to CSV"*
551
-
552
- **AI will execute:**
553
- ```json
554
- {
555
- "tool": "export_query_to_csv",
556
- "arguments": {
557
- "query": "SELECT category, SUM(sales_amount) as total_sales FROM sales GROUP BY category ORDER BY total_sales DESC",
558
- "include_headers": true
559
- }
560
- }
561
- ```
562
-
563
- ### Data Export Best Practices
564
-
565
- 1. ✅ **Use filtering** - Export only the data you need to reduce file size
566
- 2. ✅ **Implement pagination** - For large datasets, use pagination to avoid memory issues
567
- 3. ✅ **Include headers** - Make CSV files more understandable with column headers
568
- 4. ✅ **Test with small datasets first** - Verify export format before processing large amounts of data
569
- 5. ✅ **Use proper permissions** - Data export tools require `utility` permission
570
-
571
- ### Common Data Export Patterns
572
-
573
- **Pattern 1: Simple Table Export**
574
- ```json
575
- {
576
- "tool": "export_table_to_csv",
577
- "arguments": {
578
- "table_name": "products",
579
- "include_headers": true
580
- }
581
- }
582
- ```
583
-
584
- **Pattern 2: Filtered and Sorted Export**
585
- ```json
586
- {
587
- "tool": "export_table_to_csv",
588
- "arguments": {
589
- "table_name": "orders",
590
- "filters": [
591
- {
592
- "field": "order_date",
593
- "operator": "gte",
594
- "value": "2023-01-01"
595
- }
596
- ],
597
- "sorting": {
598
- "field": "order_date",
599
- "direction": "desc"
600
- },
601
- "include_headers": true
602
- }
603
- }
604
- ```
605
-
606
- **Pattern 3: Complex Query Export**
607
- ```json
608
- {
609
- "tool": "export_query_to_csv",
610
- "arguments": {
611
- "query": "SELECT u.name, u.email, COUNT(o.id) as order_count FROM users u LEFT JOIN orders o ON u.id = o.user_id GROUP BY u.id HAVING order_count > 5",
612
- "include_headers": true
613
- }
614
- }
615
- ```
616
-
617
- ---
618
-
619
- ## 💰 Transaction Management
620
-
621
- The MySQL MCP Server provides full ACID transaction support, allowing you to group multiple database operations into atomic units.
622
-
623
- ### Transaction Tools Overview
624
-
625
- - **`begin_transaction`** - Start a new transaction
626
- - **`execute_in_transaction`** - Execute SQL within transaction context
627
- - **`commit_transaction`** - Permanently save all changes
628
- - **`rollback_transaction`** - Discard all changes since transaction start
629
- - **`get_transaction_status`** - Check if transaction is active
630
-
631
- ### Transaction Example: Money Transfer
632
-
633
- **User:** *"Transfer $100 from Alice's account to Bob's account"*
634
-
635
- **AI executes:**
636
- ```json
637
- // Step 1: Begin transaction
638
- {
639
- "tool": "begin_transaction"
640
- }
641
-
642
- // Step 2: Deduct from Alice's account
643
- {
644
- "tool": "execute_in_transaction",
645
- "arguments": {
646
- "sql": "UPDATE accounts SET balance = balance - 100 WHERE name = 'Alice'"
647
- }
648
- }
649
-
650
- // Step 3: Add to Bob's account
651
- {
652
- "tool": "execute_in_transaction",
653
- "arguments": {
654
- "sql": "UPDATE accounts SET balance = balance + 100 WHERE name = 'Bob'"
655
- }
656
- }
657
-
658
- // Step 4: Verify both accounts exist and have sufficient funds
659
- {
660
- "tool": "execute_in_transaction",
661
- "arguments": {
662
- "sql": "SELECT * FROM accounts WHERE name IN ('Alice', 'Bob')"
663
- }
664
- }
665
-
666
- // Step 5: Commit if everything is valid
667
- {
668
- "tool": "commit_transaction"
669
- }
670
- ```
671
-
672
- ### Transaction Safety Features
673
-
674
- 1. ✅ **Atomic Operations** - All operations succeed or all fail together
675
- 2. ✅ **Automatic Rollback** - If any operation fails, transaction automatically rolls back
676
- 3. ✅ **Isolation** - Other sessions see changes only after commit
677
- 4. ✅ **Status Checking** - Always know if a transaction is active
678
- 5. ✅ **Error Handling** - Comprehensive error reporting for failed operations
679
-
680
- ### Transaction Best Practices
681
-
682
- 1. **Keep transactions short** - Long transactions can block other operations
683
- 2. **Always commit or rollback** - Don't leave transactions hanging
684
- 3. **Test transaction logic** - Verify your transaction sequence works correctly
685
- 4. **Handle errors gracefully** - Check for errors after each operation
686
- 5. **Use appropriate isolation levels** - Understand your consistency requirements
687
-
688
- ### Common Transaction Patterns
689
-
690
- **Pattern 1: Safe Update with Verification**
691
- ```json
692
- // Begin transaction
693
- // Update records
694
- // Verify changes with SELECT
695
- // Commit if valid, rollback if not
696
- ```
697
-
698
- **Pattern 2: Batch Operations**
699
- ```json
700
- // Begin transaction
701
- // Insert multiple related records
702
- // Update related tables
703
- // Commit all changes together
704
- ```
705
-
706
- **Pattern 3: Error Recovery**
707
- ```json
708
- // Begin transaction
709
- // Try operations
710
- // If error occurs: rollback
711
- // If success: commit
712
- ```
713
-
714
- ---
715
-
716
- ## 🔧 Stored Procedures
717
-
718
- The MySQL MCP Server provides comprehensive stored procedure management, allowing you to create, execute, and manage stored procedures with full parameter support.
719
-
720
- ### Stored Procedure Tools Overview
721
-
722
- - **`list_stored_procedures`** - List all stored procedures in a database
723
- - **`create_stored_procedure`** - Create new stored procedures with IN/OUT/INOUT parameters
724
- - **`get_stored_procedure_info`** - Get detailed information about parameters and metadata
725
- - **`execute_stored_procedure`** - Execute procedures with automatic parameter handling
726
- - **`drop_stored_procedure`** - Delete stored procedures safely
727
-
728
- ### ⚠️ Enable Stored Procedures
729
-
730
- Stored procedure operations require the `procedure` permission. Add it to your configuration:
731
-
732
- ```json
733
- {
734
- "args": [
735
- "mysql://user:pass@localhost:3306/db",
736
- "list,read,procedure,utility" // ← Include 'procedure'
737
- ]
738
- }
739
- ```
740
-
741
- ### Creating Stored Procedures
742
-
743
- **User:** *"Create a stored procedure that calculates tax for a given amount"*
744
-
745
- **AI will execute:**
746
- ```json
747
- {
748
- "tool": "create_stored_procedure",
749
- "arguments": {
750
- "procedure_name": "calculate_tax",
751
- "parameters": [
752
- {
753
- "name": "amount",
754
- "mode": "IN",
755
- "data_type": "DECIMAL(10,2)"
756
- },
757
- {
758
- "name": "tax_rate",
759
- "mode": "IN",
760
- "data_type": "DECIMAL(5,4)"
761
- },
762
- {
763
- "name": "tax_amount",
764
- "mode": "OUT",
765
- "data_type": "DECIMAL(10,2)"
766
- }
767
- ],
768
- "body": "SET tax_amount = amount * tax_rate;",
769
- "comment": "Calculate tax amount based on amount and tax rate"
770
- }
771
- }
772
- ```
773
-
774
- ### Executing Stored Procedures
775
-
776
- **User:** *"Calculate tax for $1000 with 8.5% tax rate"*
777
-
778
- **AI will execute:**
779
- ```json
780
- {
781
- "tool": "execute_stored_procedure",
782
- "arguments": {
783
- "procedure_name": "calculate_tax",
784
- "parameters": [1000.00, 0.085]
785
- }
786
- }
787
- ```
788
-
789
- **Result:**
790
- ```json
791
- {
792
- "status": "success",
793
- "data": {
794
- "results": { /* execution results */ },
795
- "outputParameters": {
796
- "tax_amount": 85.00
797
- }
798
- }
799
- }
800
- ```
801
-
802
- ### Parameter Types
803
-
804
- **IN Parameters** - Input values passed to the procedure
805
- ```sql
806
- IN user_id INT
807
- IN email VARCHAR(255)
808
- ```
809
-
810
- **OUT Parameters** - Output values returned by the procedure
811
- ```sql
812
- OUT total_count INT
813
- OUT average_score DECIMAL(5,2)
814
- ```
815
-
816
- **INOUT Parameters** - Values that are both input and output
817
- ```sql
818
- INOUT running_total DECIMAL(10,2)
819
- ```
820
-
821
- ### Complex Stored Procedure Example
822
-
823
- **User:** *"Create a procedure to process an order with inventory check"*
824
-
825
- ```json
826
- {
827
- "tool": "create_stored_procedure",
828
- "arguments": {
829
- "procedure_name": "process_order",
830
- "parameters": [
831
- { "name": "product_id", "mode": "IN", "data_type": "INT" },
832
- { "name": "quantity", "mode": "IN", "data_type": "INT" },
833
- { "name": "customer_id", "mode": "IN", "data_type": "INT" },
834
- { "name": "order_id", "mode": "OUT", "data_type": "INT" },
835
- { "name": "success", "mode": "OUT", "data_type": "BOOLEAN" }
836
- ],
837
- "body": "DECLARE available_qty INT; SELECT stock_quantity INTO available_qty FROM products WHERE id = product_id; IF available_qty >= quantity THEN INSERT INTO orders (customer_id, product_id, quantity) VALUES (customer_id, product_id, quantity); SET order_id = LAST_INSERT_ID(); UPDATE products SET stock_quantity = stock_quantity - quantity WHERE id = product_id; SET success = TRUE; ELSE SET order_id = 0; SET success = FALSE; END IF;",
838
- "comment": "Process order with inventory validation"
839
- }
840
- }
841
- ```
842
-
843
- ### Getting Procedure Information
844
-
845
- **User:** *"Show me details about the calculate_tax procedure"*
846
-
847
- **AI will execute:**
848
- ```json
849
- {
850
- "tool": "get_stored_procedure_info",
851
- "arguments": {
852
- "procedure_name": "calculate_tax"
853
- }
854
- }
855
- ```
856
-
857
- **Returns detailed information:**
858
- - Procedure metadata (created date, security type, etc.)
859
- - Parameter details (names, types, modes)
860
- - Procedure definition
861
- - Comments and documentation
862
-
863
- ### Stored Procedure Best Practices
864
-
865
- 1. ✅ **Use descriptive names** - Make procedure purposes clear
866
- 2. ✅ **Document with comments** - Add meaningful comments to procedures
867
- 3. ✅ **Validate inputs** - Check parameter values within procedures
868
- 4. ✅ **Handle errors** - Use proper error handling in procedure bodies
869
- 5. ✅ **Test thoroughly** - Verify procedures work with various inputs
870
- 6. ✅ **Use appropriate data types** - Choose correct types for parameters
871
- 7. ✅ **Consider security** - Be mindful of SQL injection in dynamic SQL
872
-
873
- ### Common Stored Procedure Patterns
874
-
875
- **Pattern 1: Data Validation and Processing**
876
- ```sql
877
- -- Validate input, process if valid, return status
878
- IF input_value > 0 THEN
879
- -- Process data
880
- SET success = TRUE;
881
- ELSE
882
- SET success = FALSE;
883
- END IF;
884
- ```
885
-
886
- **Pattern 2: Complex Business Logic**
887
- ```sql
888
- -- Multi-step business process
889
- -- Step 1: Validate
890
- -- Step 2: Calculate
891
- -- Step 3: Update multiple tables
892
- -- Step 4: Return results
893
- ```
894
-
895
- **Pattern 3: Reporting and Analytics**
896
- ```sql
897
- -- Aggregate data from multiple tables
898
- -- Apply business rules
899
- -- Return calculated results
900
- ```
901
-
902
- ---
903
-
904
- ## 📋 Usage Examples
905
-
906
- ### Example 1: Read Data
907
-
908
- **User:** *"Show me the first 10 users ordered by created_at"*
909
-
910
- **AI uses `read_records`:**
911
- - Queries the users table
912
- - Applies pagination (limit 10)
913
- - Sorts by created_at descending
914
- - Returns results
915
-
916
- ### Example 2: Filter Data
917
-
918
- **User:** *"Find all users with email ending in @example.com"*
919
-
920
- **AI uses `read_records` with filters:**
921
- - Applies LIKE filter on email column
922
- - Returns matching records
923
-
924
- ### Example 3: Create Records
925
-
926
- **User:** *"Add a new user with username 'john_doe' and email 'john@example.com'"*
927
-
928
- **AI uses `create_record`:**
929
- - Inserts new record
930
- - Returns insert ID
931
-
932
- ### Example 4: Update Records
933
-
934
- **User:** *"Update the email for user ID 5 to 'newemail@example.com'"*
935
-
936
- **AI uses `update_record`:**
937
- - Updates specific record by ID
938
- - Returns affected rows
939
-
940
- ### Example 5: Complex Query
941
-
942
- **User:** *"Show me the total number of orders per user for the last 30 days"*
943
-
944
- **AI uses `run_query`:**
945
- - Constructs JOIN query
946
- - Applies date filter
947
- - Groups by user
948
- - Returns aggregated results
949
-
950
- ### Example 6: Transaction Management
951
-
952
- **User:** *"Transfer $100 from account 1 to account 2 in a single transaction"*
953
-
954
- **AI uses transaction tools:**
955
- ```json
956
- {
957
- "tool": "begin_transaction"
958
- }
959
-
960
- {
961
- "tool": "execute_in_transaction",
962
- "arguments": {
963
- "sql": "UPDATE accounts SET balance = balance - 100 WHERE id = 1"
964
- }
965
- }
966
-
967
- {
968
- "tool": "execute_in_transaction",
969
- "arguments": {
970
- "sql": "UPDATE accounts SET balance = balance + 100 WHERE id = 2"
971
- }
972
- }
973
-
974
- {
975
- "tool": "commit_transaction"
976
- }
977
- ```
978
-
979
- **User:** *"Check if there's an active transaction"*
980
-
981
- **AI uses `get_transaction_status`:**
982
- - Returns transaction status and ID if active
983
-
984
- ### Example 7: Bulk Insert
985
-
986
- **User:** *"Insert 1000 new products from this CSV data"*
987
-
988
- **AI uses `bulk_insert`:**
989
- ```json
990
- {
991
- "tool": "bulk_insert",
992
- "arguments": {
993
- "table_name": "products",
994
- "data": [
995
- {"name": "Product 1", "price": 19.99, "category": "Electronics"},
996
- {"name": "Product 2", "price": 29.99, "category": "Books"},
997
- // ... up to 1000 records
998
- ],
999
- "batch_size": 1000
1000
- }
1001
- }
1002
- ```
1003
- - Processes records in optimized batches
1004
- - Returns total inserted count and performance metrics
1005
-
1006
- ### Example 8: Bulk Update
1007
-
1008
- **User:** *"Update prices for all products in specific categories with different discounts"*
1009
-
1010
- **AI uses `bulk_update`:**
1011
- ```json
1012
- {
1013
- "tool": "bulk_update",
1014
- "arguments": {
1015
- "table_name": "products",
1016
- "updates": [
1017
- {
1018
- "data": {"price": "price * 0.9"},
1019
- "conditions": [{"field": "category", "operator": "eq", "value": "Electronics"}]
1020
- },
1021
- {
1022
- "data": {"price": "price * 0.8"},
1023
- "conditions": [{"field": "category", "operator": "eq", "value": "Books"}]
1024
- }
1025
- ],
1026
- "batch_size": 100
1027
- }
1028
- }
1029
- ```
1030
- - Applies different updates based on conditions
1031
- - Processes in batches for optimal performance
1032
-
1033
- ### Example 9: Bulk Delete
1034
-
1035
- **User:** *"Delete all inactive users and expired sessions"*
1036
-
1037
- **AI uses `bulk_delete`:**
1038
- ```json
1039
- {
1040
- "tool": "bulk_delete",
1041
- "arguments": {
1042
- "table_name": "users",
1043
- "condition_sets": [
1044
- [{"field": "status", "operator": "eq", "value": "inactive"}],
1045
- [{"field": "last_login", "operator": "lt", "value": "2023-01-01"}],
1046
- [{"field": "email_verified", "operator": "eq", "value": false}]
1047
- ],
1048
- "batch_size": 100
1049
- }
1050
- }
1051
- ```
1052
- - Deletes records matching any of the condition sets
1053
- - Processes deletions in safe batches
1054
-
1055
- **User:** *"Rollback the current transaction"*
1056
-
1057
- **AI uses `rollback_transaction`:**
1058
- - Cancels all changes in the current transaction
1059
-
1060
- ---
1061
-
1062
- ## 📝 Query Logging
1063
-
1064
- All queries executed through the MySQL MCP Server are automatically logged with detailed execution information. Query logs are included in the response output of all query and data manipulation operations.
1065
-
1066
- ### Query Log Information
1067
-
1068
- Each logged query includes:
1069
- - **Timestamp** - ISO 8601 formatted execution time
1070
- - **SQL Query** - The exact SQL statement executed
1071
- - **Parameters** - Values passed to the query (if any)
1072
- - **Execution Duration** - Time taken to execute in milliseconds
1073
- - **Status** - Success or error indication
1074
- - **Error Details** - Error message if the query failed (optional)
1075
-
1076
- ### Example Query Log Output
1077
-
1078
- ```
1079
- [1] 2025-11-21T10:30:45.123Z | SELECT * FROM users WHERE id = ? | Params: [5] | Duration: 12ms | Status: success
1080
- ```
1081
-
1082
- ### Viewing Query Logs in Responses
1083
-
1084
- Query logs are automatically included in tool responses via the `queryLog` field:
1085
-
1086
- **Query execution:**
1087
- ```json
1088
- {
1089
- "status": "success",
1090
- "data": [
1091
- {"id": 1, "name": "John Doe", "email": "john@example.com"}
1092
- ],
1093
- "queryLog": "[1] 2025-11-21T10:30:45.123Z | SELECT * FROM users | Duration: 8ms | Status: success"
1094
- }
1095
- ```
1096
-
1097
- **Bulk operations with multiple queries:**
1098
- ```json
1099
- {
1100
- "status": "success",
1101
- "data": {
1102
- "affectedRows": 100,
1103
- "totalInserted": 100
1104
- },
1105
- "queryLog": "[1] 2025-11-21T10:30:45.123Z | INSERT INTO users ... | Duration: 45ms | Status: success\n[2] 2025-11-21T10:30:45.168Z | INSERT INTO users ... | Duration: 23ms | Status: success"
1106
- }
1107
- ```
1108
-
1109
- ### Query Logs for Debugging
1110
-
1111
- Query logs are valuable for:
1112
- - **Performance Analysis** - Track which queries are slow (high duration)
1113
- - **Troubleshooting** - Review exact parameters sent to queries
1114
- - **Auditing** - See what operations were performed and when
1115
- - **Optimization** - Identify patterns in query execution
1116
- - **Error Investigation** - Review failed queries and their errors
1117
-
1118
- ### Query Log Limitations
1119
-
1120
- - Logs are stored in memory (not persisted to disk)
1121
- - Maximum of 100 most recent queries are retained
1122
- - Logs are cleared when the MCP server restarts
1123
- - For production audit trails, consider using MySQL's built-in query logging
1124
-
1125
- ### Tools with Query Logging
1126
-
1127
- All tools that execute queries include logs:
1128
- - `run_query` - SELECT query execution
1129
- - `executeSql` - Write operations (INSERT, UPDATE, DELETE)
1130
- - `create_record` - Single record insertion
1131
- - `read_records` - Record querying with filters
1132
- - `update_record` - Record updates
1133
- - `delete_record` - Record deletion
1134
- - Bulk operations (`bulk_insert`, `bulk_update`, `bulk_delete`)
1135
- - Stored procedure execution
1136
- - Transaction operations
1137
-
1138
- ### Query Logger Performance & Configuration
1139
-
1140
- #### Memory Management
1141
-
1142
- The QueryLogger is designed with robust memory safety:
1143
-
1144
- **Built-in Protections:**
1145
- - ✅ **SQL Truncation** - Queries truncated to 500 characters max
1146
- - ✅ **Parameter Limiting** - Only first 5 parameters logged
1147
- - ✅ **Value Truncation** - Individual parameter values limited to 50 characters
1148
- - ✅ **Error Truncation** - Error messages limited to 200 characters
1149
- - ✅ **Deep Copy** - Parameters are deep copied to prevent reference mutations
1150
- - ✅ **Safe Serialization** - Handles circular references, BigInt, and unstringifiable objects
1151
- - ✅ **Bounded Storage** - Maximum 100 most recent queries retained
1152
-
1153
- **Memory Impact:**
1154
- ```
1155
- Regular query: ~1 KB per log entry
1156
- Bulk operations: ~1 KB per log entry (99.9% reduction vs unbounded)
1157
- Total max memory: ~100 KB for all 100 log entries
1158
- ```
1159
-
1160
- #### Configuration Tuning
1161
-
1162
- The QueryLogger limits are defined as constants and can be adjusted if needed by modifying `src/db/queryLogger.ts`:
1163
-
1164
- ```typescript
1165
- private static readonly MAX_LOGS = 100; // Number of queries to retain
1166
- private static readonly MAX_SQL_LENGTH = 500; // Max SQL string length
1167
- private static readonly MAX_PARAM_LENGTH = 200; // Max params output length
1168
- private static readonly MAX_PARAM_ITEMS = 5; // Max number of params to log
1169
- ```
1170
-
1171
- **Tuning Recommendations:**
1172
- - **High-traffic production**: Reduce `MAX_LOGS` to 50 to minimize memory
1173
- - **Development/debugging**: Increase `MAX_SQL_LENGTH` to 1000 for fuller visibility
1174
- - **Bulk operations heavy**: Keep defaults - they're optimized for bulk workloads
1175
-
1176
- #### Production Monitoring
1177
-
1178
- When running in production, monitor these metrics:
1179
-
1180
- 1. **Memory Usage** - QueryLogger should use <500 KB total
1181
- 2. **Response Payload Size** - Query logs add minimal overhead (<1 KB per response)
1182
- 3. **Performance Impact** - Logging overhead is <1ms per query
1183
-
1184
- **Health Check:**
1185
- ```javascript
1186
- // Check log memory usage
1187
- const logs = db.getQueryLogs();
1188
- const estimatedMemory = logs.length * 1; // ~1 KB per log
1189
- console.log(`Query log memory usage: ~${estimatedMemory} KB`);
1190
- ```
1191
-
1192
- #### Persistent Logging for Production Auditing
1193
-
1194
- **Important:** QueryLogger stores logs in memory only (not persisted to disk). For production audit trails and compliance, consider:
1195
-
1196
- 1. **MySQL Query Log** (Recommended)
1197
- ```sql
1198
- -- Enable general query log
1199
- SET GLOBAL general_log = 'ON';
1200
- SET GLOBAL general_log_file = '/var/log/mysql/queries.log';
1201
- ```
1202
-
1203
- 2. **MySQL Slow Query Log**
1204
- ```sql
1205
- -- Log queries slower than 1 second
1206
- SET GLOBAL slow_query_log = 'ON';
1207
- SET GLOBAL long_query_time = 1;
1208
- ```
1209
-
1210
- 3. **Application-Level Logging**
1211
- - Use Winston or similar logger to persist query logs to disk
1212
- - Integrate with log aggregation services (ELK, Splunk, DataDog)
1213
-
1214
- 4. **Database Audit Plugins**
1215
- - MySQL Enterprise Audit
1216
- - MariaDB Audit Plugin
1217
- - Percona Audit Log Plugin
1218
-
1219
- **Trade-offs:**
1220
- - **In-Memory (QueryLogger)**: Fast, lightweight, for debugging & development
1221
- - **MySQL Query Log**: Complete audit trail, slight performance impact
1222
- - **Application Logging**: Flexible, can include business context
1223
- - **Audit Plugins**: Enterprise-grade, compliance-ready, feature-rich
1224
-
1225
- ---
1226
-
1227
- ## 🔒 Security Features
1228
-
1229
- ### Built-in Security
1230
-
1231
- - ✅ **Parameterized Queries** - All queries use prepared statements (SQL injection protection)
1232
- - ✅ **Permission-Based Access** - Fine-grained control over operations
1233
- - ✅ **Read-Only Validation** - `run_query` enforces SELECT-only operations
1234
- - ✅ **DDL Gating** - Schema changes require explicit `ddl` permission
1235
- - ✅ **Condition Requirements** - DELETE operations must include WHERE conditions
1236
- - ✅ **Input Validation** - All inputs validated with JSON schemas
1237
- - ✅ **Connection Pooling** - Efficient database connection management
1238
-
1239
- ### Additional Security (REST API Mode)
1240
-
1241
- - ✅ **JWT Authentication** - Token-based authentication
1242
- - ✅ **Rate Limiting** - 100 requests per 15 minutes per IP
1243
- - ✅ **CORS Protection** - Configurable CORS policies
1244
- - ✅ **Helmet Security Headers** - HTTP security headers
1245
-
1246
- ### Security Best Practices
1247
-
1248
- 1. **Use Read-Only for Production**
1249
- ```
1250
- "list,read,utility"
1251
- ```
1252
-
1253
- 2. **Create MySQL Users with Limited Permissions**
1254
- ```sql
1255
- CREATE USER 'readonly'@'%' IDENTIFIED BY 'password';
1256
- GRANT SELECT ON myapp.* TO 'readonly'@'%';
1257
- FLUSH PRIVILEGES;
1258
- ```
541
+ ## 📚 Detailed Documentation
1259
542
 
1260
- 3. **Never Use Root in Production**
1261
- - Create dedicated users per environment
1262
- - Grant minimal necessary permissions
543
+ For comprehensive documentation on all features, please see **[DOCUMENTATIONS.md](DOCUMENTATIONS.md)** which includes:
1263
544
 
1264
- 4. **Never Commit `.env` Files**
1265
- - Add `.env` to `.gitignore`
1266
- - Use environment-specific configs
1267
-
1268
- 5. **Enable DDL Only When Needed**
1269
- - Keep DDL disabled by default
1270
- - Only enable for schema migration tasks
545
+ - 🏗️ **DDL Operations** - Create, alter, and drop tables
546
+ - 📤 **Data Export Tools** - Export data to CSV format
547
+ - 💰 **Transaction Management** - ACID transactions with BEGIN, COMMIT, ROLLBACK
548
+ - 🔧 **Stored Procedures** - Create and execute stored procedures with IN/OUT/INOUT parameters
549
+ - 📋 **Usage Examples** - Real-world examples for all tools
550
+ - 📝 **Query Logging & Automatic SQL Display** - See all SQL queries executed automatically
551
+ - 🔒 **Security Features** - Built-in security and best practices
552
+ - 🚀 **Bulk Operations** - High-performance batch processing
553
+ - 🛠️ **Troubleshooting** - Common issues and solutions
554
+ - 📄 **License** - MIT License details
555
+ - 🗺️ **Roadmap** - Upcoming features and improvements
1271
556
 
1272
557
  ---
1273
558
 
1274
- ## 🚀 Bulk Operations
1275
-
1276
- The MySQL MCP server includes powerful bulk operation tools designed for high-performance data processing. These tools are optimized for handling large datasets efficiently.
1277
-
1278
- ### Performance Characteristics
1279
-
1280
- - **Batch Processing**: Operations are processed in configurable batches to optimize memory usage and database performance
1281
- - **Transaction Safety**: Each batch is wrapped in a transaction for data consistency
1282
- - **Error Handling**: Detailed error reporting with batch-level granularity
1283
- - **Memory Efficient**: Streaming approach prevents memory overflow with large datasets
1284
-
1285
- ### Best Practices
1286
-
1287
- #### Batch Size Optimization
1288
- ```json
1289
- {
1290
- "batch_size": 1000 // Recommended for most operations
1291
- }
1292
- ```
1293
-
1294
- **Guidelines:**
1295
- - **Small records (< 1KB)**: Use batch sizes of 1000-5000
1296
- - **Large records (> 10KB)**: Use batch sizes of 100-500
1297
- - **Complex operations**: Start with 100 and increase based on performance
1298
-
1299
- #### Bulk Insert Tips
1300
- - Use consistent data structure across all records
1301
- - Pre-validate data to avoid mid-batch failures
1302
- - Consider using `ON DUPLICATE KEY UPDATE` for upsert operations
1303
- - Monitor MySQL's `max_allowed_packet` setting for large batches
1304
-
1305
- #### Bulk Update Optimization
1306
- - Use indexed columns in conditions for better performance
1307
- - Group similar updates together
1308
- - Consider using raw SQL expressions for calculated updates
1309
- - Test with small batches first to verify logic
1310
-
1311
- #### Bulk Delete Safety
1312
- - Always test delete conditions with `SELECT` first
1313
- - Use smaller batch sizes for delete operations
1314
- - Consider soft deletes for important data
1315
- - Monitor foreign key constraints
1316
-
1317
- ### Error Handling
1318
-
1319
- Bulk operations provide detailed error information:
1320
-
1321
- ```json
1322
- {
1323
- "success": false,
1324
- "error": "Batch 3 failed: Duplicate entry 'user123' for key 'username'",
1325
- "processed_batches": 2,
1326
- "total_batches": 5,
1327
- "successful_operations": 2000,
1328
- "failed_operations": 1000
1329
- }
1330
- ```
1331
-
1332
- ### Performance Monitoring
1333
-
1334
- Each bulk operation returns performance metrics:
1335
-
1336
- ```json
1337
- {
1338
- "success": true,
1339
- "total_processed": 10000,
1340
- "batches_processed": 10,
1341
- "execution_time_ms": 2500,
1342
- "average_batch_time_ms": 250,
1343
- "records_per_second": 4000
1344
- }
1345
- ```
1346
-
1347
- ---
1348
-
1349
- ## Troubleshooting
1350
-
1351
- ### MCP Server Not Connecting
1352
-
1353
- **Problem:** AI agent doesn't see tools
1354
-
1355
- **Solutions:**
1356
- 1. Check config file path is correct
1357
- 2. Restart AI agent completely
1358
- 3. If using npx: Verify internet connection for package download
1359
- 4. If using local files: Verify bin/mcp-mysql.js exists
1360
- 5. Check for JSON syntax errors
1361
-
1362
- **Problem:** Connection fails
1363
-
1364
- **Solutions:**
1365
- 1. Test MySQL manually: `mysql -u root -p`
1366
- 2. Verify credentials in connection string
1367
- 3. Check MySQL is running
1368
- 4. Verify network access (host/port)
1369
-
1370
- ### Permission Issues
1371
-
1372
- **Problem:** "Tool is disabled" error
1373
-
1374
- **Solutions:**
1375
- 1. Check permissions in third argument
1376
- 2. Verify permission spelling
1377
- 3. Add required permission category
1378
-
1379
- **Problem:** MySQL permission denied
1380
-
1381
- **Solutions:**
1382
- ```sql
1383
- GRANT SELECT, INSERT, UPDATE, DELETE ON db.* TO 'user'@'localhost';
1384
- FLUSH PRIVILEGES;
1385
- ```
1386
-
1387
- ### DDL Operations Not Working
1388
-
1389
- **Problem:** "DDL operations require 'ddl' permission"
1390
-
1391
- **Solution:** Add `ddl` to permissions:
1392
- ```json
1393
- {
1394
- "args": [
1395
- "mysql://...",
1396
- "list,read,create,update,delete,ddl,utility"
1397
- ]
1398
- }
1399
- ```
1400
-
1401
- ### Parameter Validation Errors
1402
-
1403
- **Problem:** "Invalid parameters: must be object" error
1404
-
1405
- **Symptoms:**
1406
- - Tools fail when called without parameters
1407
- - Error message: `Error: Invalid parameters: [{"instancePath":"","schemaPath":"#/type","keyword":"type","params":{"type":"object"},"message":"must be object"}]`
1408
- - Occurs especially with tools that have optional parameters like `list_tables`, `begin_transaction`, `list_stored_procedures`
1409
-
1410
- **Cause:**
1411
- This error occurred in earlier versions (< 1.4.1) when AI agents called MCP tools without providing parameters. The MCP SDK sometimes passes `undefined` or `null` instead of an empty object `{}`, causing JSON schema validation to fail.
1412
-
1413
- **Solution:**
1414
- ✅ **Fixed in version 1.4.1+** - All 33 tools now include defensive parameter handling that automatically converts `undefined`/`null` to empty objects.
1415
-
1416
- **If you're still experiencing this issue:**
1417
- 1. Update to the latest version:
1418
- ```bash
1419
- npx -y @berthojoris/mcp-mysql-server@latest mysql://user:pass@localhost:3306/db "permissions"
1420
- ```
1421
-
1422
- 2. If using global installation:
1423
- ```bash
1424
- npm update -g @berthojoris/mcp-mysql-server
1425
- ```
1426
-
1427
- 3. Restart your AI agent after updating
1428
-
1429
- **Technical Details:**
1430
- - All tool handlers now use defensive pattern: `(args || {})` to ensure parameters are always objects
1431
- - This fix applies to all 27 tools that accept parameters
1432
- - Tools with no parameters (like `list_databases`, `test_connection`) were not affected
1433
- - No breaking changes - existing valid calls continue to work exactly as before
1434
-
1435
- ---
1436
-
1437
- ## 📄 License
559
+ ## 📄 License
1438
560
 
1439
561
  MIT License - see [LICENSE](LICENSE) file for details.
1440
562
 
1441
563
  ---
1442
564
 
1443
- ## 🗺️ Roadmap
1444
-
1445
- ### Core Features
1446
- - ✅ **Transaction support (BEGIN, COMMIT, ROLLBACK)** - **COMPLETED!**
1447
- - ✅ **Stored procedure execution** - **COMPLETED!**
1448
- - ✅ **Bulk operations (batch insert/update/delete)** - **COMPLETED!**
1449
- - ✅ **Add query log on output** - **COMPLETED!**
1450
- - [ ] Query result caching
1451
- - [ ] Advanced query optimization hints
1452
-
1453
- ### Enterprise Features
1454
- - [ ] **Database backup and restore tools**
1455
- - [ ] **Data export/import utilities** (CSV, JSON, SQL dumps)
1456
- - [ ] **Performance monitoring and metrics**
1457
- - [ ] **Query performance analysis**
1458
- - [ ] **Connection pool monitoring**
1459
- - [ ] **Audit logging and compliance**
1460
- - [ ] **Data migration utilities**
1461
- - [ ] **Schema versioning and migrations**
1462
-
1463
- ### Database Adapters
1464
- - [ ] PostgreSQL adapter
1465
- - [ ] MongoDB adapter
1466
- - [ ] SQLite adapter
1467
- - [ ] Oracle Database adapter
1468
- - [ ] SQL Server adapter
1469
-
1470
- ### Recommended Implementation Order
1471
-
1472
- #### **Phase 1: Performance & Monitoring** 🚀
1473
- - [ ] **Query result caching** - Dramatically improve response times for repeated queries
1474
- - [ ] **Performance metrics** - Track query execution times and database performance
1475
- - [ ] **Connection pool monitoring** - Monitor database connection health and usage
1476
- - [ ] **Database health checks** - Comprehensive system health monitoring
1477
-
1478
- #### **Phase 2: Data Management** 📊
1479
- - [ ] **Database backup and restore tools** - Essential for production data safety
1480
- - [ ] **Data migration utilities** - Move data between databases and environments
1481
- - [ ] **Enhanced export/import** - Support for JSON, XML, Excel formats
1482
- - [ ] **Query history & analytics** - Track and analyze database usage patterns
1483
-
1484
- #### **Phase 3: Enterprise Features** 🏢
1485
- - [ ] **Audit logging and compliance** - Track all database operations for security
1486
- - [ ] **Schema versioning and migrations** - Version control for database schema changes
1487
- - [ ] **Query optimization** - Automatic query analysis and optimization suggestions
1488
- - [ ] **Advanced security features** - Enhanced access control and monitoring
1489
-
1490
- #### **Phase 4: Multi-Database Support** 🌐
1491
- - [ ] **PostgreSQL adapter** - Extend support to PostgreSQL databases
1492
- - [ ] **MongoDB adapter** - Add NoSQL document database support
1493
- - [ ] **SQLite adapter** - Support for lightweight embedded databases
1494
- - [ ] **Database-agnostic operations** - Unified API across different database types
1495
-
1496
- #### **Implementation Priority Matrix**
1497
-
1498
- | Feature | Impact | Effort | Priority |
1499
- |---------|--------|--------|----------|
1500
- | Query Result Caching | High | Medium | 1 |
1501
- | Database Backup/Restore | High | High | 2 |
1502
- | Performance Monitoring | High | Medium | 3 |
1503
- | Data Migration | High | High | 4 |
1504
- | Query Optimization | Medium | Medium | 5 |
1505
- | PostgreSQL Adapter | High | High | 6 |
1506
- | Audit Logging | Medium | Low | 7 |
1507
- | Schema Versioning | Medium | Medium | 8 |
1508
-
1509
- ---
1510
-
1511
- **Made with ❤️ for the AI community**
565
+ **Made with ❤️ for the AI community**
1512
566
 
1513
567
  *Help AI agents interact with MySQL databases safely and efficiently!*
568
+