@berthojoris/mcp-mysql-server 1.40.0 → 1.40.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/CHANGELOG.md CHANGED
@@ -5,6 +5,46 @@ 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.40.2] - 2026-03-07
9
+
10
+ ### Removed
11
+ - **Functions Management Category**: Removed category `functions_management` and all 6 tools
12
+ - `list_functions` - List user-defined functions
13
+ - `get_function_info` - Get function details
14
+ - `create_function` - Create function
15
+ - `drop_function` - Drop function
16
+ - `show_create_function` - Show CREATE FUNCTION statement
17
+ - `execute_function` - Execute function
18
+ - **Backup & Restore Category**: Removed category `backup_restore` and all 5 tools
19
+ - `backup_table` - Backup a single table
20
+ - `backup_database` - Backup entire database
21
+ - `restore_from_sql` - Restore from SQL dump
22
+ - `get_create_table_statement` - Get CREATE TABLE statement
23
+ - `get_database_schema` - Get complete schema snapshot
24
+ - Removed tool modules `src/tools/functionTools.ts` and `src/tools/backupRestoreTools.ts`
25
+
26
+ ### Changed
27
+ - Updated tool count: 73 → 62 tools (-11 tools)
28
+ - Updated category count: 15 → 13 categories (removed `functions_management`, `backup_restore`)
29
+ - Updated `src/mcp-server.ts` to remove tool schemas and call routing for all 11 tools
30
+ - Updated `src/index.ts` to remove MySQLMCP imports, fields, initialization, and methods for removed tool sets
31
+ - Updated `src/config/featureConfig.ts` to remove enum values and category mappings for both categories
32
+ - Updated CLI category help in `bin/mcp-mysql.js`
33
+ - Updated `README.md` and `DOCUMENTATIONS.md` to reflect new category list and tool totals
34
+ - Synchronized versions to `1.40.2` in `package.json`, `src/mcp-server.ts`, and `manifest.json`
35
+
36
+ ### Fixed
37
+ - Updated procedure permission example in docs to reference `execute_stored_procedure` instead of removed function execution tool
38
+
39
+ ## [1.40.1] - 2026-03-06
40
+
41
+ ### Changed
42
+ - Synchronized version metadata across `package.json`, `src/mcp-server.ts`, and `manifest.json` to `1.40.1`
43
+ - Updated CLI category examples in `bin/mcp-mysql.js` to match active category set
44
+ - Updated category examples in `README.md` and `DOCUMENTATIONS.md` to remove removed categories
45
+ - Refactored tool registry filtering into `src/tools/toolRegistry.ts`
46
+ - Refactored tool argument validation registry into `src/tools/toolArgumentValidation.ts`
47
+
8
48
  ## [1.40.0] - 2026-03-06
9
49
 
10
50
  ### Removed
package/DOCUMENTATIONS.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # MySQL MCP Server - Documentation
2
2
 
3
- **Last Updated:** 2026-03-06 00:00:00
4
- **Version:** 1.40.0
5
- **Total Tools:** 73
3
+ **Last Updated:** 2026-03-07 10:30:00
4
+ **Version:** 1.40.2
5
+ **Total Tools:** 62
6
6
 
7
7
  Comprehensive documentation for the MySQL MCP Server. For quick start, see [README.md](README.md).
8
8
 
@@ -37,7 +37,7 @@ Configure MySQL MCP with two access-control layers:
37
37
  "@berthojoris/mcp-mysql-server",
38
38
  "mysql://user:password@localhost:3306/database",
39
39
  "list,read,utility",
40
- "database_discovery,performance_monitoring"
40
+ "database_discovery,custom_queries,analysis"
41
41
  ]
42
42
  }
43
43
  }
@@ -58,7 +58,7 @@ Configure MySQL MCP with two access-control layers:
58
58
  "DB_PASSWORD": "your_password",
59
59
  "DB_NAME": "your_database",
60
60
  "MCP_PERMISSIONS": "list,read,utility",
61
- "MCP_CATEGORIES": "database_discovery,performance_monitoring"
61
+ "MCP_CATEGORIES": "database_discovery,custom_queries,analysis"
62
62
  }
63
63
  }
64
64
  ```
@@ -80,7 +80,7 @@ Configure MySQL MCP with two access-control layers:
80
80
  | `ddl` | Schema changes | `create_table`, `alter_table` |
81
81
  | `utility` | Utility operations | `test_connection`, `analyze_table` |
82
82
  | `transaction` | Transaction management | `begin_transaction`, `commit_transaction` |
83
- | `procedure` | Stored procedures | `create_stored_procedure`, `execute_function` |
83
+ | `procedure` | Stored procedures | `create_stored_procedure`, `execute_stored_procedure` |
84
84
 
85
85
  ### Filtering Logic
86
86
 
@@ -169,15 +169,7 @@ Tool enabled = (Has Permission) AND (Has Category OR No categories specified)
169
169
  - `drop_trigger` - Remove triggers
170
170
  - `show_create_trigger` - Show CREATE statement
171
171
 
172
- ### 11. Functions Management (6 tools)
173
- - `list_functions` - List functions
174
- - `get_function_info` - Get function details
175
- - `create_function` - Create functions
176
- - `drop_function` - Remove functions
177
- - `show_create_function` - Show CREATE statement
178
- - `execute_function` - Execute functions
179
-
180
- ### 12. Table Maintenance (8 tools)
172
+ ### 11. Table Maintenance (8 tools)
181
173
  - `analyze_table` - Update statistics
182
174
  - `optimize_table` - Reclaim space
183
175
  - `check_table` - Check for errors
@@ -187,19 +179,19 @@ Tool enabled = (Has Permission) AND (Has Category OR No categories specified)
187
179
  - `flush_table` - Close/reopen table
188
180
  - `get_table_size` - Get size information
189
181
 
190
- ### 13. Transaction Management (5 tools)
182
+ ### 12. Transaction Management (5 tools)
191
183
  - `begin_transaction` - Start transaction
192
184
  - `commit_transaction` - Commit transaction
193
185
  - `rollback_transaction` - Rollback transaction
194
186
  - `get_transaction_status` - Check transaction state
195
187
  - `execute_in_transaction` - Execute within transaction
196
188
 
197
- ### 14. Query Optimization (3 tools)
189
+ ### 13. Query Optimization (3 tools)
198
190
  - `analyze_query` - Analyze query performance
199
191
  - `get_optimization_hints` - Get optimizer hints
200
192
  - `repair_query` - Repair broken SQL queries
201
193
 
202
- ### 15. Utilities (4 tools)
194
+ ### 14. Utilities (4 tools)
203
195
  - `test_connection` - Test connectivity
204
196
  - `describe_connection` - Connection info
205
197
  - `read_changelog` - Read changelog
@@ -391,4 +383,4 @@ The system provides detailed error messages indicating:
391
383
 
392
384
  ---
393
385
 
394
- *For detailed examples and advanced usage patterns, see the project README.md.*
386
+ *For detailed examples and advanced usage patterns, see the project README.md.*
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  **A production-ready Model Context Protocol (MCP) server for MySQL database integration with AI agents**
6
6
 
7
- **Last Updated:** 2026-03-06 16:45:00
7
+ **Last Updated:** 2026-03-07 10:30:00
8
8
 
9
9
  [![npm version](https://img.shields.io/npm/v/@berthojoris/mcp-mysql-server)](https://www.npmjs.com/package/@berthojoris/mcp-mysql-server)
10
10
  [![npm downloads](https://img.shields.io/npm/dm/@berthojoris/mcp-mysql-server)](https://www.npmjs.com/package/@berthojoris/mcp-mysql-server)
@@ -200,7 +200,7 @@ Alternative approach using environment variables instead of connection string:
200
200
  "DB_PASSWORD": "your_password",
201
201
  "DB_NAME": "your_database",
202
202
  "MCP_PERMISSIONS": "list,read,utility,create,update,delete",
203
- "MCP_CATEGORIES": "database_discovery,performance_monitoring,custom_queries"
203
+ "MCP_CATEGORIES": "database_discovery,custom_queries,analysis"
204
204
  }
205
205
  }
206
206
  }
@@ -245,7 +245,7 @@ Use documentation categories to fine-tune which tools are exposed (Layer 2):
245
245
 
246
246
  | Category List | Use Case | List Tools |
247
247
  |---------------|----------|-----------|
248
- | `database_discovery` | Explore databases, tables, and schema structure | `get_all_tables_relationships, get_table_relationships, list_databases, list_tables, read_table_schema` |
248
+ | `database_discovery` | Explore databases, tables, and schema structure | `get_all_tables_relationships, list_databases, list_tables, read_table_schema` |
249
249
  | `crud_operations` | Create, read, update, delete operations on data | `create_record, delete_record, read_records, update_record` |
250
250
  | `bulk_operations` | High-performance batch processing operations | `bulk_delete, bulk_insert, bulk_update` |
251
251
  | `custom_queries` | Execute custom SQL queries and advanced operations | `execute_write_query, run_select_query` |
@@ -255,19 +255,17 @@ Use documentation categories to fine-tune which tools are exposed (Layer 2):
255
255
  | `stored_procedures` | Create, execute, and manage stored procedures | `create_stored_procedure, drop_stored_procedure, execute_stored_procedure, get_stored_procedure_info, list_stored_procedures, show_create_procedure` |
256
256
  | `views_management` | Create and manage database views | `alter_view, create_view, drop_view, get_view_info, list_views, show_create_view` |
257
257
  | `triggers_management` | Create and manage database triggers | `create_trigger, drop_trigger, get_trigger_info, list_triggers, show_create_trigger` |
258
- | `functions_management` | Create and manage database functions | `create_function, drop_function, execute_function, get_function_info, list_functions, show_create_function` |
259
258
  | `index_management` | Optimize performance with index management | `analyze_index, create_index, drop_index, get_index_info, list_indexes` |
260
259
  | `constraint_management` | Manage data integrity constraints | `add_check_constraint, add_foreign_key, add_unique_constraint, drop_constraint, drop_foreign_key, list_constraints, list_foreign_keys` |
261
260
  | `table_maintenance` | Table optimization, repair, and maintenance | `analyze_table, check_table, flush_table, get_table_size, get_table_status, optimize_table, repair_table, truncate_table` |
262
261
  | `query_optimization` | Analyze and optimize SQL queries | `analyze_query, get_optimization_hints` |
263
- | `backup_restore` | Create backups and restore databases | `backup_database, backup_table, get_create_table_statement, get_database_schema, restore_from_sql` |
264
262
  | `analysis` | Data analysis and reporting tools | `get_column_statistics, get_database_summary, get_schema_erd, get_schema_rag_context` |
265
263
 
266
264
  <details>
267
265
  <summary>Copy/paste list (comma-separated, no spaces)</summary>
268
266
 
269
267
  ```text
270
- database_discovery,crud_operations,bulk_operations,custom_queries,schema_management,utilities,transaction_management,stored_procedures,views_management,triggers_management,functions_management,index_management,constraint_management,table_maintenance,query_optimization,backup_restore,analysis
268
+ database_discovery,crud_operations,bulk_operations,custom_queries,schema_management,utilities,transaction_management,stored_procedures,views_management,triggers_management,index_management,constraint_management,table_maintenance,query_optimization,analysis
271
269
  ```
272
270
 
273
271
  </details>
@@ -278,7 +276,7 @@ Full category → tool mapping (and examples) lives in **[DOCUMENTATIONS.md →
278
276
 
279
277
  ## Available Tools
280
278
 
281
- The server exposes **73 tools** organized into categories (CRUD, schema, and utilities).
279
+ The server exposes **62 tools** organized into categories (CRUD, schema, and utilities).
282
280
 
283
281
  - Complete list of tools: **[DOCUMENTATIONS.md → Complete Tools Reference](DOCUMENTATIONS.md#🔧-complete-tools-reference)**
284
282
 
@@ -291,7 +289,6 @@ For comprehensive documentation, see **[DOCUMENTATIONS.md](DOCUMENTATIONS.md)**:
291
289
  - **DDL Operations** - Create, alter, and drop tables
292
290
  - **Data Export Tools** - Export to CSV, JSON, and SQL formats
293
291
  - **Data Import Tools** - Import from CSV and JSON sources
294
- - **Database Backup & Restore** - Full backup/restore with SQL dumps
295
292
  - **Data Migration Tools** - Copy, move, clone, compare, and sync data
296
293
  - **Schema Versioning** - Version control for database schema changes
297
294
  - **Transaction Management** - ACID transactions
package/bin/mcp-mysql.js CHANGED
@@ -50,7 +50,7 @@ if (!mysqlUrl) {
50
50
  " # Dual-layer: Permissions + Categories (fine-grained control)",
51
51
  );
52
52
  console.error(
53
- ' mcp-mysql mysql://root:pass@localhost:3306/mydb "list,read,utility" "database_discovery,performance_monitoring"',
53
+ ' mcp-mysql mysql://root:pass@localhost:3306/mydb "list,read,utility" "database_discovery,custom_queries,analysis"',
54
54
  );
55
55
  console.error("");
56
56
  console.error("Permissions (Layer 1 - Broad Control):");
@@ -66,16 +66,13 @@ if (!mysqlUrl) {
66
66
  " schema_management, utilities, transaction_management, stored_procedures,",
67
67
  );
68
68
  console.error(
69
- " views_management, triggers_management, functions_management, index_management,",
69
+ " views_management, triggers_management, index_management,",
70
70
  );
71
71
  console.error(
72
- " constraint_management, table_maintenance, server_management,",
72
+ " constraint_management, table_maintenance, query_optimization,",
73
73
  );
74
74
  console.error(
75
- " performance_monitoring, cache_management, query_optimization,",
76
- );
77
- console.error(
78
- " backup_restore, import_export, data_migration, schema_migrations",
75
+ " analysis",
79
76
  );
80
77
  console.error("");
81
78
  console.error("Filtering Logic:");
@@ -14,7 +14,7 @@ export declare enum ToolCategory {
14
14
  PROCEDURE = "procedure"
15
15
  }
16
16
  /**
17
- * Documentation categories from README (15 categories)
17
+ * Documentation categories from README (13 categories)
18
18
  * More intuitive and matches user mental model
19
19
  */
20
20
  export declare enum DocCategory {
@@ -28,12 +28,10 @@ export declare enum DocCategory {
28
28
  STORED_PROCEDURES = "stored_procedures",
29
29
  VIEWS_MANAGEMENT = "views_management",
30
30
  TRIGGERS_MANAGEMENT = "triggers_management",
31
- FUNCTIONS_MANAGEMENT = "functions_management",
32
31
  INDEX_MANAGEMENT = "index_management",
33
32
  CONSTRAINT_MANAGEMENT = "constraint_management",
34
33
  TABLE_MAINTENANCE = "table_maintenance",
35
34
  QUERY_OPTIMIZATION = "query_optimization",
36
- BACKUP_RESTORE = "backup_restore",
37
35
  ANALYSIS = "analysis"
38
36
  }
39
37
  /**
@@ -24,7 +24,7 @@ var ToolCategory;
24
24
  ToolCategory["PROCEDURE"] = "procedure";
25
25
  })(ToolCategory || (exports.ToolCategory = ToolCategory = {}));
26
26
  /**
27
- * Documentation categories from README (15 categories)
27
+ * Documentation categories from README (13 categories)
28
28
  * More intuitive and matches user mental model
29
29
  */
30
30
  var DocCategory;
@@ -39,12 +39,10 @@ var DocCategory;
39
39
  DocCategory["STORED_PROCEDURES"] = "stored_procedures";
40
40
  DocCategory["VIEWS_MANAGEMENT"] = "views_management";
41
41
  DocCategory["TRIGGERS_MANAGEMENT"] = "triggers_management";
42
- DocCategory["FUNCTIONS_MANAGEMENT"] = "functions_management";
43
42
  DocCategory["INDEX_MANAGEMENT"] = "index_management";
44
43
  DocCategory["CONSTRAINT_MANAGEMENT"] = "constraint_management";
45
44
  DocCategory["TABLE_MAINTENANCE"] = "table_maintenance";
46
45
  DocCategory["QUERY_OPTIMIZATION"] = "query_optimization";
47
- DocCategory["BACKUP_RESTORE"] = "backup_restore";
48
46
  DocCategory["ANALYSIS"] = "analysis";
49
47
  })(DocCategory || (exports.DocCategory = DocCategory = {}));
50
48
  /**
@@ -112,13 +110,6 @@ exports.toolCategoryMap = {
112
110
  createTrigger: ToolCategory.DDL,
113
111
  dropTrigger: ToolCategory.DDL,
114
112
  showCreateTrigger: ToolCategory.LIST,
115
- // Function tools
116
- listFunctions: ToolCategory.LIST,
117
- getFunctionInfo: ToolCategory.LIST,
118
- createFunction: ToolCategory.PROCEDURE,
119
- dropFunction: ToolCategory.PROCEDURE,
120
- showCreateFunction: ToolCategory.LIST,
121
- executeFunction: ToolCategory.PROCEDURE,
122
113
  // Index tools
123
114
  listIndexes: ToolCategory.LIST,
124
115
  getIndexInfo: ToolCategory.LIST,
@@ -142,12 +133,6 @@ exports.toolCategoryMap = {
142
133
  getTableStatus: ToolCategory.LIST,
143
134
  flushTable: ToolCategory.UTILITY,
144
135
  getTableSize: ToolCategory.LIST,
145
- // Backup and restore tools
146
- backupTable: ToolCategory.UTILITY,
147
- backupDatabase: ToolCategory.UTILITY,
148
- restoreFromSql: ToolCategory.UTILITY,
149
- getCreateTableStatement: ToolCategory.UTILITY,
150
- getDatabaseSchema: ToolCategory.UTILITY,
151
136
  // Full-Text Search Tools
152
137
  createFulltextIndex: ToolCategory.DDL,
153
138
  fulltextSearch: ToolCategory.READ,
@@ -215,13 +200,6 @@ exports.toolDocCategoryMap = {
215
200
  createTrigger: DocCategory.TRIGGERS_MANAGEMENT,
216
201
  dropTrigger: DocCategory.TRIGGERS_MANAGEMENT,
217
202
  showCreateTrigger: DocCategory.TRIGGERS_MANAGEMENT,
218
- // Functions Management
219
- listFunctions: DocCategory.FUNCTIONS_MANAGEMENT,
220
- getFunctionInfo: DocCategory.FUNCTIONS_MANAGEMENT,
221
- createFunction: DocCategory.FUNCTIONS_MANAGEMENT,
222
- dropFunction: DocCategory.FUNCTIONS_MANAGEMENT,
223
- showCreateFunction: DocCategory.FUNCTIONS_MANAGEMENT,
224
- executeFunction: DocCategory.FUNCTIONS_MANAGEMENT,
225
203
  // Index Management
226
204
  listIndexes: DocCategory.INDEX_MANAGEMENT,
227
205
  getIndexInfo: DocCategory.INDEX_MANAGEMENT,
@@ -249,12 +227,6 @@ exports.toolDocCategoryMap = {
249
227
  analyzeQuery: DocCategory.QUERY_OPTIMIZATION,
250
228
  getOptimizationHints: DocCategory.QUERY_OPTIMIZATION,
251
229
  repairQuery: DocCategory.QUERY_OPTIMIZATION,
252
- // Backup & Restore
253
- backupTable: DocCategory.BACKUP_RESTORE,
254
- backupDatabase: DocCategory.BACKUP_RESTORE,
255
- restoreFromSql: DocCategory.BACKUP_RESTORE,
256
- getCreateTableStatement: DocCategory.BACKUP_RESTORE,
257
- getDatabaseSchema: DocCategory.BACKUP_RESTORE,
258
230
  // Analysis
259
231
  getDatabaseSummary: DocCategory.ANALYSIS,
260
232
  getSchemaERD: DocCategory.ANALYSIS,
@@ -278,7 +250,6 @@ const legacyToDocCategoryMap = {
278
250
  DocCategory.STORED_PROCEDURES,
279
251
  DocCategory.VIEWS_MANAGEMENT,
280
252
  DocCategory.TRIGGERS_MANAGEMENT,
281
- DocCategory.FUNCTIONS_MANAGEMENT,
282
253
  DocCategory.INDEX_MANAGEMENT,
283
254
  DocCategory.CONSTRAINT_MANAGEMENT,
284
255
  DocCategory.TABLE_MAINTENANCE,
@@ -306,16 +277,14 @@ const legacyToDocCategoryMap = {
306
277
  DocCategory.INDEX_MANAGEMENT,
307
278
  DocCategory.CONSTRAINT_MANAGEMENT,
308
279
  DocCategory.TABLE_MAINTENANCE,
309
- DocCategory.BACKUP_RESTORE,
310
280
  ],
311
281
  utility: [
312
282
  DocCategory.UTILITIES,
313
283
  DocCategory.TABLE_MAINTENANCE,
314
284
  DocCategory.QUERY_OPTIMIZATION,
315
- DocCategory.BACKUP_RESTORE,
316
285
  ],
317
286
  transaction: [DocCategory.TRANSACTION_MANAGEMENT],
318
- procedure: [DocCategory.STORED_PROCEDURES, DocCategory.FUNCTIONS_MANAGEMENT],
287
+ procedure: [DocCategory.STORED_PROCEDURES],
319
288
  };
320
289
  /**
321
290
  * Class to manage feature configuration based on runtime or environment variables
package/dist/index.d.ts CHANGED
@@ -13,11 +13,9 @@ export declare class MySQLMCP {
13
13
  private dataExportTools;
14
14
  private viewTools;
15
15
  private triggerTools;
16
- private functionTools;
17
16
  private indexTools;
18
17
  private constraintTools;
19
18
  private maintenanceTools;
20
- private backupRestoreTools;
21
19
  private analysisTools;
22
20
  private aiTools;
23
21
  private macroTools;
@@ -510,52 +508,6 @@ export declare class MySQLMCP {
510
508
  data?: any;
511
509
  error?: string;
512
510
  }>;
513
- listFunctions(params: {
514
- database?: string;
515
- }): Promise<{
516
- status: string;
517
- data?: any[];
518
- error?: string;
519
- }>;
520
- getFunctionInfo(params: {
521
- function_name: string;
522
- database?: string;
523
- }): Promise<{
524
- status: string;
525
- data?: any;
526
- error?: string;
527
- }>;
528
- createFunction(params: any): Promise<{
529
- status: string;
530
- data?: any;
531
- error?: string;
532
- }>;
533
- dropFunction(params: {
534
- function_name: string;
535
- if_exists?: boolean;
536
- database?: string;
537
- }): Promise<{
538
- status: string;
539
- message?: string;
540
- error?: string;
541
- }>;
542
- showCreateFunction(params: {
543
- function_name: string;
544
- database?: string;
545
- }): Promise<{
546
- status: string;
547
- data?: any;
548
- error?: string;
549
- }>;
550
- executeFunction(params: {
551
- function_name: string;
552
- parameters?: any[];
553
- database?: string;
554
- }): Promise<{
555
- status: string;
556
- data?: any;
557
- error?: string;
558
- }>;
559
511
  listIndexes(params: {
560
512
  table_name: string;
561
513
  database?: string;
package/dist/index.js CHANGED
@@ -14,11 +14,9 @@ const storedProcedureTools_1 = require("./tools/storedProcedureTools");
14
14
  const dataExportTools_1 = require("./tools/dataExportTools");
15
15
  const viewTools_1 = require("./tools/viewTools");
16
16
  const triggerTools_1 = require("./tools/triggerTools");
17
- const functionTools_1 = require("./tools/functionTools");
18
17
  const indexTools_1 = require("./tools/indexTools");
19
18
  const constraintTools_1 = require("./tools/constraintTools");
20
19
  const maintenanceTools_1 = require("./tools/maintenanceTools");
21
- const backupRestoreTools_1 = require("./tools/backupRestoreTools");
22
20
  const analysisTools_1 = require("./tools/analysisTools");
23
21
  const aiTools_1 = require("./tools/aiTools");
24
22
  const macroTools_1 = require("./tools/macroTools");
@@ -45,11 +43,9 @@ class MySQLMCP {
45
43
  this.dataExportTools = new dataExportTools_1.DataExportTools(this.security);
46
44
  this.viewTools = new viewTools_1.ViewTools(this.security);
47
45
  this.triggerTools = new triggerTools_1.TriggerTools(this.security);
48
- this.functionTools = new functionTools_1.FunctionTools(this.security);
49
46
  this.indexTools = new indexTools_1.IndexTools(this.security);
50
47
  this.constraintTools = new constraintTools_1.ConstraintTools(this.security);
51
48
  this.maintenanceTools = new maintenanceTools_1.MaintenanceTools(this.security);
52
- this.backupRestoreTools = new backupRestoreTools_1.BackupRestoreTools(this.security);
53
49
  this.analysisTools = new analysisTools_1.AnalysisTools(this.security);
54
50
  this.aiTools = new aiTools_1.AiTools(this.security);
55
51
  this.macroTools = new macroTools_1.MacroTools(this.security);
@@ -515,45 +511,6 @@ class MySQLMCP {
515
511
  return await this.triggerTools.showCreateTrigger(params);
516
512
  }
517
513
  // ==========================================
518
- // Function Tools
519
- // ==========================================
520
- async listFunctions(params) {
521
- const check = this.checkToolEnabled("listFunctions");
522
- if (!check.enabled)
523
- return { status: "error", error: check.error };
524
- return await this.functionTools.listFunctions(params);
525
- }
526
- async getFunctionInfo(params) {
527
- const check = this.checkToolEnabled("getFunctionInfo");
528
- if (!check.enabled)
529
- return { status: "error", error: check.error };
530
- return await this.functionTools.getFunctionInfo(params);
531
- }
532
- async createFunction(params) {
533
- const check = this.checkToolEnabled("createFunction");
534
- if (!check.enabled)
535
- return { status: "error", error: check.error };
536
- return await this.functionTools.createFunction(params);
537
- }
538
- async dropFunction(params) {
539
- const check = this.checkToolEnabled("dropFunction");
540
- if (!check.enabled)
541
- return { status: "error", error: check.error };
542
- return await this.functionTools.dropFunction(params);
543
- }
544
- async showCreateFunction(params) {
545
- const check = this.checkToolEnabled("showCreateFunction");
546
- if (!check.enabled)
547
- return { status: "error", error: check.error };
548
- return await this.functionTools.showCreateFunction(params);
549
- }
550
- async executeFunction(params) {
551
- const check = this.checkToolEnabled("executeFunction");
552
- if (!check.enabled)
553
- return { status: "error", error: check.error };
554
- return await this.functionTools.executeFunction(params);
555
- }
556
- // ==========================================
557
514
  // Index Tools
558
515
  // ==========================================
559
516
  async listIndexes(params) {
@@ -5,7 +5,8 @@ const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js");
5
5
  const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
6
6
  const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
7
7
  const index_js_2 = require("./index.js");
8
- const inputValidation_js_1 = require("./validation/inputValidation.js");
8
+ const toolRegistry_js_1 = require("./tools/toolRegistry.js");
9
+ const toolArgumentValidation_js_1 = require("./tools/toolArgumentValidation.js");
9
10
  // Get permissions and categories from environment variables (set by bin/mcp-mysql.js)
10
11
  // Layer 1 (Permissions): MCP_PERMISSIONS or MCP_CONFIG (backward compatible)
11
12
  // Layer 2 (Categories): MCP_CATEGORIES (optional, for fine-grained control)
@@ -602,7 +603,7 @@ const TOOLS = [
602
603
  },
603
604
  {
604
605
  name: "drop_table",
605
- description: '🗑️ DESTRUCTIVE: Permanently deletes a table and ALL its data. Cannot be undone! Consider backup_table first. Requires "ddl" permission. ⚠️ WARNING: IRREVERSIBLE!',
606
+ description: '🗑️ DESTRUCTIVE: Permanently deletes a table and ALL its data. Cannot be undone! Requires "ddl" permission. ⚠️ WARNING: IRREVERSIBLE!',
606
607
  inputSchema: {
607
608
  type: "object",
608
609
  properties: {
@@ -1252,139 +1253,6 @@ const TOOLS = [
1252
1253
  required: ["trigger_name"],
1253
1254
  },
1254
1255
  },
1255
- // Function Tools
1256
- {
1257
- name: "list_functions",
1258
- description: "Lists all user-defined functions in the database.",
1259
- inputSchema: {
1260
- type: "object",
1261
- properties: {
1262
- database: {
1263
- type: "string",
1264
- description: "Optional: specific database name",
1265
- },
1266
- },
1267
- },
1268
- },
1269
- {
1270
- name: "get_function_info",
1271
- description: "Gets detailed information about a specific function including parameters.",
1272
- inputSchema: {
1273
- type: "object",
1274
- properties: {
1275
- function_name: { type: "string", description: "Name of the function" },
1276
- database: {
1277
- type: "string",
1278
- description: "Optional: specific database name",
1279
- },
1280
- },
1281
- required: ["function_name"],
1282
- },
1283
- },
1284
- {
1285
- name: "create_function",
1286
- description: "Creates a new user-defined function. Requires 'ddl' permission.",
1287
- inputSchema: {
1288
- type: "object",
1289
- properties: {
1290
- function_name: { type: "string", description: "Name of the function" },
1291
- parameters: {
1292
- type: "array",
1293
- description: "Array of parameter definitions",
1294
- items: {
1295
- type: "object",
1296
- properties: {
1297
- name: { type: "string" },
1298
- data_type: { type: "string" },
1299
- },
1300
- required: ["name", "data_type"],
1301
- },
1302
- },
1303
- returns: { type: "string", description: "Return data type" },
1304
- body: { type: "string", description: "Function body (SQL statements)" },
1305
- deterministic: {
1306
- type: "boolean",
1307
- description: "Whether function always returns same result for same input",
1308
- },
1309
- data_access: {
1310
- type: "string",
1311
- enum: [
1312
- "CONTAINS SQL",
1313
- "NO SQL",
1314
- "READS SQL DATA",
1315
- "MODIFIES SQL DATA",
1316
- ],
1317
- },
1318
- security: { type: "string", enum: ["DEFINER", "INVOKER"] },
1319
- comment: { type: "string", description: "Optional comment" },
1320
- database: {
1321
- type: "string",
1322
- description: "Optional: specific database name",
1323
- },
1324
- },
1325
- required: ["function_name", "returns", "body"],
1326
- },
1327
- },
1328
- {
1329
- name: "drop_function",
1330
- description: "Drops a user-defined function. Requires 'ddl' permission.",
1331
- inputSchema: {
1332
- type: "object",
1333
- properties: {
1334
- function_name: {
1335
- type: "string",
1336
- description: "Name of the function to drop",
1337
- },
1338
- if_exists: {
1339
- type: "boolean",
1340
- description: "If true, will not error if function does not exist",
1341
- },
1342
- database: {
1343
- type: "string",
1344
- description: "Optional: specific database name",
1345
- },
1346
- },
1347
- required: ["function_name"],
1348
- },
1349
- },
1350
- {
1351
- name: "show_create_function",
1352
- description: "Shows the CREATE statement for a function.",
1353
- inputSchema: {
1354
- type: "object",
1355
- properties: {
1356
- function_name: { type: "string", description: "Name of the function" },
1357
- database: {
1358
- type: "string",
1359
- description: "Optional: specific database name",
1360
- },
1361
- },
1362
- required: ["function_name"],
1363
- },
1364
- },
1365
- {
1366
- name: "execute_function",
1367
- description: "Executes a user-defined function and returns its result.",
1368
- inputSchema: {
1369
- type: "object",
1370
- properties: {
1371
- function_name: {
1372
- type: "string",
1373
- description: "Name of the function to execute",
1374
- },
1375
- parameters: {
1376
- type: "array",
1377
- description: "Array of parameter values",
1378
- items: {},
1379
- },
1380
- database: {
1381
- type: "string",
1382
- description: "Optional: specific database name",
1383
- },
1384
- },
1385
- required: ["function_name"],
1386
- },
1387
- },
1388
1256
  // Index Tools
1389
1257
  {
1390
1258
  name: "list_indexes",
@@ -1737,7 +1605,7 @@ const TOOLS = [
1737
1605
  },
1738
1606
  {
1739
1607
  name: "truncate_table",
1740
- description: "🗑️ DESTRUCTIVE: Removes ALL rows from a table instantly (faster than DELETE). Resets auto-increment counters. Cannot be undone! Consider backup_table first. Requires 'ddl' permission. ⚠️ WARNING: IRREVERSIBLE!",
1608
+ description: "🗑️ DESTRUCTIVE: Removes ALL rows from a table instantly (faster than DELETE). Resets auto-increment counters. Cannot be undone! Requires 'ddl' permission. ⚠️ WARNING: IRREVERSIBLE!",
1741
1609
  inputSchema: {
1742
1610
  type: "object",
1743
1611
  properties: {
@@ -1808,128 +1676,6 @@ const TOOLS = [
1808
1676
  },
1809
1677
  },
1810
1678
  },
1811
- // Backup and Restore Tools
1812
- {
1813
- name: "backup_table",
1814
- description: "Backup a single table to SQL dump format including structure and optionally data.",
1815
- inputSchema: {
1816
- type: "object",
1817
- properties: {
1818
- table_name: {
1819
- type: "string",
1820
- description: "Name of the table to backup",
1821
- },
1822
- include_data: {
1823
- type: "boolean",
1824
- description: "Include table data in the backup (default: true)",
1825
- },
1826
- include_drop: {
1827
- type: "boolean",
1828
- description: "Include DROP TABLE IF EXISTS statement (default: true)",
1829
- },
1830
- database: {
1831
- type: "string",
1832
- description: "Optional: specific database name",
1833
- },
1834
- },
1835
- required: ["table_name"],
1836
- },
1837
- },
1838
- {
1839
- name: "backup_database",
1840
- description: "💾 Creates SQL dump backup of entire database or specific tables. Includes structure and optionally data. Returns backup as SQL text. Use before major schema changes or migrations.",
1841
- inputSchema: {
1842
- type: "object",
1843
- properties: {
1844
- include_data: {
1845
- type: "boolean",
1846
- description: "Include table data in the backup (default: true)",
1847
- },
1848
- include_drop: {
1849
- type: "boolean",
1850
- description: "Include DROP TABLE IF EXISTS statements (default: true)",
1851
- },
1852
- tables: {
1853
- type: "array",
1854
- items: { type: "string" },
1855
- description: "Optional: specific tables to backup (default: all tables)",
1856
- },
1857
- database: {
1858
- type: "string",
1859
- description: "Optional: specific database name",
1860
- },
1861
- },
1862
- },
1863
- },
1864
- {
1865
- name: "restore_from_sql",
1866
- description: "Restore database from SQL dump content. Executes SQL statements from the provided dump. Requires 'ddl' permission.",
1867
- inputSchema: {
1868
- type: "object",
1869
- properties: {
1870
- sql_dump: {
1871
- type: "string",
1872
- description: "SQL dump content to restore",
1873
- },
1874
- stop_on_error: {
1875
- type: "boolean",
1876
- description: "Stop execution on first error (default: true)",
1877
- },
1878
- database: {
1879
- type: "string",
1880
- description: "Optional: specific database name",
1881
- },
1882
- },
1883
- required: ["sql_dump"],
1884
- },
1885
- },
1886
- {
1887
- name: "get_create_table_statement",
1888
- description: "Get the CREATE TABLE statement for a specific table.",
1889
- inputSchema: {
1890
- type: "object",
1891
- properties: {
1892
- table_name: {
1893
- type: "string",
1894
- description: "Name of the table",
1895
- },
1896
- database: {
1897
- type: "string",
1898
- description: "Optional: specific database name",
1899
- },
1900
- },
1901
- required: ["table_name"],
1902
- },
1903
- },
1904
- {
1905
- name: "get_database_schema",
1906
- description: "Get complete database schema including tables, views, procedures, functions, and triggers.",
1907
- inputSchema: {
1908
- type: "object",
1909
- properties: {
1910
- database: {
1911
- type: "string",
1912
- description: "Optional: specific database name",
1913
- },
1914
- include_views: {
1915
- type: "boolean",
1916
- description: "Include views in schema (default: true)",
1917
- },
1918
- include_procedures: {
1919
- type: "boolean",
1920
- description: "Include stored procedures in schema (default: true)",
1921
- },
1922
- include_functions: {
1923
- type: "boolean",
1924
- description: "Include functions in schema (default: true)",
1925
- },
1926
- include_triggers: {
1927
- type: "boolean",
1928
- description: "Include triggers in schema (default: true)",
1929
- },
1930
- },
1931
- },
1932
- },
1933
1679
  {
1934
1680
  name: "create_fulltext_index",
1935
1681
  description: "Creates a FULLTEXT index on one or more text columns in a table. Supports ngram and mecab parsers for advanced text search capabilities (useful for languages like Chinese, Japanese, Korean). Use this to enable full-text search on text columns.",
@@ -2104,7 +1850,7 @@ const TOOLS = [
2104
1850
  // Create the MCP server
2105
1851
  const server = new index_js_1.Server({
2106
1852
  name: "mysql-mcp-server",
2107
- version: "1.28.0",
1853
+ version: "1.40.2",
2108
1854
  }, {
2109
1855
  capabilities: {
2110
1856
  tools: {},
@@ -2112,17 +1858,7 @@ const server = new index_js_1.Server({
2112
1858
  });
2113
1859
  // Handle list tools request - filter tools based on permissions and categories
2114
1860
  server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => {
2115
- // Filter tools to only return those that are enabled based on current config
2116
- const enabledTools = TOOLS.filter((tool) => {
2117
- // Convert tool name from snake_case to camelCase for checking
2118
- // e.g., "list_databases" -> "listDatabases"
2119
- const toolNameCamelCase = tool.name.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
2120
- // Check if tool is enabled based on permissions and categories
2121
- // Most tools are keyed in featureConfig using camelCase, but a few legacy/meta tools
2122
- // are keyed using their snake_case MCP names (e.g., read_changelog, list_all_tools).
2123
- return (mysqlMCP.isToolEnabled(toolNameCamelCase) ||
2124
- mysqlMCP.isToolEnabled(tool.name));
2125
- });
1861
+ const enabledTools = (0, toolRegistry_js_1.getEnabledTools)(mysqlMCP, TOOLS);
2126
1862
  // Log the filtering results
2127
1863
  console.error(`Tools available: ${enabledTools.length} of ${TOOLS.length} total tools`);
2128
1864
  return {
@@ -2133,7 +1869,7 @@ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => {
2133
1869
  server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
2134
1870
  const { name, arguments: args } = request.params;
2135
1871
  // Validate tool arguments before execution
2136
- const validation = validateToolArguments(name, args);
1872
+ const validation = (0, toolArgumentValidation_js_1.validateToolArguments)(name, args);
2137
1873
  if (!validation.valid) {
2138
1874
  return {
2139
1875
  content: [
@@ -2308,25 +2044,6 @@ server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
2308
2044
  case "show_create_trigger":
2309
2045
  result = await mysqlMCP.showCreateTrigger((args || {}));
2310
2046
  break;
2311
- // Function Tools
2312
- case "list_functions":
2313
- result = await mysqlMCP.listFunctions((args || {}));
2314
- break;
2315
- case "get_function_info":
2316
- result = await mysqlMCP.getFunctionInfo((args || {}));
2317
- break;
2318
- case "create_function":
2319
- result = await mysqlMCP.createFunction((args || {}));
2320
- break;
2321
- case "drop_function":
2322
- result = await mysqlMCP.dropFunction((args || {}));
2323
- break;
2324
- case "show_create_function":
2325
- result = await mysqlMCP.showCreateFunction((args || {}));
2326
- break;
2327
- case "execute_function":
2328
- result = await mysqlMCP.executeFunction((args || {}));
2329
- break;
2330
2047
  // Index Tools
2331
2048
  case "list_indexes":
2332
2049
  result = await mysqlMCP.listIndexes((args || {}));
@@ -2488,52 +2205,6 @@ server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
2488
2205
  };
2489
2206
  }
2490
2207
  });
2491
- // Validation function to validate tool arguments before execution
2492
- function validateToolArguments(name, args) {
2493
- if (!args)
2494
- return { valid: true }; // Some tools don't require arguments
2495
- try {
2496
- switch (name) {
2497
- case "create_record":
2498
- return (0, inputValidation_js_1.validateCreateRecord)(args);
2499
- case "read_records":
2500
- return (0, inputValidation_js_1.validateReadRecords)(args);
2501
- case "update_record":
2502
- return (0, inputValidation_js_1.validateUpdateRecord)(args);
2503
- case "delete_record":
2504
- return (0, inputValidation_js_1.validateDeleteRecord)(args);
2505
- case "run_select_query":
2506
- case "execute_write_query":
2507
- case "execute_ddl":
2508
- return (0, inputValidation_js_1.validateQuery)({ query: args?.query || "" });
2509
- case "bulk_insert":
2510
- return (0, inputValidation_js_1.validateBulkInsert)(args);
2511
- case "list_tables":
2512
- case "get_schema_erd":
2513
- case "get_schema_rag_context":
2514
- case "get_database_summary":
2515
- if (args.database !== undefined) {
2516
- const validation = (0, inputValidation_js_1.validateValue)(args.database);
2517
- if (!validation.valid)
2518
- return { valid: false, errors: [validation.error || 'Invalid database name'] };
2519
- }
2520
- return { valid: true };
2521
- case "get_column_statistics":
2522
- case "read_table_schema":
2523
- if (args.table_name) {
2524
- const validation = (0, inputValidation_js_1.validateTableName)(args.table_name);
2525
- if (!validation.valid)
2526
- return { valid: false, errors: [validation.error || 'Invalid table name'] };
2527
- }
2528
- return { valid: true };
2529
- default:
2530
- return { valid: true }; // For tools without specific validation
2531
- }
2532
- }
2533
- catch (error) {
2534
- return { valid: false, errors: [`Validation error: ${error instanceof Error ? error.message : 'Unknown validation error'}`] };
2535
- }
2536
- }
2537
2208
  // Start the server
2538
2209
  async function main() {
2539
2210
  const transport = new stdio_js_1.StdioServerTransport();
@@ -0,0 +1,4 @@
1
+ export declare function validateToolArguments(name: string, args: any): {
2
+ valid: boolean;
3
+ errors?: string[];
4
+ };
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateToolArguments = validateToolArguments;
4
+ const inputValidation_js_1 = require("../validation/inputValidation.js");
5
+ function validateToolArguments(name, args) {
6
+ if (!args)
7
+ return { valid: true };
8
+ try {
9
+ switch (name) {
10
+ case "create_record":
11
+ return (0, inputValidation_js_1.validateCreateRecord)(args);
12
+ case "read_records":
13
+ return (0, inputValidation_js_1.validateReadRecords)(args);
14
+ case "update_record":
15
+ return (0, inputValidation_js_1.validateUpdateRecord)(args);
16
+ case "delete_record":
17
+ return (0, inputValidation_js_1.validateDeleteRecord)(args);
18
+ case "run_select_query":
19
+ case "execute_write_query":
20
+ case "execute_ddl":
21
+ return (0, inputValidation_js_1.validateQuery)({ query: args?.query || "" });
22
+ case "bulk_insert":
23
+ return (0, inputValidation_js_1.validateBulkInsert)(args);
24
+ case "list_tables":
25
+ case "get_schema_erd":
26
+ case "get_schema_rag_context":
27
+ case "get_database_summary":
28
+ if (args.database !== undefined) {
29
+ const validation = (0, inputValidation_js_1.validateValue)(args.database);
30
+ if (!validation.valid) {
31
+ return {
32
+ valid: false,
33
+ errors: [validation.error || "Invalid database name"],
34
+ };
35
+ }
36
+ }
37
+ return { valid: true };
38
+ case "get_column_statistics":
39
+ case "read_table_schema":
40
+ if (args.table_name) {
41
+ const validation = (0, inputValidation_js_1.validateTableName)(args.table_name);
42
+ if (!validation.valid) {
43
+ return {
44
+ valid: false,
45
+ errors: [validation.error || "Invalid table name"],
46
+ };
47
+ }
48
+ }
49
+ return { valid: true };
50
+ default:
51
+ return { valid: true };
52
+ }
53
+ }
54
+ catch (error) {
55
+ return {
56
+ valid: false,
57
+ errors: [
58
+ `Validation error: ${error instanceof Error ? error.message : "Unknown validation error"}`,
59
+ ],
60
+ };
61
+ }
62
+ }
@@ -0,0 +1,4 @@
1
+ import { Tool } from "@modelcontextprotocol/sdk/types.js";
2
+ import { MySQLMCP } from "../index.js";
3
+ export declare const isToolEnabled: (mysqlMCP: MySQLMCP, tool: Tool) => boolean;
4
+ export declare const getEnabledTools: (mysqlMCP: MySQLMCP, tools: Tool[]) => Tool[];
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getEnabledTools = exports.isToolEnabled = void 0;
4
+ const toCamelCase = (value) => value.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
5
+ const isToolEnabled = (mysqlMCP, tool) => {
6
+ const camelCaseName = toCamelCase(tool.name);
7
+ return mysqlMCP.isToolEnabled(camelCaseName) || mysqlMCP.isToolEnabled(tool.name);
8
+ };
9
+ exports.isToolEnabled = isToolEnabled;
10
+ const getEnabledTools = (mysqlMCP, tools) => tools.filter((tool) => (0, exports.isToolEnabled)(mysqlMCP, tool));
11
+ exports.getEnabledTools = getEnabledTools;
package/manifest.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mysql-mcp",
3
3
  "description": "A Model Context Protocol for MySQL database interaction",
4
- "version": "1.26.1",
4
+ "version": "1.40.2",
5
5
  "tools": [
6
6
  {
7
7
  "name": "list_databases",
@@ -730,4 +730,4 @@
730
730
  }
731
731
  }
732
732
  ]
733
- }
733
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@berthojoris/mcp-mysql-server",
3
- "version": "1.40.0",
4
- "description": "Model Context Protocol server for MySQL database integration with dynamic per-project permissions, backup/restore capabilities",
3
+ "version": "1.40.2",
4
+ "description": "Model Context Protocol server for MySQL database integration with dynamic per-project permissions",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "type": "commonjs",
@@ -77,4 +77,4 @@
77
77
  "ts-node": "^10.9.1",
78
78
  "typescript": "^5.2.2"
79
79
  }
80
- }
80
+ }