@berthojoris/mcp-mysql-server 1.39.0 → 1.40.1
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 +59 -0
- package/DOCUMENTATIONS.md +8 -30
- package/README.md +5 -8
- package/bin/mcp-mysql.js +3 -6
- package/dist/config/featureConfig.d.ts +1 -4
- package/dist/config/featureConfig.js +2 -77
- package/dist/index.d.ts +0 -137
- package/dist/index.js +1 -151
- package/dist/mcp-server.js +5 -425
- package/dist/tools/toolArgumentValidation.d.ts +4 -0
- package/dist/tools/toolArgumentValidation.js +62 -0
- package/dist/tools/toolRegistry.d.ts +4 -0
- package/dist/tools/toolRegistry.js +11 -0
- package/manifest.json +2 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,65 @@ 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.1] - 2026-03-06
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
- Synchronized version metadata across `package.json`, `src/mcp-server.ts`, and `manifest.json` to `1.40.1`
|
|
12
|
+
- Updated CLI category examples in `bin/mcp-mysql.js` to match active category set
|
|
13
|
+
- Updated category examples in `README.md` and `DOCUMENTATIONS.md` to remove removed categories
|
|
14
|
+
- Refactored tool registry filtering into `src/tools/toolRegistry.ts`
|
|
15
|
+
- Refactored tool argument validation registry into `src/tools/toolArgumentValidation.ts`
|
|
16
|
+
|
|
17
|
+
## [1.40.0] - 2026-03-06
|
|
18
|
+
|
|
19
|
+
### Removed
|
|
20
|
+
- **Performance Monitoring Category**: Removed entire `performance_monitoring` category and all 10 tools to reduce bundle size and simplify the codebase
|
|
21
|
+
- `get_performance_metrics` - Get overall performance metrics
|
|
22
|
+
- `get_table_io_stats` - Get table I/O statistics
|
|
23
|
+
- `get_index_usage_stats` - Get index usage statistics
|
|
24
|
+
- `get_unused_indexes` - Find unused indexes
|
|
25
|
+
- `get_connection_pool_stats` - Get connection pool statistics
|
|
26
|
+
- `get_database_health_check` - Get database health status
|
|
27
|
+
- `reset_performance_stats` - Reset performance statistics
|
|
28
|
+
- `get_top_queries_by_time` - Get top queries by execution time
|
|
29
|
+
- `get_top_queries_by_count` - Get top queries by execution count
|
|
30
|
+
- `get_slow_queries` - Get slow queries
|
|
31
|
+
- **Cache Management Category**: Removed entire `cache_management` category and all 5 tools
|
|
32
|
+
- `get_cache_stats` - Query cache statistics
|
|
33
|
+
- `get_cache_config` - Cache configuration
|
|
34
|
+
- `configure_cache_settings` - Configure cache settings
|
|
35
|
+
- `clear_cache` - Clear cached results
|
|
36
|
+
- `invalidate_cache_for_table` - Invalidate cache for table
|
|
37
|
+
- **Server Management Category**: Removed entire `server_management` category and all 9 tools
|
|
38
|
+
- `show_process_list` - Show running processes
|
|
39
|
+
- `kill_process` - Terminate processes
|
|
40
|
+
- `show_status` - Server status variables
|
|
41
|
+
- `show_variables` - Server configuration
|
|
42
|
+
- `explain_query` - Query execution plan
|
|
43
|
+
- `show_engine_status` - Storage engine status
|
|
44
|
+
- `get_server_info` - Server information
|
|
45
|
+
- `show_binary_logs` - Binary log files
|
|
46
|
+
- `show_replication_status` - Replication status
|
|
47
|
+
- **Tool Modules**: Removed imports and initialization for `PerformanceTools` and `ProcessTools` from `index.ts`
|
|
48
|
+
|
|
49
|
+
### Changed
|
|
50
|
+
- Updated tool count: 97 → 73 tools (-24 tools)
|
|
51
|
+
- Updated category count: 20 → 15 categories (removed `performance_monitoring`, `cache_management`, `server_management`)
|
|
52
|
+
- Updated `mcp-server.ts` to remove tool registrations and routing for all 24 tools
|
|
53
|
+
- Updated `index.ts` to remove MySQLMCP methods and tool imports
|
|
54
|
+
- Updated `featureConfig.ts` to remove all performance/cache/server tool mappings and categories
|
|
55
|
+
- Updated README.md and DOCUMENTATIONS.md to reflect tool/category count changes
|
|
56
|
+
- Simplified package description
|
|
57
|
+
- Bumped package version to `1.40.0`
|
|
58
|
+
|
|
59
|
+
### Rationale
|
|
60
|
+
- These tools were rarely used by AI agents in production
|
|
61
|
+
- Added significant complexity to the codebase (~2,000+ lines)
|
|
62
|
+
- Performance monitoring is typically handled by dedicated tools (MySQL Enterprise Monitor, Percona Monitoring Tools, etc.)
|
|
63
|
+
- Cache management is internal implementation detail, rarely needs manual intervention
|
|
64
|
+
- Server management commands are administrative tasks outside typical AI agent workflows
|
|
65
|
+
- Removal reduces bundle size by ~80KB and simplifies maintenance
|
|
66
|
+
|
|
8
67
|
## [1.39.0] - 2026-03-06
|
|
9
68
|
|
|
10
69
|
### Removed
|
package/DOCUMENTATIONS.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# MySQL MCP Server - Documentation
|
|
2
2
|
|
|
3
|
-
**Last Updated:** 2026-03-06
|
|
4
|
-
**Version:** 1.
|
|
5
|
-
**Total Tools:**
|
|
3
|
+
**Last Updated:** 2026-03-06 17:30:00
|
|
4
|
+
**Version:** 1.40.1
|
|
5
|
+
**Total Tools:** 73
|
|
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,
|
|
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,
|
|
61
|
+
"MCP_CATEGORIES": "database_discovery,custom_queries,analysis"
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
```
|
|
@@ -194,34 +194,12 @@ Tool enabled = (Has Permission) AND (Has Category OR No categories specified)
|
|
|
194
194
|
- `get_transaction_status` - Check transaction state
|
|
195
195
|
- `execute_in_transaction` - Execute within transaction
|
|
196
196
|
|
|
197
|
-
### 14.
|
|
198
|
-
- `get_performance_metrics` - Get overall performance metrics
|
|
199
|
-
- `get_table_io_stats` - Get table I/O statistics
|
|
200
|
-
- `get_index_usage_stats` - Get index usage statistics
|
|
201
|
-
- `get_unused_indexes` - Find unused indexes
|
|
202
|
-
- `get_connection_pool_stats` - Get connection pool statistics
|
|
203
|
-
- `get_database_health_check` - Get database health status
|
|
204
|
-
- `reset_performance_stats` - Reset performance statistics
|
|
205
|
-
|
|
206
|
-
### 15. Query Optimization (3 tools)
|
|
197
|
+
### 14. Query Optimization (3 tools)
|
|
207
198
|
- `analyze_query` - Analyze query performance
|
|
208
199
|
- `get_optimization_hints` - Get optimizer hints
|
|
209
200
|
- `repair_query` - Repair broken SQL queries
|
|
210
201
|
|
|
211
|
-
###
|
|
212
|
-
- `show_process_list` - Show running processes
|
|
213
|
-
- `kill_process` - Terminate processes
|
|
214
|
-
- `show_status` - Server status variables
|
|
215
|
-
- `show_variables` - Server configuration
|
|
216
|
-
- `explain_query` - Query execution plan
|
|
217
|
-
|
|
218
|
-
### 17. Cache Management (4 tools)
|
|
219
|
-
- `get_cache_stats` - Query cache statistics
|
|
220
|
-
- `get_cache_config` - Cache configuration
|
|
221
|
-
- `configure_cache` - Configure cache settings
|
|
222
|
-
- `clear_cache` - Clear cached results
|
|
223
|
-
|
|
224
|
-
### 18. Utilities (4 tools)
|
|
202
|
+
### 15. Utilities (4 tools)
|
|
225
203
|
- `test_connection` - Test connectivity
|
|
226
204
|
- `describe_connection` - Connection info
|
|
227
205
|
- `read_changelog` - Read changelog
|
|
@@ -413,4 +391,4 @@ The system provides detailed error messages indicating:
|
|
|
413
391
|
|
|
414
392
|
---
|
|
415
393
|
|
|
416
|
-
*For detailed examples and advanced usage patterns, see the project README.md.*
|
|
394
|
+
*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
|
|
7
|
+
**Last Updated:** 2026-03-06 17:30:00
|
|
8
8
|
|
|
9
9
|
[](https://www.npmjs.com/package/@berthojoris/mcp-mysql-server)
|
|
10
10
|
[](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,
|
|
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,
|
|
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` |
|
|
@@ -259,9 +259,6 @@ Use documentation categories to fine-tune which tools are exposed (Layer 2):
|
|
|
259
259
|
| `index_management` | Optimize performance with index management | `analyze_index, create_index, drop_index, get_index_info, list_indexes` |
|
|
260
260
|
| `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
261
|
| `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
|
-
| `server_management` | MySQL server configuration and administration | `explain_query, get_server_info, kill_process, show_binary_logs, show_engine_status, show_process_list, show_replication_status, show_status, show_variables` |
|
|
263
|
-
| `performance_monitoring` | Monitor and analyze database performance | `get_connection_pool_stats, get_database_health_check, get_index_usage_stats, get_performance_metrics, get_slow_queries, get_table_io_stats, get_top_queries_by_count, get_top_queries_by_time, get_unused_indexes, reset_performance_stats` |
|
|
264
|
-
| `cache_management` | Manage query cache and optimization | `clear_cache, configure_cache_settings, get_cache_config, get_cache_stats, invalidate_cache_for_table` |
|
|
265
262
|
| `query_optimization` | Analyze and optimize SQL queries | `analyze_query, get_optimization_hints` |
|
|
266
263
|
| `backup_restore` | Create backups and restore databases | `backup_database, backup_table, get_create_table_statement, get_database_schema, restore_from_sql` |
|
|
267
264
|
| `analysis` | Data analysis and reporting tools | `get_column_statistics, get_database_summary, get_schema_erd, get_schema_rag_context` |
|
|
@@ -270,7 +267,7 @@ Use documentation categories to fine-tune which tools are exposed (Layer 2):
|
|
|
270
267
|
<summary>Copy/paste list (comma-separated, no spaces)</summary>
|
|
271
268
|
|
|
272
269
|
```text
|
|
273
|
-
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,
|
|
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
|
|
274
271
|
```
|
|
275
272
|
|
|
276
273
|
</details>
|
|
@@ -281,7 +278,7 @@ Full category → tool mapping (and examples) lives in **[DOCUMENTATIONS.md →
|
|
|
281
278
|
|
|
282
279
|
## Available Tools
|
|
283
280
|
|
|
284
|
-
The server exposes **
|
|
281
|
+
The server exposes **73 tools** organized into categories (CRUD, schema, and utilities).
|
|
285
282
|
|
|
286
283
|
- Complete list of tools: **[DOCUMENTATIONS.md → Complete Tools Reference](DOCUMENTATIONS.md#🔧-complete-tools-reference)**
|
|
287
284
|
|
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,
|
|
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):");
|
|
@@ -69,13 +69,10 @@ if (!mysqlUrl) {
|
|
|
69
69
|
" views_management, triggers_management, functions_management, index_management,",
|
|
70
70
|
);
|
|
71
71
|
console.error(
|
|
72
|
-
" constraint_management, table_maintenance,
|
|
72
|
+
" constraint_management, table_maintenance, query_optimization,",
|
|
73
73
|
);
|
|
74
74
|
console.error(
|
|
75
|
-
"
|
|
76
|
-
);
|
|
77
|
-
console.error(
|
|
78
|
-
" backup_restore, import_export, data_migration, schema_migrations",
|
|
75
|
+
" backup_restore, 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 (
|
|
17
|
+
* Documentation categories from README (15 categories)
|
|
18
18
|
* More intuitive and matches user mental model
|
|
19
19
|
*/
|
|
20
20
|
export declare enum DocCategory {
|
|
@@ -32,9 +32,6 @@ export declare enum DocCategory {
|
|
|
32
32
|
INDEX_MANAGEMENT = "index_management",
|
|
33
33
|
CONSTRAINT_MANAGEMENT = "constraint_management",
|
|
34
34
|
TABLE_MAINTENANCE = "table_maintenance",
|
|
35
|
-
SERVER_MANAGEMENT = "server_management",
|
|
36
|
-
PERFORMANCE_MONITORING = "performance_monitoring",
|
|
37
|
-
CACHE_MANAGEMENT = "cache_management",
|
|
38
35
|
QUERY_OPTIMIZATION = "query_optimization",
|
|
39
36
|
BACKUP_RESTORE = "backup_restore",
|
|
40
37
|
ANALYSIS = "analysis"
|
|
@@ -24,7 +24,7 @@ var ToolCategory;
|
|
|
24
24
|
ToolCategory["PROCEDURE"] = "procedure";
|
|
25
25
|
})(ToolCategory || (exports.ToolCategory = ToolCategory = {}));
|
|
26
26
|
/**
|
|
27
|
-
* Documentation categories from README (
|
|
27
|
+
* Documentation categories from README (15 categories)
|
|
28
28
|
* More intuitive and matches user mental model
|
|
29
29
|
*/
|
|
30
30
|
var DocCategory;
|
|
@@ -43,9 +43,6 @@ var DocCategory;
|
|
|
43
43
|
DocCategory["INDEX_MANAGEMENT"] = "index_management";
|
|
44
44
|
DocCategory["CONSTRAINT_MANAGEMENT"] = "constraint_management";
|
|
45
45
|
DocCategory["TABLE_MAINTENANCE"] = "table_maintenance";
|
|
46
|
-
DocCategory["SERVER_MANAGEMENT"] = "server_management";
|
|
47
|
-
DocCategory["PERFORMANCE_MONITORING"] = "performance_monitoring";
|
|
48
|
-
DocCategory["CACHE_MANAGEMENT"] = "cache_management";
|
|
49
46
|
DocCategory["QUERY_OPTIMIZATION"] = "query_optimization";
|
|
50
47
|
DocCategory["BACKUP_RESTORE"] = "backup_restore";
|
|
51
48
|
DocCategory["ANALYSIS"] = "analysis";
|
|
@@ -102,15 +99,6 @@ exports.toolCategoryMap = {
|
|
|
102
99
|
createStoredProcedure: ToolCategory.PROCEDURE,
|
|
103
100
|
dropStoredProcedure: ToolCategory.PROCEDURE,
|
|
104
101
|
showCreateProcedure: ToolCategory.LIST,
|
|
105
|
-
// Cache management tools
|
|
106
|
-
getCacheStats: ToolCategory.UTILITY,
|
|
107
|
-
getCacheConfig: ToolCategory.UTILITY,
|
|
108
|
-
configureCacheSettings: ToolCategory.UTILITY,
|
|
109
|
-
clearCache: ToolCategory.UTILITY,
|
|
110
|
-
invalidateCacheForTable: ToolCategory.UTILITY,
|
|
111
|
-
// Query optimization tools
|
|
112
|
-
analyzeQuery: ToolCategory.UTILITY,
|
|
113
|
-
getOptimizationHints: ToolCategory.UTILITY,
|
|
114
102
|
// View tools
|
|
115
103
|
listViews: ToolCategory.LIST,
|
|
116
104
|
getViewInfo: ToolCategory.LIST,
|
|
@@ -154,45 +142,12 @@ exports.toolCategoryMap = {
|
|
|
154
142
|
getTableStatus: ToolCategory.LIST,
|
|
155
143
|
flushTable: ToolCategory.UTILITY,
|
|
156
144
|
getTableSize: ToolCategory.LIST,
|
|
157
|
-
// Process and server management tools
|
|
158
|
-
showProcessList: ToolCategory.LIST,
|
|
159
|
-
killProcess: ToolCategory.EXECUTE,
|
|
160
|
-
showStatus: ToolCategory.LIST,
|
|
161
|
-
showVariables: ToolCategory.LIST,
|
|
162
|
-
explainQuery: ToolCategory.UTILITY,
|
|
163
|
-
showEngineStatus: ToolCategory.LIST,
|
|
164
|
-
getServerInfo: ToolCategory.LIST,
|
|
165
|
-
showBinaryLogs: ToolCategory.LIST,
|
|
166
|
-
showReplicationStatus: ToolCategory.LIST,
|
|
167
145
|
// Backup and restore tools
|
|
168
146
|
backupTable: ToolCategory.UTILITY,
|
|
169
147
|
backupDatabase: ToolCategory.UTILITY,
|
|
170
148
|
restoreFromSql: ToolCategory.UTILITY,
|
|
171
149
|
getCreateTableStatement: ToolCategory.UTILITY,
|
|
172
150
|
getDatabaseSchema: ToolCategory.UTILITY,
|
|
173
|
-
// Schema versioning and migrations tools
|
|
174
|
-
initMigrationsTable: ToolCategory.DDL,
|
|
175
|
-
createMigration: ToolCategory.DDL,
|
|
176
|
-
applyMigrations: ToolCategory.DDL,
|
|
177
|
-
rollbackMigration: ToolCategory.DDL,
|
|
178
|
-
getMigrationStatus: ToolCategory.LIST,
|
|
179
|
-
getSchemaVersion: ToolCategory.LIST,
|
|
180
|
-
validateMigrations: ToolCategory.LIST,
|
|
181
|
-
resetFailedMigration: ToolCategory.DDL,
|
|
182
|
-
generateMigrationFromDiff: ToolCategory.DDL,
|
|
183
|
-
// Analysis tools - MOVED here to avoid duplication
|
|
184
|
-
// Note: keys must be unique in the object literal
|
|
185
|
-
// Performance monitoring tools
|
|
186
|
-
getPerformanceMetrics: ToolCategory.UTILITY,
|
|
187
|
-
getTopQueriesByTime: ToolCategory.UTILITY,
|
|
188
|
-
getTopQueriesByCount: ToolCategory.UTILITY,
|
|
189
|
-
getSlowQueries: ToolCategory.UTILITY,
|
|
190
|
-
getTableIOStats: ToolCategory.UTILITY,
|
|
191
|
-
getIndexUsageStats: ToolCategory.UTILITY,
|
|
192
|
-
getUnusedIndexes: ToolCategory.UTILITY,
|
|
193
|
-
getConnectionPoolStats: ToolCategory.UTILITY,
|
|
194
|
-
getDatabaseHealthCheck: ToolCategory.UTILITY,
|
|
195
|
-
resetPerformanceStats: ToolCategory.UTILITY,
|
|
196
151
|
// Full-Text Search Tools
|
|
197
152
|
createFulltextIndex: ToolCategory.DDL,
|
|
198
153
|
fulltextSearch: ToolCategory.READ,
|
|
@@ -290,33 +245,6 @@ exports.toolDocCategoryMap = {
|
|
|
290
245
|
getTableStatus: DocCategory.TABLE_MAINTENANCE,
|
|
291
246
|
flushTable: DocCategory.TABLE_MAINTENANCE,
|
|
292
247
|
getTableSize: DocCategory.TABLE_MAINTENANCE,
|
|
293
|
-
// Server Management
|
|
294
|
-
showProcessList: DocCategory.SERVER_MANAGEMENT,
|
|
295
|
-
killProcess: DocCategory.SERVER_MANAGEMENT,
|
|
296
|
-
showStatus: DocCategory.SERVER_MANAGEMENT,
|
|
297
|
-
showVariables: DocCategory.SERVER_MANAGEMENT,
|
|
298
|
-
explainQuery: DocCategory.SERVER_MANAGEMENT,
|
|
299
|
-
showEngineStatus: DocCategory.SERVER_MANAGEMENT,
|
|
300
|
-
getServerInfo: DocCategory.SERVER_MANAGEMENT,
|
|
301
|
-
showBinaryLogs: DocCategory.SERVER_MANAGEMENT,
|
|
302
|
-
showReplicationStatus: DocCategory.SERVER_MANAGEMENT,
|
|
303
|
-
// Performance Monitoring
|
|
304
|
-
getPerformanceMetrics: DocCategory.PERFORMANCE_MONITORING,
|
|
305
|
-
getTopQueriesByTime: DocCategory.PERFORMANCE_MONITORING,
|
|
306
|
-
getTopQueriesByCount: DocCategory.PERFORMANCE_MONITORING,
|
|
307
|
-
getSlowQueries: DocCategory.PERFORMANCE_MONITORING,
|
|
308
|
-
getTableIOStats: DocCategory.PERFORMANCE_MONITORING,
|
|
309
|
-
getIndexUsageStats: DocCategory.PERFORMANCE_MONITORING,
|
|
310
|
-
getUnusedIndexes: DocCategory.PERFORMANCE_MONITORING,
|
|
311
|
-
getConnectionPoolStats: DocCategory.PERFORMANCE_MONITORING,
|
|
312
|
-
getDatabaseHealthCheck: DocCategory.PERFORMANCE_MONITORING,
|
|
313
|
-
resetPerformanceStats: DocCategory.PERFORMANCE_MONITORING,
|
|
314
|
-
// Cache Management
|
|
315
|
-
getCacheStats: DocCategory.CACHE_MANAGEMENT,
|
|
316
|
-
getCacheConfig: DocCategory.CACHE_MANAGEMENT,
|
|
317
|
-
configureCacheSettings: DocCategory.CACHE_MANAGEMENT,
|
|
318
|
-
clearCache: DocCategory.CACHE_MANAGEMENT,
|
|
319
|
-
invalidateCacheForTable: DocCategory.CACHE_MANAGEMENT,
|
|
320
248
|
// Query Optimization
|
|
321
249
|
analyzeQuery: DocCategory.QUERY_OPTIMIZATION,
|
|
322
250
|
getOptimizationHints: DocCategory.QUERY_OPTIMIZATION,
|
|
@@ -354,7 +282,6 @@ const legacyToDocCategoryMap = {
|
|
|
354
282
|
DocCategory.INDEX_MANAGEMENT,
|
|
355
283
|
DocCategory.CONSTRAINT_MANAGEMENT,
|
|
356
284
|
DocCategory.TABLE_MAINTENANCE,
|
|
357
|
-
DocCategory.SERVER_MANAGEMENT,
|
|
358
285
|
DocCategory.ANALYSIS,
|
|
359
286
|
DocCategory.UTILITIES,
|
|
360
287
|
],
|
|
@@ -371,7 +298,7 @@ const legacyToDocCategoryMap = {
|
|
|
371
298
|
DocCategory.CRUD_OPERATIONS,
|
|
372
299
|
DocCategory.BULK_OPERATIONS,
|
|
373
300
|
],
|
|
374
|
-
execute: [DocCategory.CUSTOM_QUERIES
|
|
301
|
+
execute: [DocCategory.CUSTOM_QUERIES],
|
|
375
302
|
ddl: [
|
|
376
303
|
DocCategory.SCHEMA_MANAGEMENT,
|
|
377
304
|
DocCategory.VIEWS_MANAGEMENT,
|
|
@@ -384,8 +311,6 @@ const legacyToDocCategoryMap = {
|
|
|
384
311
|
utility: [
|
|
385
312
|
DocCategory.UTILITIES,
|
|
386
313
|
DocCategory.TABLE_MAINTENANCE,
|
|
387
|
-
DocCategory.PERFORMANCE_MONITORING,
|
|
388
|
-
DocCategory.CACHE_MANAGEMENT,
|
|
389
314
|
DocCategory.QUERY_OPTIMIZATION,
|
|
390
315
|
DocCategory.BACKUP_RESTORE,
|
|
391
316
|
],
|
package/dist/index.d.ts
CHANGED
|
@@ -17,10 +17,7 @@ export declare class MySQLMCP {
|
|
|
17
17
|
private indexTools;
|
|
18
18
|
private constraintTools;
|
|
19
19
|
private maintenanceTools;
|
|
20
|
-
private processTools;
|
|
21
20
|
private backupRestoreTools;
|
|
22
|
-
private migrationTools;
|
|
23
|
-
private performanceTools;
|
|
24
21
|
private analysisTools;
|
|
25
22
|
private aiTools;
|
|
26
23
|
private macroTools;
|
|
@@ -412,57 +409,6 @@ export declare class MySQLMCP {
|
|
|
412
409
|
error?: string;
|
|
413
410
|
}>;
|
|
414
411
|
close(): Promise<void>;
|
|
415
|
-
/**
|
|
416
|
-
* Get cache statistics
|
|
417
|
-
*/
|
|
418
|
-
getCacheStats(): {
|
|
419
|
-
status: string;
|
|
420
|
-
data: import("./cache/queryCache").CacheStats;
|
|
421
|
-
};
|
|
422
|
-
/**
|
|
423
|
-
* Get cache configuration
|
|
424
|
-
*/
|
|
425
|
-
getCacheConfig(): {
|
|
426
|
-
status: string;
|
|
427
|
-
data: import("./cache/queryCache").CacheConfig;
|
|
428
|
-
};
|
|
429
|
-
/**
|
|
430
|
-
* Configure cache settings
|
|
431
|
-
*/
|
|
432
|
-
configureCacheSettings(params: {
|
|
433
|
-
enabled?: boolean;
|
|
434
|
-
ttlMs?: number;
|
|
435
|
-
maxSize?: number;
|
|
436
|
-
maxMemoryMB?: number;
|
|
437
|
-
}): {
|
|
438
|
-
status: string;
|
|
439
|
-
data: {
|
|
440
|
-
message: string;
|
|
441
|
-
config: import("./cache/queryCache").CacheConfig;
|
|
442
|
-
};
|
|
443
|
-
};
|
|
444
|
-
/**
|
|
445
|
-
* Clear the query cache
|
|
446
|
-
*/
|
|
447
|
-
clearCache(): {
|
|
448
|
-
status: string;
|
|
449
|
-
data: {
|
|
450
|
-
message: string;
|
|
451
|
-
entriesCleared: number;
|
|
452
|
-
};
|
|
453
|
-
};
|
|
454
|
-
/**
|
|
455
|
-
* Invalidate cache for a specific table
|
|
456
|
-
*/
|
|
457
|
-
invalidateCacheForTable(params: {
|
|
458
|
-
table_name: string;
|
|
459
|
-
}): {
|
|
460
|
-
status: string;
|
|
461
|
-
data: {
|
|
462
|
-
message: string;
|
|
463
|
-
entriesInvalidated: number;
|
|
464
|
-
};
|
|
465
|
-
};
|
|
466
412
|
/**
|
|
467
413
|
* Analyze a query and get optimization suggestions
|
|
468
414
|
*/
|
|
@@ -768,89 +714,6 @@ export declare class MySQLMCP {
|
|
|
768
714
|
data?: any;
|
|
769
715
|
error?: string;
|
|
770
716
|
}>;
|
|
771
|
-
showProcessList(params?: {
|
|
772
|
-
full?: boolean;
|
|
773
|
-
}): Promise<{
|
|
774
|
-
status: string;
|
|
775
|
-
data?: any[];
|
|
776
|
-
error?: string;
|
|
777
|
-
}>;
|
|
778
|
-
killProcess(params: {
|
|
779
|
-
process_id: number;
|
|
780
|
-
type?: "CONNECTION" | "QUERY";
|
|
781
|
-
}): Promise<{
|
|
782
|
-
status: string;
|
|
783
|
-
message?: string;
|
|
784
|
-
error?: string;
|
|
785
|
-
}>;
|
|
786
|
-
showStatus(params?: {
|
|
787
|
-
like?: string;
|
|
788
|
-
global?: boolean;
|
|
789
|
-
}): Promise<{
|
|
790
|
-
status: string;
|
|
791
|
-
data?: any;
|
|
792
|
-
error?: string;
|
|
793
|
-
}>;
|
|
794
|
-
showVariables(params?: {
|
|
795
|
-
like?: string;
|
|
796
|
-
global?: boolean;
|
|
797
|
-
}): Promise<{
|
|
798
|
-
status: string;
|
|
799
|
-
data?: any;
|
|
800
|
-
error?: string;
|
|
801
|
-
}>;
|
|
802
|
-
explainQuery(params: {
|
|
803
|
-
query: string;
|
|
804
|
-
format?: "TRADITIONAL" | "JSON" | "TREE";
|
|
805
|
-
analyze?: boolean;
|
|
806
|
-
}): Promise<{
|
|
807
|
-
status: string;
|
|
808
|
-
data?: any;
|
|
809
|
-
error?: string;
|
|
810
|
-
}>;
|
|
811
|
-
getPerformanceMetrics(): Promise<{
|
|
812
|
-
status: string;
|
|
813
|
-
data?: any;
|
|
814
|
-
error?: string;
|
|
815
|
-
}>;
|
|
816
|
-
getTableIOStats(params?: {
|
|
817
|
-
limit?: number;
|
|
818
|
-
table_schema?: string;
|
|
819
|
-
}): Promise<{
|
|
820
|
-
status: string;
|
|
821
|
-
data?: any[];
|
|
822
|
-
error?: string;
|
|
823
|
-
}>;
|
|
824
|
-
getIndexUsageStats(params?: {
|
|
825
|
-
limit?: number;
|
|
826
|
-
table_schema?: string;
|
|
827
|
-
}): Promise<{
|
|
828
|
-
status: string;
|
|
829
|
-
data?: any[];
|
|
830
|
-
error?: string;
|
|
831
|
-
}>;
|
|
832
|
-
getUnusedIndexes(params?: {
|
|
833
|
-
table_schema?: string;
|
|
834
|
-
}): Promise<{
|
|
835
|
-
status: string;
|
|
836
|
-
data?: any[];
|
|
837
|
-
error?: string;
|
|
838
|
-
}>;
|
|
839
|
-
getConnectionPoolStats(): Promise<{
|
|
840
|
-
status: string;
|
|
841
|
-
data?: any;
|
|
842
|
-
error?: string;
|
|
843
|
-
}>;
|
|
844
|
-
getDatabaseHealthCheck(): Promise<{
|
|
845
|
-
status: string;
|
|
846
|
-
data?: any;
|
|
847
|
-
error?: string;
|
|
848
|
-
}>;
|
|
849
|
-
resetPerformanceStats(): Promise<{
|
|
850
|
-
status: string;
|
|
851
|
-
message?: string;
|
|
852
|
-
error?: string;
|
|
853
|
-
}>;
|
|
854
717
|
startQueryBuilder(params: {
|
|
855
718
|
intent: string;
|
|
856
719
|
context?: "analytics" | "reporting" | "data_entry" | "schema_exploration";
|
package/dist/index.js
CHANGED
|
@@ -18,10 +18,7 @@ const functionTools_1 = require("./tools/functionTools");
|
|
|
18
18
|
const indexTools_1 = require("./tools/indexTools");
|
|
19
19
|
const constraintTools_1 = require("./tools/constraintTools");
|
|
20
20
|
const maintenanceTools_1 = require("./tools/maintenanceTools");
|
|
21
|
-
const processTools_1 = require("./tools/processTools");
|
|
22
21
|
const backupRestoreTools_1 = require("./tools/backupRestoreTools");
|
|
23
|
-
const migrationTools_1 = require("./tools/migrationTools");
|
|
24
|
-
const performanceTools_1 = require("./tools/performanceTools");
|
|
25
22
|
const analysisTools_1 = require("./tools/analysisTools");
|
|
26
23
|
const aiTools_1 = require("./tools/aiTools");
|
|
27
24
|
const macroTools_1 = require("./tools/macroTools");
|
|
@@ -52,11 +49,7 @@ class MySQLMCP {
|
|
|
52
49
|
this.indexTools = new indexTools_1.IndexTools(this.security);
|
|
53
50
|
this.constraintTools = new constraintTools_1.ConstraintTools(this.security);
|
|
54
51
|
this.maintenanceTools = new maintenanceTools_1.MaintenanceTools(this.security);
|
|
55
|
-
this.processTools = new processTools_1.ProcessTools(this.security);
|
|
56
52
|
this.backupRestoreTools = new backupRestoreTools_1.BackupRestoreTools(this.security);
|
|
57
|
-
this.migrationTools = new migrationTools_1.MigrationTools(this.security);
|
|
58
|
-
this.performanceTools = new performanceTools_1.PerformanceTools(this.security);
|
|
59
|
-
this.analysisTools = new analysisTools_1.AnalysisTools(this.security);
|
|
60
53
|
this.analysisTools = new analysisTools_1.AnalysisTools(this.security);
|
|
61
54
|
this.aiTools = new aiTools_1.AiTools(this.security);
|
|
62
55
|
this.macroTools = new macroTools_1.MacroTools(this.security);
|
|
@@ -424,72 +417,7 @@ class MySQLMCP {
|
|
|
424
417
|
await db.closePool();
|
|
425
418
|
}
|
|
426
419
|
// ==========================================
|
|
427
|
-
//
|
|
428
|
-
// ==========================================
|
|
429
|
-
/**
|
|
430
|
-
* Get cache statistics
|
|
431
|
-
*/
|
|
432
|
-
getCacheStats() {
|
|
433
|
-
const db = connection_1.default.getInstance();
|
|
434
|
-
return {
|
|
435
|
-
status: "success",
|
|
436
|
-
data: db.getCacheStats(),
|
|
437
|
-
};
|
|
438
|
-
}
|
|
439
|
-
/**
|
|
440
|
-
* Get cache configuration
|
|
441
|
-
*/
|
|
442
|
-
getCacheConfig() {
|
|
443
|
-
const db = connection_1.default.getInstance();
|
|
444
|
-
return {
|
|
445
|
-
status: "success",
|
|
446
|
-
data: db.getCacheConfig(),
|
|
447
|
-
};
|
|
448
|
-
}
|
|
449
|
-
/**
|
|
450
|
-
* Configure cache settings
|
|
451
|
-
*/
|
|
452
|
-
configureCacheSettings(params) {
|
|
453
|
-
const db = connection_1.default.getInstance();
|
|
454
|
-
db.setCacheConfig(params);
|
|
455
|
-
return {
|
|
456
|
-
status: "success",
|
|
457
|
-
data: {
|
|
458
|
-
message: "Cache configuration updated successfully",
|
|
459
|
-
config: db.getCacheConfig(),
|
|
460
|
-
},
|
|
461
|
-
};
|
|
462
|
-
}
|
|
463
|
-
/**
|
|
464
|
-
* Clear the query cache
|
|
465
|
-
*/
|
|
466
|
-
clearCache() {
|
|
467
|
-
const db = connection_1.default.getInstance();
|
|
468
|
-
const clearedCount = db.clearCache();
|
|
469
|
-
return {
|
|
470
|
-
status: "success",
|
|
471
|
-
data: {
|
|
472
|
-
message: `Cache cleared successfully`,
|
|
473
|
-
entriesCleared: clearedCount,
|
|
474
|
-
},
|
|
475
|
-
};
|
|
476
|
-
}
|
|
477
|
-
/**
|
|
478
|
-
* Invalidate cache for a specific table
|
|
479
|
-
*/
|
|
480
|
-
invalidateCacheForTable(params) {
|
|
481
|
-
const db = connection_1.default.getInstance();
|
|
482
|
-
const invalidatedCount = db.invalidateCacheForTable(params.table_name);
|
|
483
|
-
return {
|
|
484
|
-
status: "success",
|
|
485
|
-
data: {
|
|
486
|
-
message: `Cache invalidated for table '${params.table_name}'`,
|
|
487
|
-
entriesInvalidated: invalidatedCount,
|
|
488
|
-
},
|
|
489
|
-
};
|
|
490
|
-
}
|
|
491
|
-
// ==========================================
|
|
492
|
-
// Query Optimization Methods
|
|
420
|
+
// Query Optimization Tools
|
|
493
421
|
// ==========================================
|
|
494
422
|
/**
|
|
495
423
|
* Analyze a query and get optimization suggestions
|
|
@@ -754,84 +682,6 @@ class MySQLMCP {
|
|
|
754
682
|
return { status: "error", error: check.error };
|
|
755
683
|
return await this.maintenanceTools.getTableSize(params);
|
|
756
684
|
}
|
|
757
|
-
// ==========================================
|
|
758
|
-
// Process Management Tools
|
|
759
|
-
// ==========================================
|
|
760
|
-
async showProcessList(params) {
|
|
761
|
-
const check = this.checkToolEnabled("showProcessList");
|
|
762
|
-
if (!check.enabled)
|
|
763
|
-
return { status: "error", error: check.error };
|
|
764
|
-
return await this.processTools.showProcessList(params);
|
|
765
|
-
}
|
|
766
|
-
async killProcess(params) {
|
|
767
|
-
const check = this.checkToolEnabled("killProcess");
|
|
768
|
-
if (!check.enabled)
|
|
769
|
-
return { status: "error", error: check.error };
|
|
770
|
-
return await this.processTools.killProcess(params);
|
|
771
|
-
}
|
|
772
|
-
async showStatus(params) {
|
|
773
|
-
const check = this.checkToolEnabled("showStatus");
|
|
774
|
-
if (!check.enabled)
|
|
775
|
-
return { status: "error", error: check.error };
|
|
776
|
-
return await this.processTools.showStatus(params);
|
|
777
|
-
}
|
|
778
|
-
async showVariables(params) {
|
|
779
|
-
const check = this.checkToolEnabled("showVariables");
|
|
780
|
-
if (!check.enabled)
|
|
781
|
-
return { status: "error", error: check.error };
|
|
782
|
-
return await this.processTools.showVariables(params);
|
|
783
|
-
}
|
|
784
|
-
async explainQuery(params) {
|
|
785
|
-
const check = this.checkToolEnabled("explainQuery");
|
|
786
|
-
if (!check.enabled)
|
|
787
|
-
return { status: "error", error: check.error };
|
|
788
|
-
return await this.processTools.explainQuery(params);
|
|
789
|
-
}
|
|
790
|
-
// ==========================================
|
|
791
|
-
// Performance Monitoring Tools
|
|
792
|
-
// ==========================================
|
|
793
|
-
async getPerformanceMetrics() {
|
|
794
|
-
const check = this.checkToolEnabled("getPerformanceMetrics");
|
|
795
|
-
if (!check.enabled)
|
|
796
|
-
return { status: "error", error: check.error };
|
|
797
|
-
return await this.performanceTools.getPerformanceMetrics();
|
|
798
|
-
}
|
|
799
|
-
async getTableIOStats(params) {
|
|
800
|
-
const check = this.checkToolEnabled("getTableIOStats");
|
|
801
|
-
if (!check.enabled)
|
|
802
|
-
return { status: "error", error: check.error };
|
|
803
|
-
return await this.performanceTools.getTableIOStats(params);
|
|
804
|
-
}
|
|
805
|
-
async getIndexUsageStats(params) {
|
|
806
|
-
const check = this.checkToolEnabled("getIndexUsageStats");
|
|
807
|
-
if (!check.enabled)
|
|
808
|
-
return { status: "error", error: check.error };
|
|
809
|
-
return await this.performanceTools.getIndexUsageStats(params);
|
|
810
|
-
}
|
|
811
|
-
async getUnusedIndexes(params) {
|
|
812
|
-
const check = this.checkToolEnabled("getUnusedIndexes");
|
|
813
|
-
if (!check.enabled)
|
|
814
|
-
return { status: "error", error: check.error };
|
|
815
|
-
return await this.performanceTools.getUnusedIndexes(params);
|
|
816
|
-
}
|
|
817
|
-
async getConnectionPoolStats() {
|
|
818
|
-
const check = this.checkToolEnabled("getConnectionPoolStats");
|
|
819
|
-
if (!check.enabled)
|
|
820
|
-
return { status: "error", error: check.error };
|
|
821
|
-
return await this.performanceTools.getConnectionPoolStats();
|
|
822
|
-
}
|
|
823
|
-
async getDatabaseHealthCheck() {
|
|
824
|
-
const check = this.checkToolEnabled("getDatabaseHealthCheck");
|
|
825
|
-
if (!check.enabled)
|
|
826
|
-
return { status: "error", error: check.error };
|
|
827
|
-
return await this.performanceTools.getDatabaseHealthCheck();
|
|
828
|
-
}
|
|
829
|
-
async resetPerformanceStats() {
|
|
830
|
-
const check = this.checkToolEnabled("resetPerformanceStats");
|
|
831
|
-
if (!check.enabled)
|
|
832
|
-
return { status: "error", error: check.error };
|
|
833
|
-
return await this.performanceTools.resetPerformanceStats();
|
|
834
|
-
}
|
|
835
685
|
// Smart Query Builder Tools
|
|
836
686
|
async startQueryBuilder(params) {
|
|
837
687
|
const check = this.checkToolEnabled("startQueryBuilder");
|
package/dist/mcp-server.js
CHANGED
|
@@ -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
|
|
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)
|
|
@@ -980,70 +981,6 @@ const TOOLS = [
|
|
|
980
981
|
required: ["query"],
|
|
981
982
|
},
|
|
982
983
|
},
|
|
983
|
-
// Cache Management Tools
|
|
984
|
-
{
|
|
985
|
-
name: "get_cache_stats",
|
|
986
|
-
description: "📊 Returns query cache performance metrics: hit rate, miss rate, size, memory usage, and entry count. Use to monitor cache effectiveness and tune cache settings.",
|
|
987
|
-
inputSchema: {
|
|
988
|
-
type: "object",
|
|
989
|
-
properties: {},
|
|
990
|
-
},
|
|
991
|
-
},
|
|
992
|
-
{
|
|
993
|
-
name: "get_cache_config",
|
|
994
|
-
description: "Get current cache configuration settings.",
|
|
995
|
-
inputSchema: {
|
|
996
|
-
type: "object",
|
|
997
|
-
properties: {},
|
|
998
|
-
},
|
|
999
|
-
},
|
|
1000
|
-
{
|
|
1001
|
-
name: "configure_cache",
|
|
1002
|
-
description: "Configure cache settings including TTL, max size, and enable/disable.",
|
|
1003
|
-
inputSchema: {
|
|
1004
|
-
type: "object",
|
|
1005
|
-
properties: {
|
|
1006
|
-
enabled: {
|
|
1007
|
-
type: "boolean",
|
|
1008
|
-
description: "Enable or disable the query cache",
|
|
1009
|
-
},
|
|
1010
|
-
ttlMs: {
|
|
1011
|
-
type: "number",
|
|
1012
|
-
description: "Cache time-to-live in milliseconds (default: 60000)",
|
|
1013
|
-
},
|
|
1014
|
-
maxSize: {
|
|
1015
|
-
type: "number",
|
|
1016
|
-
description: "Maximum number of cached entries (default: 100)",
|
|
1017
|
-
},
|
|
1018
|
-
maxMemoryMB: {
|
|
1019
|
-
type: "number",
|
|
1020
|
-
description: "Maximum memory usage in MB (default: 50)",
|
|
1021
|
-
},
|
|
1022
|
-
},
|
|
1023
|
-
},
|
|
1024
|
-
},
|
|
1025
|
-
{
|
|
1026
|
-
name: "clear_cache",
|
|
1027
|
-
description: "Clear all entries from the query cache.",
|
|
1028
|
-
inputSchema: {
|
|
1029
|
-
type: "object",
|
|
1030
|
-
properties: {},
|
|
1031
|
-
},
|
|
1032
|
-
},
|
|
1033
|
-
{
|
|
1034
|
-
name: "invalidate_table_cache",
|
|
1035
|
-
description: "Invalidate all cached queries related to a specific table.",
|
|
1036
|
-
inputSchema: {
|
|
1037
|
-
type: "object",
|
|
1038
|
-
properties: {
|
|
1039
|
-
table_name: {
|
|
1040
|
-
type: "string",
|
|
1041
|
-
description: "Name of the table to invalidate cache for",
|
|
1042
|
-
},
|
|
1043
|
-
},
|
|
1044
|
-
required: ["table_name"],
|
|
1045
|
-
},
|
|
1046
|
-
},
|
|
1047
984
|
// Query Optimization Tools
|
|
1048
985
|
{
|
|
1049
986
|
name: "analyze_query",
|
|
@@ -1872,130 +1809,6 @@ const TOOLS = [
|
|
|
1872
1809
|
},
|
|
1873
1810
|
},
|
|
1874
1811
|
},
|
|
1875
|
-
// Process Management Tools
|
|
1876
|
-
{
|
|
1877
|
-
name: "show_process_list",
|
|
1878
|
-
description: "Shows all running MySQL processes/connections.",
|
|
1879
|
-
inputSchema: {
|
|
1880
|
-
type: "object",
|
|
1881
|
-
properties: {
|
|
1882
|
-
full: { type: "boolean", description: "Show full query text" },
|
|
1883
|
-
},
|
|
1884
|
-
},
|
|
1885
|
-
},
|
|
1886
|
-
{
|
|
1887
|
-
name: "kill_process",
|
|
1888
|
-
description: "Kills a MySQL process/connection by ID.",
|
|
1889
|
-
inputSchema: {
|
|
1890
|
-
type: "object",
|
|
1891
|
-
properties: {
|
|
1892
|
-
process_id: { type: "number", description: "Process ID to kill" },
|
|
1893
|
-
type: {
|
|
1894
|
-
type: "string",
|
|
1895
|
-
enum: ["CONNECTION", "QUERY"],
|
|
1896
|
-
description: "Kill connection or just query",
|
|
1897
|
-
},
|
|
1898
|
-
},
|
|
1899
|
-
required: ["process_id"],
|
|
1900
|
-
},
|
|
1901
|
-
},
|
|
1902
|
-
{
|
|
1903
|
-
name: "show_status",
|
|
1904
|
-
description: "Shows MySQL server status variables.",
|
|
1905
|
-
inputSchema: {
|
|
1906
|
-
type: "object",
|
|
1907
|
-
properties: {
|
|
1908
|
-
like: {
|
|
1909
|
-
type: "string",
|
|
1910
|
-
description: "Optional: filter pattern (e.g., 'Thread%')",
|
|
1911
|
-
},
|
|
1912
|
-
global: {
|
|
1913
|
-
type: "boolean",
|
|
1914
|
-
description: "Show global status instead of session",
|
|
1915
|
-
},
|
|
1916
|
-
},
|
|
1917
|
-
},
|
|
1918
|
-
},
|
|
1919
|
-
{
|
|
1920
|
-
name: "show_variables",
|
|
1921
|
-
description: "Shows MySQL server configuration variables.",
|
|
1922
|
-
inputSchema: {
|
|
1923
|
-
type: "object",
|
|
1924
|
-
properties: {
|
|
1925
|
-
like: {
|
|
1926
|
-
type: "string",
|
|
1927
|
-
description: "Optional: filter pattern (e.g., 'max_%')",
|
|
1928
|
-
},
|
|
1929
|
-
global: {
|
|
1930
|
-
type: "boolean",
|
|
1931
|
-
description: "Show global variables instead of session",
|
|
1932
|
-
},
|
|
1933
|
-
},
|
|
1934
|
-
},
|
|
1935
|
-
},
|
|
1936
|
-
{
|
|
1937
|
-
name: "explain_query",
|
|
1938
|
-
description: "Shows the execution plan for a query (EXPLAIN).",
|
|
1939
|
-
inputSchema: {
|
|
1940
|
-
type: "object",
|
|
1941
|
-
properties: {
|
|
1942
|
-
query: { type: "string", description: "SQL query to explain" },
|
|
1943
|
-
format: {
|
|
1944
|
-
type: "string",
|
|
1945
|
-
enum: ["TRADITIONAL", "JSON", "TREE"],
|
|
1946
|
-
description: "Output format",
|
|
1947
|
-
},
|
|
1948
|
-
analyze: {
|
|
1949
|
-
type: "boolean",
|
|
1950
|
-
description: "Actually execute the query and show real statistics",
|
|
1951
|
-
},
|
|
1952
|
-
},
|
|
1953
|
-
required: ["query"],
|
|
1954
|
-
},
|
|
1955
|
-
},
|
|
1956
|
-
{
|
|
1957
|
-
name: "show_engine_status",
|
|
1958
|
-
description: "Shows storage engine status (InnoDB by default).",
|
|
1959
|
-
inputSchema: {
|
|
1960
|
-
type: "object",
|
|
1961
|
-
properties: {
|
|
1962
|
-
engine: {
|
|
1963
|
-
type: "string",
|
|
1964
|
-
description: "Engine name (INNODB, PERFORMANCE_SCHEMA, etc.)",
|
|
1965
|
-
},
|
|
1966
|
-
},
|
|
1967
|
-
},
|
|
1968
|
-
},
|
|
1969
|
-
{
|
|
1970
|
-
name: "get_server_info",
|
|
1971
|
-
description: "Gets comprehensive MySQL server information including version, uptime, and statistics.",
|
|
1972
|
-
inputSchema: {
|
|
1973
|
-
type: "object",
|
|
1974
|
-
properties: {},
|
|
1975
|
-
},
|
|
1976
|
-
},
|
|
1977
|
-
{
|
|
1978
|
-
name: "show_binary_logs",
|
|
1979
|
-
description: "Shows binary log files on the server.",
|
|
1980
|
-
inputSchema: {
|
|
1981
|
-
type: "object",
|
|
1982
|
-
properties: {},
|
|
1983
|
-
},
|
|
1984
|
-
},
|
|
1985
|
-
{
|
|
1986
|
-
name: "show_replication_status",
|
|
1987
|
-
description: "Shows replication status (master or replica).",
|
|
1988
|
-
inputSchema: {
|
|
1989
|
-
type: "object",
|
|
1990
|
-
properties: {
|
|
1991
|
-
type: {
|
|
1992
|
-
type: "string",
|
|
1993
|
-
enum: ["MASTER", "REPLICA", "SLAVE"],
|
|
1994
|
-
description: "Which status to show",
|
|
1995
|
-
},
|
|
1996
|
-
},
|
|
1997
|
-
},
|
|
1998
|
-
},
|
|
1999
1812
|
// Backup and Restore Tools
|
|
2000
1813
|
{
|
|
2001
1814
|
name: "backup_table",
|
|
@@ -2118,129 +1931,6 @@ const TOOLS = [
|
|
|
2118
1931
|
},
|
|
2119
1932
|
},
|
|
2120
1933
|
},
|
|
2121
|
-
// Performance Monitoring Tools
|
|
2122
|
-
{
|
|
2123
|
-
name: "get_performance_metrics",
|
|
2124
|
-
description: "📊 COMPREHENSIVE MONITORING: Returns complete MySQL performance dashboard including query stats, connection pool, buffer pool efficiency, InnoDB metrics, and disk I/O. Use for performance troubleshooting or health checks.",
|
|
2125
|
-
inputSchema: {
|
|
2126
|
-
type: "object",
|
|
2127
|
-
properties: {},
|
|
2128
|
-
},
|
|
2129
|
-
},
|
|
2130
|
-
{
|
|
2131
|
-
name: "get_top_queries_by_time",
|
|
2132
|
-
description: "Get the top queries ordered by total execution time. Useful for identifying slow queries.",
|
|
2133
|
-
inputSchema: {
|
|
2134
|
-
type: "object",
|
|
2135
|
-
properties: {
|
|
2136
|
-
limit: {
|
|
2137
|
-
type: "number",
|
|
2138
|
-
description: "Maximum number of queries to return (default: 10, max: 100)",
|
|
2139
|
-
},
|
|
2140
|
-
},
|
|
2141
|
-
},
|
|
2142
|
-
},
|
|
2143
|
-
{
|
|
2144
|
-
name: "get_top_queries_by_count",
|
|
2145
|
-
description: "Get the top queries ordered by execution count. Useful for identifying frequently executed queries.",
|
|
2146
|
-
inputSchema: {
|
|
2147
|
-
type: "object",
|
|
2148
|
-
properties: {
|
|
2149
|
-
limit: {
|
|
2150
|
-
type: "number",
|
|
2151
|
-
description: "Maximum number of queries to return (default: 10, max: 100)",
|
|
2152
|
-
},
|
|
2153
|
-
},
|
|
2154
|
-
},
|
|
2155
|
-
},
|
|
2156
|
-
{
|
|
2157
|
-
name: "get_slow_queries",
|
|
2158
|
-
description: "Get queries that exceed a specified execution time threshold.",
|
|
2159
|
-
inputSchema: {
|
|
2160
|
-
type: "object",
|
|
2161
|
-
properties: {
|
|
2162
|
-
limit: {
|
|
2163
|
-
type: "number",
|
|
2164
|
-
description: "Maximum number of queries to return (default: 10, max: 100)",
|
|
2165
|
-
},
|
|
2166
|
-
threshold_seconds: {
|
|
2167
|
-
type: "number",
|
|
2168
|
-
description: "Execution time threshold in seconds (default: 1)",
|
|
2169
|
-
},
|
|
2170
|
-
},
|
|
2171
|
-
},
|
|
2172
|
-
},
|
|
2173
|
-
{
|
|
2174
|
-
name: "get_table_io_stats",
|
|
2175
|
-
description: "Get I/O statistics for tables including read/write operations and timings.",
|
|
2176
|
-
inputSchema: {
|
|
2177
|
-
type: "object",
|
|
2178
|
-
properties: {
|
|
2179
|
-
limit: {
|
|
2180
|
-
type: "number",
|
|
2181
|
-
description: "Maximum number of tables to return (default: 20, max: 100)",
|
|
2182
|
-
},
|
|
2183
|
-
table_schema: {
|
|
2184
|
-
type: "string",
|
|
2185
|
-
description: "Filter by specific database schema",
|
|
2186
|
-
},
|
|
2187
|
-
},
|
|
2188
|
-
},
|
|
2189
|
-
},
|
|
2190
|
-
{
|
|
2191
|
-
name: "get_index_usage_stats",
|
|
2192
|
-
description: "Get index usage statistics showing how often each index is used.",
|
|
2193
|
-
inputSchema: {
|
|
2194
|
-
type: "object",
|
|
2195
|
-
properties: {
|
|
2196
|
-
limit: {
|
|
2197
|
-
type: "number",
|
|
2198
|
-
description: "Maximum number of indexes to return (default: 20, max: 100)",
|
|
2199
|
-
},
|
|
2200
|
-
table_schema: {
|
|
2201
|
-
type: "string",
|
|
2202
|
-
description: "Filter by specific database schema",
|
|
2203
|
-
},
|
|
2204
|
-
},
|
|
2205
|
-
},
|
|
2206
|
-
},
|
|
2207
|
-
{
|
|
2208
|
-
name: "get_unused_indexes",
|
|
2209
|
-
description: "Identify indexes that are not being used by queries. These may be candidates for removal to improve write performance.",
|
|
2210
|
-
inputSchema: {
|
|
2211
|
-
type: "object",
|
|
2212
|
-
properties: {
|
|
2213
|
-
table_schema: {
|
|
2214
|
-
type: "string",
|
|
2215
|
-
description: "Filter by specific database schema",
|
|
2216
|
-
},
|
|
2217
|
-
},
|
|
2218
|
-
},
|
|
2219
|
-
},
|
|
2220
|
-
{
|
|
2221
|
-
name: "get_connection_pool_stats",
|
|
2222
|
-
description: "Get connection pool statistics including current connections, max usage, configuration, and health indicators.",
|
|
2223
|
-
inputSchema: {
|
|
2224
|
-
type: "object",
|
|
2225
|
-
properties: {},
|
|
2226
|
-
},
|
|
2227
|
-
},
|
|
2228
|
-
{
|
|
2229
|
-
name: "get_database_health_check",
|
|
2230
|
-
description: "Perform a comprehensive health check of the database including connection usage, buffer pool efficiency, aborted connections, and slow queries.",
|
|
2231
|
-
inputSchema: {
|
|
2232
|
-
type: "object",
|
|
2233
|
-
properties: {},
|
|
2234
|
-
},
|
|
2235
|
-
},
|
|
2236
|
-
{
|
|
2237
|
-
name: "reset_performance_stats",
|
|
2238
|
-
description: "Reset performance schema statistics. This clears query digest statistics, table I/O stats, and index usage stats. Requires 'utility' permission.",
|
|
2239
|
-
inputSchema: {
|
|
2240
|
-
type: "object",
|
|
2241
|
-
properties: {},
|
|
2242
|
-
},
|
|
2243
|
-
},
|
|
2244
1934
|
{
|
|
2245
1935
|
name: "create_fulltext_index",
|
|
2246
1936
|
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.",
|
|
@@ -2415,7 +2105,7 @@ const TOOLS = [
|
|
|
2415
2105
|
// Create the MCP server
|
|
2416
2106
|
const server = new index_js_1.Server({
|
|
2417
2107
|
name: "mysql-mcp-server",
|
|
2418
|
-
version: "1.
|
|
2108
|
+
version: "1.40.1",
|
|
2419
2109
|
}, {
|
|
2420
2110
|
capabilities: {
|
|
2421
2111
|
tools: {},
|
|
@@ -2423,17 +2113,7 @@ const server = new index_js_1.Server({
|
|
|
2423
2113
|
});
|
|
2424
2114
|
// Handle list tools request - filter tools based on permissions and categories
|
|
2425
2115
|
server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => {
|
|
2426
|
-
|
|
2427
|
-
const enabledTools = TOOLS.filter((tool) => {
|
|
2428
|
-
// Convert tool name from snake_case to camelCase for checking
|
|
2429
|
-
// e.g., "list_databases" -> "listDatabases"
|
|
2430
|
-
const toolNameCamelCase = tool.name.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
2431
|
-
// Check if tool is enabled based on permissions and categories
|
|
2432
|
-
// Most tools are keyed in featureConfig using camelCase, but a few legacy/meta tools
|
|
2433
|
-
// are keyed using their snake_case MCP names (e.g., read_changelog, list_all_tools).
|
|
2434
|
-
return (mysqlMCP.isToolEnabled(toolNameCamelCase) ||
|
|
2435
|
-
mysqlMCP.isToolEnabled(tool.name));
|
|
2436
|
-
});
|
|
2116
|
+
const enabledTools = (0, toolRegistry_js_1.getEnabledTools)(mysqlMCP, TOOLS);
|
|
2437
2117
|
// Log the filtering results
|
|
2438
2118
|
console.error(`Tools available: ${enabledTools.length} of ${TOOLS.length} total tools`);
|
|
2439
2119
|
return {
|
|
@@ -2444,7 +2124,7 @@ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => {
|
|
|
2444
2124
|
server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
|
|
2445
2125
|
const { name, arguments: args } = request.params;
|
|
2446
2126
|
// Validate tool arguments before execution
|
|
2447
|
-
const validation = validateToolArguments(name, args);
|
|
2127
|
+
const validation = (0, toolArgumentValidation_js_1.validateToolArguments)(name, args);
|
|
2448
2128
|
if (!validation.valid) {
|
|
2449
2129
|
return {
|
|
2450
2130
|
content: [
|
|
@@ -2577,22 +2257,6 @@ server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
|
|
|
2577
2257
|
case "export_table_to_csv":
|
|
2578
2258
|
result = await mysqlMCP.exportTableToCSV((args || {}));
|
|
2579
2259
|
break;
|
|
2580
|
-
// Cache Management Tools
|
|
2581
|
-
case "get_cache_stats":
|
|
2582
|
-
result = mysqlMCP.getCacheStats();
|
|
2583
|
-
break;
|
|
2584
|
-
case "get_cache_config":
|
|
2585
|
-
result = mysqlMCP.getCacheConfig();
|
|
2586
|
-
break;
|
|
2587
|
-
case "configure_cache":
|
|
2588
|
-
result = mysqlMCP.configureCacheSettings((args || {}));
|
|
2589
|
-
break;
|
|
2590
|
-
case "clear_cache":
|
|
2591
|
-
result = mysqlMCP.clearCache();
|
|
2592
|
-
break;
|
|
2593
|
-
case "invalidate_table_cache":
|
|
2594
|
-
result = mysqlMCP.invalidateCacheForTable((args || {}));
|
|
2595
|
-
break;
|
|
2596
2260
|
// Query Optimization Tools
|
|
2597
2261
|
case "analyze_query":
|
|
2598
2262
|
result = mysqlMCP.analyzeQuery((args || {}));
|
|
@@ -2717,44 +2381,6 @@ server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
|
|
|
2717
2381
|
case "get_table_size":
|
|
2718
2382
|
result = await mysqlMCP.getTableSize((args || {}));
|
|
2719
2383
|
break;
|
|
2720
|
-
// Process Management Tools
|
|
2721
|
-
case "show_process_list":
|
|
2722
|
-
result = await mysqlMCP.showProcessList((args || {}));
|
|
2723
|
-
break;
|
|
2724
|
-
case "kill_process":
|
|
2725
|
-
result = await mysqlMCP.killProcess((args || {}));
|
|
2726
|
-
break;
|
|
2727
|
-
case "show_status":
|
|
2728
|
-
result = await mysqlMCP.showStatus((args || {}));
|
|
2729
|
-
break;
|
|
2730
|
-
case "show_variables":
|
|
2731
|
-
result = await mysqlMCP.showVariables((args || {}));
|
|
2732
|
-
break;
|
|
2733
|
-
case "explain_query":
|
|
2734
|
-
result = await mysqlMCP.explainQuery((args || {}));
|
|
2735
|
-
break;
|
|
2736
|
-
// Performance Monitoring Tools
|
|
2737
|
-
case "get_performance_metrics":
|
|
2738
|
-
result = await mysqlMCP.getPerformanceMetrics();
|
|
2739
|
-
break;
|
|
2740
|
-
case "get_table_io_stats":
|
|
2741
|
-
result = await mysqlMCP.getTableIOStats((args || {}));
|
|
2742
|
-
break;
|
|
2743
|
-
case "get_index_usage_stats":
|
|
2744
|
-
result = await mysqlMCP.getIndexUsageStats((args || {}));
|
|
2745
|
-
break;
|
|
2746
|
-
case "get_unused_indexes":
|
|
2747
|
-
result = await mysqlMCP.getUnusedIndexes((args || {}));
|
|
2748
|
-
break;
|
|
2749
|
-
case "get_connection_pool_stats":
|
|
2750
|
-
result = await mysqlMCP.getConnectionPoolStats();
|
|
2751
|
-
break;
|
|
2752
|
-
case "get_database_health_check":
|
|
2753
|
-
result = await mysqlMCP.getDatabaseHealthCheck();
|
|
2754
|
-
break;
|
|
2755
|
-
case "reset_performance_stats":
|
|
2756
|
-
result = await mysqlMCP.resetPerformanceStats();
|
|
2757
|
-
break;
|
|
2758
2384
|
case "repair_query":
|
|
2759
2385
|
result = await mysqlMCP.repairQuery((args || {}));
|
|
2760
2386
|
break;
|
|
@@ -2853,52 +2479,6 @@ server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
|
|
|
2853
2479
|
};
|
|
2854
2480
|
}
|
|
2855
2481
|
});
|
|
2856
|
-
// Validation function to validate tool arguments before execution
|
|
2857
|
-
function validateToolArguments(name, args) {
|
|
2858
|
-
if (!args)
|
|
2859
|
-
return { valid: true }; // Some tools don't require arguments
|
|
2860
|
-
try {
|
|
2861
|
-
switch (name) {
|
|
2862
|
-
case "create_record":
|
|
2863
|
-
return (0, inputValidation_js_1.validateCreateRecord)(args);
|
|
2864
|
-
case "read_records":
|
|
2865
|
-
return (0, inputValidation_js_1.validateReadRecords)(args);
|
|
2866
|
-
case "update_record":
|
|
2867
|
-
return (0, inputValidation_js_1.validateUpdateRecord)(args);
|
|
2868
|
-
case "delete_record":
|
|
2869
|
-
return (0, inputValidation_js_1.validateDeleteRecord)(args);
|
|
2870
|
-
case "run_select_query":
|
|
2871
|
-
case "execute_write_query":
|
|
2872
|
-
case "execute_ddl":
|
|
2873
|
-
return (0, inputValidation_js_1.validateQuery)({ query: args?.query || "" });
|
|
2874
|
-
case "bulk_insert":
|
|
2875
|
-
return (0, inputValidation_js_1.validateBulkInsert)(args);
|
|
2876
|
-
case "list_tables":
|
|
2877
|
-
case "get_schema_erd":
|
|
2878
|
-
case "get_schema_rag_context":
|
|
2879
|
-
case "get_database_summary":
|
|
2880
|
-
if (args.database !== undefined) {
|
|
2881
|
-
const validation = (0, inputValidation_js_1.validateValue)(args.database);
|
|
2882
|
-
if (!validation.valid)
|
|
2883
|
-
return { valid: false, errors: [validation.error || 'Invalid database name'] };
|
|
2884
|
-
}
|
|
2885
|
-
return { valid: true };
|
|
2886
|
-
case "get_column_statistics":
|
|
2887
|
-
case "read_table_schema":
|
|
2888
|
-
if (args.table_name) {
|
|
2889
|
-
const validation = (0, inputValidation_js_1.validateTableName)(args.table_name);
|
|
2890
|
-
if (!validation.valid)
|
|
2891
|
-
return { valid: false, errors: [validation.error || 'Invalid table name'] };
|
|
2892
|
-
}
|
|
2893
|
-
return { valid: true };
|
|
2894
|
-
default:
|
|
2895
|
-
return { valid: true }; // For tools without specific validation
|
|
2896
|
-
}
|
|
2897
|
-
}
|
|
2898
|
-
catch (error) {
|
|
2899
|
-
return { valid: false, errors: [`Validation error: ${error instanceof Error ? error.message : 'Unknown validation error'}`] };
|
|
2900
|
-
}
|
|
2901
|
-
}
|
|
2902
2482
|
// Start the server
|
|
2903
2483
|
async function main() {
|
|
2904
2484
|
const transport = new stdio_js_1.StdioServerTransport();
|
|
@@ -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,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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@berthojoris/mcp-mysql-server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.40.1",
|
|
4
4
|
"description": "Model Context Protocol server for MySQL database integration with dynamic per-project permissions, backup/restore capabilities",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -77,4 +77,4 @@
|
|
|
77
77
|
"ts-node": "^10.9.1",
|
|
78
78
|
"typescript": "^5.2.2"
|
|
79
79
|
}
|
|
80
|
-
}
|
|
80
|
+
}
|