@berthojoris/mcp-mysql-server 1.40.6 → 1.42.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +32 -0
- package/DOCUMENTATIONS.md +88 -18
- package/README.md +15 -5
- package/bin/mcp-mysql.js +5 -5
- package/dist/config/featureConfig.d.ts +3 -2
- package/dist/config/featureConfig.js +35 -4
- package/dist/index.d.ts +53 -1
- package/dist/index.js +56 -4
- package/dist/mcp-server.js +334 -3
- package/dist/security/securityLayer.d.ts +1 -1
- package/dist/security/securityLayer.js +2 -2
- package/dist/tools/dataExportTools.d.ts +11 -0
- package/dist/tools/dataExportTools.js +68 -27
- package/dist/tools/ddlTools.d.ts +2 -0
- package/dist/tools/ddlTools.js +125 -20
- package/dist/tools/relationalSeederTools.d.ts +207 -0
- package/dist/tools/relationalSeederTools.js +1432 -0
- package/dist/tools/toolArgumentValidation.js +117 -0
- package/dist/tools/utilityTools.d.ts +16 -1
- package/dist/tools/utilityTools.js +81 -18
- package/manifest.json +2901 -744
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,38 @@ 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.42.0] - 2026-05-11
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- Added composite FK/PK tuple resolution for relational seeding so multi-column relationships are selected and validated as intact parent key tuples.
|
|
12
|
+
- Added `infer_seed_rules` to infer safe seed generators from schema, samples, unique indexes, and ecommerce/POS/CRM domain presets.
|
|
13
|
+
- Added `seed_from_template` to create plan-first ecommerce, POS, and CRM seed workflows with detected tables and template-scale row counts.
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
- Updated seed tool count to 6 and total MCP tools to 85.
|
|
17
|
+
|
|
18
|
+
## [1.41.0] - 2026-05-11
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
- Added `seed_operations` category with `plan_seed_data`, `generate_seed_preview`, `execute_seed_plan`, and `validate_seed_integrity` for FK-aware relational dummy data seeding.
|
|
22
|
+
- Added deterministic seed planning, preview, confirmation token, transaction rollback, production-name guard, and integrity validation support.
|
|
23
|
+
|
|
24
|
+
### Changed
|
|
25
|
+
- Updated tool totals and version metadata to `1.41.0`.
|
|
26
|
+
|
|
27
|
+
## [1.40.7] - 2026-05-06
|
|
28
|
+
|
|
29
|
+
### Added
|
|
30
|
+
- Implemented `export_query_to_csv` end-to-end for SELECT query CSV exports.
|
|
31
|
+
- Enhanced `list_all_tools` with a live runtime tool catalog, enabled/disabled status, access profile, and AI-agent workflow guidance.
|
|
32
|
+
|
|
33
|
+
### Fixed
|
|
34
|
+
- Fixed `export_query_to_csv` being advertised but failing with `Unknown tool`.
|
|
35
|
+
- Fixed `list_all_tools` returning stale manifest data instead of the active MCP tool catalog.
|
|
36
|
+
- Fixed `execute_in_transaction` permission checks to match its advertised transaction permission.
|
|
37
|
+
- Hardened DDL tools by validating raw DDL statements and checking structured table, column, and index inputs before building SQL.
|
|
38
|
+
- Added argument validation for Cursor bridge dispatches.
|
|
39
|
+
|
|
8
40
|
## [1.40.6] - 2026-05-04
|
|
9
41
|
|
|
10
42
|
### Added
|
package/DOCUMENTATIONS.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# MySQL MCP Server - Documentation
|
|
2
2
|
|
|
3
|
-
**Last Updated:** 2026-05-
|
|
4
|
-
**Version:** 1.
|
|
5
|
-
**Total Tools:**
|
|
3
|
+
**Last Updated:** 2026-05-11 10:44:46
|
|
4
|
+
**Version:** 1.42.0
|
|
5
|
+
**Total Tools:** 85
|
|
6
6
|
|
|
7
7
|
Comprehensive documentation for the MySQL MCP Server. For quick start, see [README.md](README.md).
|
|
8
8
|
|
|
@@ -93,6 +93,14 @@ Supported `mode` values are `auto`, `select`, `write`, and `ddl`. Set `MYSQL_MCP
|
|
|
93
93
|
|
|
94
94
|
---
|
|
95
95
|
|
|
96
|
+
### AI Agent Tool Discovery
|
|
97
|
+
|
|
98
|
+
Use `list_all_tools` first when connecting from Codex, Claude Code CLI, Cursor, Droid CLI, or other MCP agents. It returns the live runtime catalog from the server, enabled/disabled status for each tool, the active permission/category profile, and recommended workflows for common agent tasks.
|
|
99
|
+
|
|
100
|
+
For CSV exports, use `export_table_to_csv` for table-based exports and `export_query_to_csv` for SELECT query exports.
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
96
104
|
## Permission System
|
|
97
105
|
|
|
98
106
|
### Available Permissions
|
|
@@ -101,7 +109,7 @@ Supported `mode` values are `auto`, `select`, `write`, and `ddl`. Set `MYSQL_MCP
|
|
|
101
109
|
|------------|------------|---------------|
|
|
102
110
|
| `list` | List/discover objects | `list_databases`, `list_tables` |
|
|
103
111
|
| `read` | Read data | `read_records`, `run_select_query` |
|
|
104
|
-
| `create` | Insert records | `create_record`, `bulk_insert` |
|
|
112
|
+
| `create` | Insert records and seed data | `create_record`, `bulk_insert`, `execute_seed_plan` |
|
|
105
113
|
| `update` | Update records | `update_record`, `bulk_update` |
|
|
106
114
|
| `delete` | Delete records | `delete_record`, `bulk_delete` |
|
|
107
115
|
| `execute` | Custom SQL | `execute_write_query` |
|
|
@@ -120,12 +128,11 @@ Tool enabled = (Has Permission) AND (Has Category OR No categories specified)
|
|
|
120
128
|
|
|
121
129
|
## Tool Categories
|
|
122
130
|
|
|
123
|
-
### 1. Database Discovery (
|
|
131
|
+
### 1. Database Discovery (4 tools)
|
|
124
132
|
- `list_databases` - List all databases
|
|
125
133
|
- `list_tables` - List tables in database
|
|
126
134
|
- `read_table_schema` - Get table structure
|
|
127
135
|
- `get_all_tables_relationships` - Get all FK relationships
|
|
128
|
-
- `list_all_tools` - List available MCP tools
|
|
129
136
|
|
|
130
137
|
### 2. Analysis (4 tools)
|
|
131
138
|
- `get_database_summary` - Database overview with statistics
|
|
@@ -142,18 +149,30 @@ Tool enabled = (Has Permission) AND (Has Category OR No categories specified)
|
|
|
142
149
|
- `bulk_update` - Batch update (performance)
|
|
143
150
|
- `bulk_delete` - Batch delete (performance)
|
|
144
151
|
|
|
145
|
-
### 4.
|
|
152
|
+
### 4. Seed Operations (6 tools)
|
|
153
|
+
- `plan_seed_data` - Build FK-aware relational seed plans
|
|
154
|
+
- `generate_seed_preview` - Preview deterministic dummy rows without writing
|
|
155
|
+
- `execute_seed_plan` - Execute confirmed seed plans with transaction and rollback safety
|
|
156
|
+
- `validate_seed_integrity` - Validate row counts, FK orphans, required columns, and unique collisions
|
|
157
|
+
- `infer_seed_rules` - Infer advanced generators from schema, samples, unique indexes, and domain presets
|
|
158
|
+
- `seed_from_template` - Create reusable plan-first seed workflows for ecommerce, POS, and CRM domains
|
|
159
|
+
|
|
160
|
+
### 5. Query Management (3 tools)
|
|
146
161
|
- `run_select_query` - Execute SELECT queries
|
|
147
162
|
- `execute_write_query` - Execute INSERT/UPDATE/DELETE
|
|
148
163
|
- `repair_query` - Diagnose and fix SQL errors
|
|
149
164
|
|
|
150
|
-
###
|
|
165
|
+
### 6. Schema Management (4 tools)
|
|
151
166
|
- `create_table` - Create new tables
|
|
152
167
|
- `alter_table` - Modify table structure
|
|
153
168
|
- `drop_table` - Delete tables
|
|
154
169
|
- `execute_ddl` - Execute raw DDL
|
|
155
170
|
|
|
156
|
-
###
|
|
171
|
+
### 7. Data Export (2 tools)
|
|
172
|
+
- `export_table_to_csv` - Export table data to CSV
|
|
173
|
+
- `export_query_to_csv` - Export SELECT query results to CSV
|
|
174
|
+
|
|
175
|
+
### 8. Index Management (10 tools)
|
|
157
176
|
- `list_indexes` - List table indexes
|
|
158
177
|
- `get_index_info` - Get index details
|
|
159
178
|
- `create_index` - Create indexes
|
|
@@ -165,7 +184,7 @@ Tool enabled = (Has Permission) AND (Has Category OR No categories specified)
|
|
|
165
184
|
- `get_fulltext_stats` - Get FULLTEXT index statistics
|
|
166
185
|
- `optimize_fulltext` - Optimize FULLTEXT indexes
|
|
167
186
|
|
|
168
|
-
###
|
|
187
|
+
### 9. Constraint Management (7 tools)
|
|
169
188
|
- `list_foreign_keys` - List foreign keys
|
|
170
189
|
- `list_constraints` - List all constraints
|
|
171
190
|
- `add_foreign_key` - Add foreign key
|
|
@@ -174,7 +193,7 @@ Tool enabled = (Has Permission) AND (Has Category OR No categories specified)
|
|
|
174
193
|
- `drop_constraint` - Remove constraint
|
|
175
194
|
- `add_check_constraint` - Add check constraint
|
|
176
195
|
|
|
177
|
-
###
|
|
196
|
+
### 10. Stored Procedures (6 tools)
|
|
178
197
|
- `list_stored_procedures` - List procedures
|
|
179
198
|
- `get_stored_procedure_info` - Get procedure details
|
|
180
199
|
- `execute_stored_procedure` - Execute procedures
|
|
@@ -182,7 +201,7 @@ Tool enabled = (Has Permission) AND (Has Category OR No categories specified)
|
|
|
182
201
|
- `drop_stored_procedure` - Remove procedures
|
|
183
202
|
- `show_create_procedure` - Show CREATE statement
|
|
184
203
|
|
|
185
|
-
###
|
|
204
|
+
### 11. Views Management (6 tools)
|
|
186
205
|
- `list_views` - List views
|
|
187
206
|
- `get_view_info` - Get view details
|
|
188
207
|
- `create_view` - Create views
|
|
@@ -190,14 +209,14 @@ Tool enabled = (Has Permission) AND (Has Category OR No categories specified)
|
|
|
190
209
|
- `drop_view` - Remove views
|
|
191
210
|
- `show_create_view` - Show CREATE statement
|
|
192
211
|
|
|
193
|
-
###
|
|
212
|
+
### 12. Triggers Management (5 tools)
|
|
194
213
|
- `list_triggers` - List triggers
|
|
195
214
|
- `get_trigger_info` - Get trigger details
|
|
196
215
|
- `create_trigger` - Create triggers
|
|
197
216
|
- `drop_trigger` - Remove triggers
|
|
198
217
|
- `show_create_trigger` - Show CREATE statement
|
|
199
218
|
|
|
200
|
-
###
|
|
219
|
+
### 13. Table Maintenance (8 tools)
|
|
201
220
|
- `analyze_table` - Update statistics
|
|
202
221
|
- `optimize_table` - Reclaim space
|
|
203
222
|
- `check_table` - Check for errors
|
|
@@ -207,24 +226,24 @@ Tool enabled = (Has Permission) AND (Has Category OR No categories specified)
|
|
|
207
226
|
- `flush_table` - Close/reopen table
|
|
208
227
|
- `get_table_size` - Get size information
|
|
209
228
|
|
|
210
|
-
###
|
|
229
|
+
### 14. Transaction Management (5 tools)
|
|
211
230
|
- `begin_transaction` - Start transaction
|
|
212
231
|
- `commit_transaction` - Commit transaction
|
|
213
232
|
- `rollback_transaction` - Rollback transaction
|
|
214
233
|
- `get_transaction_status` - Check transaction state
|
|
215
234
|
- `execute_in_transaction` - Execute within transaction
|
|
216
235
|
|
|
217
|
-
###
|
|
236
|
+
### 15. Query Optimization (3 tools)
|
|
218
237
|
- `analyze_query` - Analyze query performance
|
|
219
238
|
- `get_optimization_hints` - Get optimizer hints
|
|
220
239
|
- `repair_query` - Repair broken SQL queries
|
|
221
240
|
|
|
222
|
-
###
|
|
241
|
+
### 16. Utilities (5 tools)
|
|
223
242
|
- `test_connection` - Test connectivity
|
|
224
243
|
- `describe_connection` - Connection info
|
|
225
244
|
- `read_changelog` - Read changelog
|
|
226
|
-
- `invalidate_table_cache` - Clear table cache
|
|
227
245
|
- `cursor_execute_request` - Execute a file-backed request for clients that cannot send MCP arguments
|
|
246
|
+
- `list_all_tools` - Runtime tool catalog with agent guidance
|
|
228
247
|
|
|
229
248
|
---
|
|
230
249
|
|
|
@@ -318,6 +337,57 @@ For high-performance operations with large datasets:
|
|
|
318
337
|
- **Bulk Update**: Update multiple records with different conditions
|
|
319
338
|
- **Bulk Delete**: Delete multiple record sets in batches
|
|
320
339
|
|
|
340
|
+
### Relational Data Seeder
|
|
341
|
+
|
|
342
|
+
For dummy data on related tables, use the seed workflow:
|
|
343
|
+
|
|
344
|
+
```javascript
|
|
345
|
+
const plan = await mcp.call("plan_seed_data", {
|
|
346
|
+
target_tables: ["orders"],
|
|
347
|
+
rows_per_table: 20,
|
|
348
|
+
include_dependencies: true,
|
|
349
|
+
include_children: true,
|
|
350
|
+
random_seed: 42
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
await mcp.call("generate_seed_preview", {
|
|
354
|
+
plan_id: plan.plan_id,
|
|
355
|
+
max_preview_rows_per_table: 3
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
await mcp.call("execute_seed_plan", {
|
|
359
|
+
plan_id: plan.plan_id,
|
|
360
|
+
dry_run: false,
|
|
361
|
+
confirm_token: plan.confirm_token
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
await mcp.call("validate_seed_integrity", {
|
|
365
|
+
plan_id: plan.plan_id
|
|
366
|
+
});
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
`execute_seed_plan` defaults to dry-run, requires confirmation for writes, blocks production-like database names unless explicitly allowed, and uses transaction rollback on errors.
|
|
370
|
+
|
|
371
|
+
Composite FK/PK support resolves multi-column parent tuples together, so relations such as `(tenant_id, region_id)` or `(tenant_id, region_id, order_id)` are not mixed across different parent rows.
|
|
372
|
+
|
|
373
|
+
Advanced rule inference and templates:
|
|
374
|
+
|
|
375
|
+
```javascript
|
|
376
|
+
await mcp.call("infer_seed_rules", {
|
|
377
|
+
tables: ["orders", "order_items"],
|
|
378
|
+
domain: "ecommerce",
|
|
379
|
+
sample_size: 25
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
await mcp.call("seed_from_template", {
|
|
383
|
+
template: "ecommerce",
|
|
384
|
+
scale: "small",
|
|
385
|
+
random_seed: 42
|
|
386
|
+
});
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
`seed_from_template` is plan-first and does not write data directly. Review its plan/preview, then execute with `execute_seed_plan`.
|
|
390
|
+
|
|
321
391
|
### Transaction Management
|
|
322
392
|
|
|
323
393
|
Full ACID transaction support:
|
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-05-
|
|
7
|
+
**Last Updated:** 2026-05-11 10:44:46
|
|
8
8
|
|
|
9
9
|
[](https://www.npmjs.com/package/@berthojoris/mcp-mysql-server)
|
|
10
10
|
[](https://www.npmjs.com/package/@berthojoris/mcp-mysql-server)
|
|
@@ -148,8 +148,8 @@ If you want ready-to-copy snippets per client (Claude Code/Cursor/Windsurf/Cline
|
|
|
148
148
|
"-y",
|
|
149
149
|
"@berthojoris/mcp-mysql-server",
|
|
150
150
|
"mysql://user:password@localhost:3306/database_name_here",
|
|
151
|
-
"list,read,utility,create,update,ddl",
|
|
152
|
-
"database_discovery,crud_operations,custom_queries,schema_management,index_management,constraint_management,table_maintenance,query_optimization,analysis"
|
|
151
|
+
"list,read,utility,create,update,ddl,transaction",
|
|
152
|
+
"database_discovery,crud_operations,custom_queries,schema_management,index_management,constraint_management,table_maintenance,query_optimization,analysis,seed_operations"
|
|
153
153
|
]
|
|
154
154
|
}
|
|
155
155
|
}
|
|
@@ -237,6 +237,14 @@ Set `MYSQL_MCP_CURSOR_REQUEST_FILE` to override the request file path.
|
|
|
237
237
|
|
|
238
238
|
---
|
|
239
239
|
|
|
240
|
+
### AI Agent Tool Discovery
|
|
241
|
+
|
|
242
|
+
For Codex, Claude Code CLI, Cursor, Droid CLI, and other MCP agents, call `list_all_tools` first. It returns the live runtime catalog, enabled/disabled status, active permission/category profile, and recommended workflows for schema exploration, safe SELECT queries, CSV exports, transactions, and data changes.
|
|
243
|
+
|
|
244
|
+
Use `export_table_to_csv` for table-based exports and `export_query_to_csv` for SELECT query exports.
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
240
248
|
## Permission System
|
|
241
249
|
|
|
242
250
|
Control database access with a **dual-layer filtering system** that provides both broad and fine-grained control:
|
|
@@ -274,6 +282,7 @@ Use documentation categories to fine-tune which tools are exposed (Layer 2):
|
|
|
274
282
|
| `database_discovery` | Explore databases, tables, and schema structure | `get_all_tables_relationships, list_databases, list_tables, read_table_schema` |
|
|
275
283
|
| `crud_operations` | Create, read, update, delete operations on data | `create_record, delete_record, read_records, update_record` |
|
|
276
284
|
| `bulk_operations` | High-performance batch processing operations | `bulk_delete, bulk_insert, bulk_update` |
|
|
285
|
+
| `seed_operations` | FK-aware relational dummy data seeding | `execute_seed_plan, generate_seed_preview, infer_seed_rules, plan_seed_data, seed_from_template, validate_seed_integrity` |
|
|
277
286
|
| `custom_queries` | Execute custom SQL queries and advanced operations | `execute_write_query, run_select_query` |
|
|
278
287
|
| `schema_management` | Manage database schema, tables, and structure | `alter_table, create_table, drop_table, execute_ddl` |
|
|
279
288
|
| `utilities` | Database utilities, diagnostics, and helper functions | `cursor_execute_request, describe_connection, export_query_to_csv, export_table_to_csv, list_all_tools, read_changelog, test_connection` |
|
|
@@ -291,7 +300,7 @@ Use documentation categories to fine-tune which tools are exposed (Layer 2):
|
|
|
291
300
|
<summary>Copy/paste list (comma-separated, no spaces)</summary>
|
|
292
301
|
|
|
293
302
|
```text
|
|
294
|
-
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
|
|
303
|
+
database_discovery,crud_operations,bulk_operations,seed_operations,custom_queries,schema_management,utilities,transaction_management,stored_procedures,views_management,triggers_management,index_management,constraint_management,table_maintenance,query_optimization,analysis
|
|
295
304
|
```
|
|
296
305
|
|
|
297
306
|
</details>
|
|
@@ -302,7 +311,7 @@ Full category → tool mapping (and examples) lives in **[DOCUMENTATIONS.md →
|
|
|
302
311
|
|
|
303
312
|
## Available Tools
|
|
304
313
|
|
|
305
|
-
The server exposes **
|
|
314
|
+
The server exposes **85 tools** organized into categories (CRUD, seed, schema, and utilities).
|
|
306
315
|
|
|
307
316
|
- Complete list of tools: **[DOCUMENTATIONS.md → Complete Tools Reference](DOCUMENTATIONS.md#🔧-complete-tools-reference)**
|
|
308
317
|
|
|
@@ -314,6 +323,7 @@ For comprehensive documentation, see **[DOCUMENTATIONS.md](DOCUMENTATIONS.md)**:
|
|
|
314
323
|
|
|
315
324
|
- **DDL Operations** - Create, alter, and drop tables
|
|
316
325
|
- **Data Export Tools** - Export to CSV, JSON, and SQL formats
|
|
326
|
+
- **Relational Data Seeder** - Plan, preview, execute, validate, infer rules, and template FK-aware dummy data
|
|
317
327
|
- **Data Import Tools** - Import from CSV and JSON sources
|
|
318
328
|
- **Data Migration Tools** - Copy, move, clone, compare, and sync data
|
|
319
329
|
- **Schema Versioning** - Version control for database schema changes
|
package/bin/mcp-mysql.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
1
|
+
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* MCP MySQL Server CLI
|
|
@@ -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,custom_queries,analysis"',
|
|
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,13 +66,13 @@ if (!mysqlUrl) {
|
|
|
66
66
|
" schema_management, utilities, transaction_management, stored_procedures,",
|
|
67
67
|
);
|
|
68
68
|
console.error(
|
|
69
|
-
" views_management, triggers_management, index_management,",
|
|
69
|
+
" views_management, triggers_management, index_management,",
|
|
70
70
|
);
|
|
71
71
|
console.error(
|
|
72
|
-
" constraint_management, table_maintenance, query_optimization,",
|
|
72
|
+
" constraint_management, table_maintenance, query_optimization,",
|
|
73
73
|
);
|
|
74
74
|
console.error(
|
|
75
|
-
" analysis",
|
|
75
|
+
" analysis, seed_operations",
|
|
76
76
|
);
|
|
77
77
|
console.error("");
|
|
78
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
|
|
18
18
|
* More intuitive and matches user mental model
|
|
19
19
|
*/
|
|
20
20
|
export declare enum DocCategory {
|
|
@@ -32,7 +32,8 @@ export declare enum DocCategory {
|
|
|
32
32
|
CONSTRAINT_MANAGEMENT = "constraint_management",
|
|
33
33
|
TABLE_MAINTENANCE = "table_maintenance",
|
|
34
34
|
QUERY_OPTIMIZATION = "query_optimization",
|
|
35
|
-
ANALYSIS = "analysis"
|
|
35
|
+
ANALYSIS = "analysis",
|
|
36
|
+
SEED_OPERATIONS = "seed_operations"
|
|
36
37
|
}
|
|
37
38
|
/**
|
|
38
39
|
* Map of tool names to their legacy categories
|
|
@@ -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
|
|
28
28
|
* More intuitive and matches user mental model
|
|
29
29
|
*/
|
|
30
30
|
var DocCategory;
|
|
@@ -44,6 +44,7 @@ var DocCategory;
|
|
|
44
44
|
DocCategory["TABLE_MAINTENANCE"] = "table_maintenance";
|
|
45
45
|
DocCategory["QUERY_OPTIMIZATION"] = "query_optimization";
|
|
46
46
|
DocCategory["ANALYSIS"] = "analysis";
|
|
47
|
+
DocCategory["SEED_OPERATIONS"] = "seed_operations";
|
|
47
48
|
})(DocCategory || (exports.DocCategory = DocCategory = {}));
|
|
48
49
|
/**
|
|
49
50
|
* Map of tool names to their legacy categories
|
|
@@ -53,7 +54,8 @@ exports.toolCategoryMap = {
|
|
|
53
54
|
listDatabases: ToolCategory.LIST,
|
|
54
55
|
listTables: ToolCategory.LIST,
|
|
55
56
|
readTableSchema: ToolCategory.LIST,
|
|
56
|
-
|
|
57
|
+
listAllTools: ToolCategory.UTILITY,
|
|
58
|
+
list_all_tools: ToolCategory.UTILITY,
|
|
57
59
|
// Analysis tools (added here to group with database tools)
|
|
58
60
|
getDatabaseSummary: ToolCategory.LIST,
|
|
59
61
|
getSchemaERD: ToolCategory.LIST,
|
|
@@ -71,6 +73,19 @@ exports.toolCategoryMap = {
|
|
|
71
73
|
bulkInsert: ToolCategory.CREATE,
|
|
72
74
|
bulkUpdate: ToolCategory.UPDATE,
|
|
73
75
|
bulkDelete: ToolCategory.DELETE,
|
|
76
|
+
// Seed operations
|
|
77
|
+
planSeedData: ToolCategory.LIST,
|
|
78
|
+
plan_seed_data: ToolCategory.LIST,
|
|
79
|
+
generateSeedPreview: ToolCategory.READ,
|
|
80
|
+
generate_seed_preview: ToolCategory.READ,
|
|
81
|
+
executeSeedPlan: ToolCategory.CREATE,
|
|
82
|
+
execute_seed_plan: ToolCategory.CREATE,
|
|
83
|
+
validateSeedIntegrity: ToolCategory.READ,
|
|
84
|
+
validate_seed_integrity: ToolCategory.READ,
|
|
85
|
+
inferSeedRules: ToolCategory.READ,
|
|
86
|
+
infer_seed_rules: ToolCategory.READ,
|
|
87
|
+
seedFromTemplate: ToolCategory.LIST,
|
|
88
|
+
seed_from_template: ToolCategory.LIST,
|
|
74
89
|
// Query tools
|
|
75
90
|
runSelectQuery: ToolCategory.READ,
|
|
76
91
|
executeWriteQuery: ToolCategory.EXECUTE,
|
|
@@ -174,6 +189,19 @@ exports.toolDocCategoryMap = {
|
|
|
174
189
|
bulkInsert: DocCategory.BULK_OPERATIONS,
|
|
175
190
|
bulkUpdate: DocCategory.BULK_OPERATIONS,
|
|
176
191
|
bulkDelete: DocCategory.BULK_OPERATIONS,
|
|
192
|
+
// Seed Operations
|
|
193
|
+
planSeedData: DocCategory.SEED_OPERATIONS,
|
|
194
|
+
plan_seed_data: DocCategory.SEED_OPERATIONS,
|
|
195
|
+
generateSeedPreview: DocCategory.SEED_OPERATIONS,
|
|
196
|
+
generate_seed_preview: DocCategory.SEED_OPERATIONS,
|
|
197
|
+
executeSeedPlan: DocCategory.SEED_OPERATIONS,
|
|
198
|
+
execute_seed_plan: DocCategory.SEED_OPERATIONS,
|
|
199
|
+
validateSeedIntegrity: DocCategory.SEED_OPERATIONS,
|
|
200
|
+
validate_seed_integrity: DocCategory.SEED_OPERATIONS,
|
|
201
|
+
inferSeedRules: DocCategory.SEED_OPERATIONS,
|
|
202
|
+
infer_seed_rules: DocCategory.SEED_OPERATIONS,
|
|
203
|
+
seedFromTemplate: DocCategory.SEED_OPERATIONS,
|
|
204
|
+
seed_from_template: DocCategory.SEED_OPERATIONS,
|
|
177
205
|
// Custom Queries
|
|
178
206
|
runSelectQuery: DocCategory.CUSTOM_QUERIES,
|
|
179
207
|
executeWriteQuery: DocCategory.CUSTOM_QUERIES,
|
|
@@ -194,6 +222,7 @@ exports.toolDocCategoryMap = {
|
|
|
194
222
|
exportQueryToCsv: DocCategory.UTILITIES,
|
|
195
223
|
export_query_to_csv: DocCategory.UTILITIES,
|
|
196
224
|
read_changelog: DocCategory.UTILITIES,
|
|
225
|
+
listAllTools: DocCategory.UTILITIES,
|
|
197
226
|
list_all_tools: DocCategory.UTILITIES,
|
|
198
227
|
// Transaction Management
|
|
199
228
|
beginTransaction: DocCategory.TRANSACTION_MANAGEMENT,
|
|
@@ -281,11 +310,13 @@ const legacyToDocCategoryMap = {
|
|
|
281
310
|
DocCategory.TABLE_MAINTENANCE,
|
|
282
311
|
DocCategory.ANALYSIS,
|
|
283
312
|
DocCategory.UTILITIES,
|
|
313
|
+
DocCategory.SEED_OPERATIONS,
|
|
284
314
|
],
|
|
285
|
-
read: [DocCategory.CRUD_OPERATIONS, DocCategory.CUSTOM_QUERIES, DocCategory.ANALYSIS],
|
|
315
|
+
read: [DocCategory.CRUD_OPERATIONS, DocCategory.CUSTOM_QUERIES, DocCategory.ANALYSIS, DocCategory.SEED_OPERATIONS],
|
|
286
316
|
create: [
|
|
287
317
|
DocCategory.CRUD_OPERATIONS,
|
|
288
318
|
DocCategory.BULK_OPERATIONS,
|
|
319
|
+
DocCategory.SEED_OPERATIONS,
|
|
289
320
|
],
|
|
290
321
|
update: [
|
|
291
322
|
DocCategory.CRUD_OPERATIONS,
|
|
@@ -309,7 +340,7 @@ const legacyToDocCategoryMap = {
|
|
|
309
340
|
DocCategory.TABLE_MAINTENANCE,
|
|
310
341
|
DocCategory.QUERY_OPTIMIZATION,
|
|
311
342
|
],
|
|
312
|
-
transaction: [DocCategory.TRANSACTION_MANAGEMENT],
|
|
343
|
+
transaction: [DocCategory.TRANSACTION_MANAGEMENT, DocCategory.SEED_OPERATIONS],
|
|
313
344
|
procedure: [DocCategory.STORED_PROCEDURES],
|
|
314
345
|
};
|
|
315
346
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export declare class MySQLMCP {
|
|
|
21
21
|
private macroTools;
|
|
22
22
|
private smartQueryBuilderTools;
|
|
23
23
|
private fulltextSearchTools;
|
|
24
|
+
private relationalSeederTools;
|
|
24
25
|
private security;
|
|
25
26
|
private featureConfig;
|
|
26
27
|
constructor(permissionsConfig?: string, categoriesConfig?: string);
|
|
@@ -203,7 +204,19 @@ export declare class MySQLMCP {
|
|
|
203
204
|
data?: any;
|
|
204
205
|
error?: string;
|
|
205
206
|
}>;
|
|
206
|
-
listAllTools(
|
|
207
|
+
listAllTools(params?: {
|
|
208
|
+
tools?: Array<{
|
|
209
|
+
name: string;
|
|
210
|
+
description?: string;
|
|
211
|
+
inputSchema?: any;
|
|
212
|
+
input_schema?: any;
|
|
213
|
+
output_schema?: any;
|
|
214
|
+
}>;
|
|
215
|
+
enabledToolNames?: string[];
|
|
216
|
+
accessProfile?: any;
|
|
217
|
+
serverName?: string;
|
|
218
|
+
serverVersion?: string;
|
|
219
|
+
}): Promise<{
|
|
207
220
|
status: string;
|
|
208
221
|
data?: any;
|
|
209
222
|
error?: string;
|
|
@@ -315,6 +328,15 @@ export declare class MySQLMCP {
|
|
|
315
328
|
data?: any;
|
|
316
329
|
error?: string;
|
|
317
330
|
}>;
|
|
331
|
+
exportQueryToCSV(params: {
|
|
332
|
+
query: string;
|
|
333
|
+
params?: any[];
|
|
334
|
+
include_headers?: boolean;
|
|
335
|
+
}): Promise<{
|
|
336
|
+
status: string;
|
|
337
|
+
data?: any;
|
|
338
|
+
error?: string;
|
|
339
|
+
}>;
|
|
318
340
|
repairQuery(params: {
|
|
319
341
|
query: string;
|
|
320
342
|
error_message?: string;
|
|
@@ -406,6 +428,36 @@ export declare class MySQLMCP {
|
|
|
406
428
|
data?: any;
|
|
407
429
|
error?: string;
|
|
408
430
|
}>;
|
|
431
|
+
planSeedData(params: any): Promise<{
|
|
432
|
+
status: string;
|
|
433
|
+
data?: any;
|
|
434
|
+
error?: string;
|
|
435
|
+
}>;
|
|
436
|
+
generateSeedPreview(params: any): Promise<{
|
|
437
|
+
status: string;
|
|
438
|
+
data?: any;
|
|
439
|
+
error?: string;
|
|
440
|
+
}>;
|
|
441
|
+
executeSeedPlan(params: any): Promise<{
|
|
442
|
+
status: string;
|
|
443
|
+
data?: any;
|
|
444
|
+
error?: string;
|
|
445
|
+
}>;
|
|
446
|
+
validateSeedIntegrity(params: any): Promise<{
|
|
447
|
+
status: string;
|
|
448
|
+
data?: any;
|
|
449
|
+
error?: string;
|
|
450
|
+
}>;
|
|
451
|
+
inferSeedRules(params: any): Promise<{
|
|
452
|
+
status: string;
|
|
453
|
+
data?: any;
|
|
454
|
+
error?: string;
|
|
455
|
+
}>;
|
|
456
|
+
seedFromTemplate(params: any): Promise<{
|
|
457
|
+
status: string;
|
|
458
|
+
data?: any;
|
|
459
|
+
error?: string;
|
|
460
|
+
}>;
|
|
409
461
|
close(): Promise<void>;
|
|
410
462
|
/**
|
|
411
463
|
* Analyze a query and get optimization suggestions
|
package/dist/index.js
CHANGED
|
@@ -22,6 +22,7 @@ const aiTools_1 = require("./tools/aiTools");
|
|
|
22
22
|
const macroTools_1 = require("./tools/macroTools");
|
|
23
23
|
const smartQueryBuilderTools_1 = require("./tools/smartQueryBuilderTools");
|
|
24
24
|
const fulltextSearchTools_1 = require("./tools/fulltextSearchTools");
|
|
25
|
+
const relationalSeederTools_1 = require("./tools/relationalSeederTools");
|
|
25
26
|
const securityLayer_1 = __importDefault(require("./security/securityLayer"));
|
|
26
27
|
const connection_1 = __importDefault(require("./db/connection"));
|
|
27
28
|
const featureConfig_1 = require("./config/featureConfig");
|
|
@@ -51,6 +52,7 @@ class MySQLMCP {
|
|
|
51
52
|
this.macroTools = new macroTools_1.MacroTools(this.security);
|
|
52
53
|
this.smartQueryBuilderTools = new smartQueryBuilderTools_1.SmartQueryBuilderTools(this.security);
|
|
53
54
|
this.fulltextSearchTools = new fulltextSearchTools_1.FulltextSearchTools(this.security);
|
|
55
|
+
this.relationalSeederTools = new relationalSeederTools_1.RelationalSeederTools(this.security);
|
|
54
56
|
}
|
|
55
57
|
// Helper method to check if tool is enabled
|
|
56
58
|
checkToolEnabled(toolName) {
|
|
@@ -134,7 +136,7 @@ class MySQLMCP {
|
|
|
134
136
|
return { status: "error", error: check.error };
|
|
135
137
|
}
|
|
136
138
|
// Additional security check
|
|
137
|
-
if (!this.security.isReadOnlyQuery(params.query)) {
|
|
139
|
+
if (!this.security.isReadOnlyQuery(params.query, this.security.hasExecutePermission())) {
|
|
138
140
|
return {
|
|
139
141
|
status: "error",
|
|
140
142
|
error: "Only SELECT queries are allowed with run_select_query. Use execute_write_query for other operations.",
|
|
@@ -239,12 +241,12 @@ class MySQLMCP {
|
|
|
239
241
|
}
|
|
240
242
|
return await this.utilityTools.readChangelog(params);
|
|
241
243
|
}
|
|
242
|
-
async listAllTools() {
|
|
244
|
+
async listAllTools(params) {
|
|
243
245
|
const check = this.checkToolEnabled("list_all_tools");
|
|
244
246
|
if (!check.enabled) {
|
|
245
247
|
return { status: "error", error: check.error };
|
|
246
248
|
}
|
|
247
|
-
return await this.utilityTools.listAllTools();
|
|
249
|
+
return await this.utilityTools.listAllTools(params);
|
|
248
250
|
}
|
|
249
251
|
// Transaction Tools
|
|
250
252
|
async beginTransaction(params) {
|
|
@@ -276,7 +278,7 @@ class MySQLMCP {
|
|
|
276
278
|
return await this.transactionTools.getTransactionStatus();
|
|
277
279
|
}
|
|
278
280
|
async executeInTransaction(params) {
|
|
279
|
-
const check = this.checkToolEnabled("
|
|
281
|
+
const check = this.checkToolEnabled("executeInTransaction");
|
|
280
282
|
if (!check.enabled) {
|
|
281
283
|
return { status: "error", error: check.error };
|
|
282
284
|
}
|
|
@@ -333,6 +335,13 @@ class MySQLMCP {
|
|
|
333
335
|
}
|
|
334
336
|
return await this.dataExportTools.exportTableToCSV(params);
|
|
335
337
|
}
|
|
338
|
+
async exportQueryToCSV(params) {
|
|
339
|
+
const check = this.checkToolEnabled("exportQueryToCSV");
|
|
340
|
+
if (!check.enabled) {
|
|
341
|
+
return { status: "error", error: check.error };
|
|
342
|
+
}
|
|
343
|
+
return await this.dataExportTools.exportQueryToCSV(params);
|
|
344
|
+
}
|
|
336
345
|
// AI Productivity Tools
|
|
337
346
|
async repairQuery(params) {
|
|
338
347
|
const check = this.checkToolEnabled("repairQuery");
|
|
@@ -407,6 +416,49 @@ class MySQLMCP {
|
|
|
407
416
|
}
|
|
408
417
|
return this.crudTools.bulkDelete(params);
|
|
409
418
|
}
|
|
419
|
+
// Relational Data Seeder Tools
|
|
420
|
+
async planSeedData(params) {
|
|
421
|
+
const check = this.checkToolEnabled("planSeedData");
|
|
422
|
+
if (!check.enabled) {
|
|
423
|
+
return { status: "error", error: check.error };
|
|
424
|
+
}
|
|
425
|
+
return await this.relationalSeederTools.planSeedData(params);
|
|
426
|
+
}
|
|
427
|
+
async generateSeedPreview(params) {
|
|
428
|
+
const check = this.checkToolEnabled("generateSeedPreview");
|
|
429
|
+
if (!check.enabled) {
|
|
430
|
+
return { status: "error", error: check.error };
|
|
431
|
+
}
|
|
432
|
+
return await this.relationalSeederTools.generateSeedPreview(params);
|
|
433
|
+
}
|
|
434
|
+
async executeSeedPlan(params) {
|
|
435
|
+
const check = this.checkToolEnabled("executeSeedPlan");
|
|
436
|
+
if (!check.enabled) {
|
|
437
|
+
return { status: "error", error: check.error };
|
|
438
|
+
}
|
|
439
|
+
return await this.relationalSeederTools.executeSeedPlan(params);
|
|
440
|
+
}
|
|
441
|
+
async validateSeedIntegrity(params) {
|
|
442
|
+
const check = this.checkToolEnabled("validateSeedIntegrity");
|
|
443
|
+
if (!check.enabled) {
|
|
444
|
+
return { status: "error", error: check.error };
|
|
445
|
+
}
|
|
446
|
+
return await this.relationalSeederTools.validateSeedIntegrity(params);
|
|
447
|
+
}
|
|
448
|
+
async inferSeedRules(params) {
|
|
449
|
+
const check = this.checkToolEnabled("inferSeedRules");
|
|
450
|
+
if (!check.enabled) {
|
|
451
|
+
return { status: "error", error: check.error };
|
|
452
|
+
}
|
|
453
|
+
return await this.relationalSeederTools.inferSeedRules(params);
|
|
454
|
+
}
|
|
455
|
+
async seedFromTemplate(params) {
|
|
456
|
+
const check = this.checkToolEnabled("seedFromTemplate");
|
|
457
|
+
if (!check.enabled) {
|
|
458
|
+
return { status: "error", error: check.error };
|
|
459
|
+
}
|
|
460
|
+
return await this.relationalSeederTools.seedFromTemplate(params);
|
|
461
|
+
}
|
|
410
462
|
// Close database connection
|
|
411
463
|
async close() {
|
|
412
464
|
const db = connection_1.default.getInstance();
|