@berthojoris/mcp-mysql-server 1.43.2 → 1.44.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 +57 -6
- package/DOCUMENTATIONS.md +40 -38
- package/README.md +26 -7
- package/bin/mcp-mysql.js +168 -168
- package/dist/cache/queryCache.js +1 -1
- package/dist/config/config.js +2 -1
- package/dist/config/featureConfig.d.ts +5 -0
- package/dist/config/featureConfig.js +26 -12
- package/dist/db/connection.d.ts +8 -1
- package/dist/db/connection.js +19 -14
- package/dist/index.js +0 -10
- package/dist/mcp-server.js +45 -305
- package/dist/security/securityLayer.d.ts +33 -5
- package/dist/security/securityLayer.js +211 -58
- package/dist/tools/aiTools.js +1 -1
- package/dist/tools/dataExportTools.js +8 -0
- package/dist/tools/queryTools.d.ts +1 -1
- package/dist/tools/queryTools.js +6 -7
- package/dist/tools/toolArgumentValidation.js +22 -22
- package/dist/tools/toolRegistry.d.ts +1 -1
- package/dist/tools/toolRegistry.js +7 -1
- package/dist/tools/transactionTools.js +1 -1
- package/manifest.json +5 -5
- package/package.json +86 -78
- package/dist/auth/authService.d.ts +0 -29
- package/dist/auth/authService.js +0 -114
- package/dist/tools/backupRestoreTools.d.ts +0 -18
- package/dist/tools/backupRestoreTools.js +0 -70
- package/dist/tools/documentationGeneratorTools.d.ts +0 -145
- package/dist/tools/documentationGeneratorTools.js +0 -820
- package/dist/tools/forecastingTools.d.ts +0 -36
- package/dist/tools/forecastingTools.js +0 -256
- package/dist/tools/functionTools.d.ts +0 -87
- package/dist/tools/functionTools.js +0 -358
- package/dist/tools/indexRecommendationTools.d.ts +0 -50
- package/dist/tools/indexRecommendationTools.js +0 -451
- package/dist/tools/intelligentQueryTools.d.ts +0 -94
- package/dist/tools/intelligentQueryTools.js +0 -713
- package/dist/tools/performanceTools.d.ts +0 -76
- package/dist/tools/performanceTools.js +0 -505
- package/dist/tools/processTools.d.ts +0 -61
- package/dist/tools/processTools.js +0 -181
- package/dist/tools/queryVisualizationTools.d.ts +0 -22
- package/dist/tools/queryVisualizationTools.js +0 -155
- package/dist/tools/schemaDesignTools.d.ts +0 -67
- package/dist/tools/schemaDesignTools.js +0 -359
- package/dist/tools/schemaPatternTools.d.ts +0 -19
- package/dist/tools/schemaPatternTools.js +0 -253
- package/dist/tools/schemaVersioningTools.d.ts +0 -138
- package/dist/tools/schemaVersioningTools.js +0 -1008
- package/dist/tools/securityAuditTools.d.ts +0 -39
- package/dist/tools/securityAuditTools.js +0 -319
- package/dist/tools/smartDiscoveryTools.d.ts +0 -163
- package/dist/tools/smartDiscoveryTools.js +0 -750
- package/dist/tools/testDataTools.d.ts +0 -26
- package/dist/tools/testDataTools.js +0 -325
package/CHANGELOG.md
CHANGED
|
@@ -5,12 +5,63 @@ 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.
|
|
9
|
-
|
|
10
|
-
### Changed
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
|
|
8
|
+
## [1.44.0] - 2026-10-26
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
- **Read-only default permissions**: when neither permissions nor categories are configured, the server enables only `list,read,utility` instead of every tool. Configurations that relied on the old default must now list permissions explicitly.
|
|
12
|
+
- **No implicit `mysql` schema**: `DB_NAME` no longer falls back to the `mysql` system schema. Without a configured database, database-scoped tools return "No database specified".
|
|
13
|
+
- **Query cache disabled by default**: opt in with `CACHE_ENABLED=true`.
|
|
14
|
+
- `CallTool` dispatch now resolves tools to their `MySQLMCP` method through the same path as the Cursor bridge, replacing the per-tool `switch`. The server version is read from `package.json`.
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
- SQL validation no longer rejects `#`, `;`, `--`, or `/* */` inside string literals and quoted identifiers (e.g. `WHERE color = '#fff'`). Literals containing backslashes still get the strict raw-text check because their meaning depends on `NO_BACKSLASH_ESCAPES`.
|
|
18
|
+
- `WITH` (CTE) queries are classified by their main statement (SELECT/UPDATE/DELETE) instead of being rejected. CTEs in read queries require `execute`, as derived tables do.
|
|
19
|
+
- When the cache is enabled, writes executed inside transactions and transaction commits now clear it, and table-name guessing was replaced by clearing the whole cache on any data-changing statement (covers db-qualified names, multi-table writes, DDL, and `EXPLAIN ANALYZE`).
|
|
20
|
+
- `npm run build` now removes `dist/` first, so the stale `dist/auth/authService.js` (JWT code with a default secret and an undeclared `jsonwebtoken` dependency) is no longer published.
|
|
21
|
+
- `npm run dev` (ts-node) works again: local imports no longer use `.js` suffixes that ts-node could not resolve.
|
|
22
|
+
- Restricted permission profiles no longer log "Unknown tool" warnings for tools mapped only by their snake_case name.
|
|
23
|
+
|
|
24
|
+
### Added
|
|
25
|
+
- Jest test suite in `src/__tests__/` covering the SQL validator, default permissions, and cache invalidation.
|
|
26
|
+
|
|
27
|
+
### Removed
|
|
28
|
+
- Unused `next-env.d.ts`. Removed the inaccurate "PII masking in exports" claim from the documentation; results are returned unmasked. The catalog remains at 88 tools.
|
|
29
|
+
|
|
30
|
+
## [1.43.5] - 2026-10-12
|
|
31
|
+
|
|
32
|
+
### Added
|
|
33
|
+
- Added `SECURITY.md` defining supported versions, private vulnerability reporting via GitHub Private Vulnerability Reporting, report requirements, and response/disclosure expectations (acknowledgment within 7 days, coordinated disclosure).
|
|
34
|
+
|
|
35
|
+
### Changed
|
|
36
|
+
- Linked the security reporting policy from `README.md` and `DOCUMENTATIONS.md`, and synchronized version metadata to `1.43.5`; the catalog remains at 88 tools.
|
|
37
|
+
|
|
38
|
+
## [1.43.4] - 2026-10-12
|
|
39
|
+
|
|
40
|
+
### Fixed
|
|
41
|
+
- Authorized `EXPLAIN ANALYZE` statements as the SQL operation they execute. MySQL 8.0.18+ runs the wrapped statement (including multi-table UPDATE/DELETE), so it now requires the matching permission: `read` for SELECT, `update` or `execute` for UPDATE, and `delete` for DELETE. This closes a bypass where `transaction` plus `list`/`read` could run `EXPLAIN ANALYZE UPDATE/DELETE` through `execute_in_transaction` without the corresponding write permission.
|
|
42
|
+
|
|
43
|
+
### Changed
|
|
44
|
+
- Updated permission documentation for `EXPLAIN ANALYZE` (plan-only `EXPLAIN` remains an information query) and synchronized version metadata to `1.43.4`; the catalog remains at 88 tools.
|
|
45
|
+
|
|
46
|
+
## [1.43.3] - 2026-10-12
|
|
47
|
+
|
|
48
|
+
### Fixed
|
|
49
|
+
- Enforced permission/category checks at tool execution, including the Cursor bridge and its destination tool.
|
|
50
|
+
- Required SQL operation permissions inside transactions; DDL also respects the schema tool category.
|
|
51
|
+
- Required both `utility` and `read` for CSV exports, including tool discovery and direct execution.
|
|
52
|
+
- Restricted `execute_write_query` to INSERT/UPDATE/DELETE, preventing DDL through the write-query tool.
|
|
53
|
+
- Applied mandatory dangerous SQL checks regardless of `execute` permission, including information queries and query repair.
|
|
54
|
+
|
|
55
|
+
### Changed
|
|
56
|
+
- Updated permission documentation and tool descriptions. Advanced SELECT features still require `execute`.
|
|
57
|
+
- Synchronized version metadata and lockfile to `1.43.3`; the catalog remains at 88 tools.
|
|
58
|
+
|
|
59
|
+
## [1.43.2] - 2026-07-23
|
|
60
|
+
|
|
61
|
+
### Changed
|
|
62
|
+
- Version bump to `1.43.2` for npm publish.
|
|
63
|
+
- Synchronized version across `package.json`, `src/mcp-server.ts`, `DOCUMENTATIONS.md`, `README.md`, and `manifest.json`.
|
|
64
|
+
|
|
14
65
|
## [1.43.1] - 2026-05-26
|
|
15
66
|
|
|
16
67
|
### Fixed
|
package/DOCUMENTATIONS.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# MySQL MCP Server - Documentation
|
|
2
2
|
|
|
3
|
-
**Last Updated:** 2026-
|
|
4
|
-
**Version:** 1.
|
|
3
|
+
**Last Updated:** 2026-10-26 13:35:39
|
|
4
|
+
**Version:** 1.44.0
|
|
5
5
|
**Total Tools:** 88
|
|
6
6
|
|
|
7
7
|
Comprehensive documentation for the MySQL MCP Server. For quick start, see [README.md](README.md).
|
|
@@ -65,6 +65,12 @@ Configure MySQL MCP with two access-control layers:
|
|
|
65
65
|
}
|
|
66
66
|
```
|
|
67
67
|
|
|
68
|
+
### Defaults (v1.44.0, 2026-10-26 13:35:39)
|
|
69
|
+
|
|
70
|
+
- **Permissions**: when neither permissions nor categories are given, the server starts **read-only** with `list,read,utility`. Earlier versions enabled every tool. To enable everything, pass the full list: `list,read,create,update,delete,execute,ddl,utility,transaction,procedure`.
|
|
71
|
+
- **Database**: when the connection string has no database and `DB_NAME` is unset, no database is selected and database-scoped tools return "No database specified". Earlier versions fell back to the `mysql` system schema.
|
|
72
|
+
- **Query cache**: disabled by default. Set `CACHE_ENABLED=true` to opt in (`CACHE_TTL_MS`, default `60000`; `CACHE_MAX_SIZE`, default `100`). When enabled, any statement that can change data (outside or inside a transaction) and every transaction commit clears the whole cache. Writes made by other clients are not detected, so cached results can lag by up to the TTL.
|
|
73
|
+
|
|
68
74
|
---
|
|
69
75
|
|
|
70
76
|
### Cursor Compatibility Bridge
|
|
@@ -93,6 +99,8 @@ Or execute SQL directly with automatic routing:
|
|
|
93
99
|
|
|
94
100
|
Supported `mode` values are `auto`, `select`, `write`, and `ddl`. Set `MYSQL_MCP_CURSOR_REQUEST_FILE` to override the request file path.
|
|
95
101
|
|
|
102
|
+
The bridge requires `utility` permission and the `utilities` category when category filtering is enabled. The requested destination tool must also be enabled. Disabled tools cannot be called directly or through the bridge.
|
|
103
|
+
|
|
96
104
|
---
|
|
97
105
|
|
|
98
106
|
### AI Agent Tool Discovery
|
|
@@ -126,6 +134,18 @@ For CSV exports, use `export_table_to_csv` for table-based exports and `export_q
|
|
|
126
134
|
Tool enabled = (Has Permission) AND (Has Category OR No categories specified)
|
|
127
135
|
```
|
|
128
136
|
|
|
137
|
+
With no permissions and no categories configured, the effective permissions are `list,read,utility` (read-only default since v1.44.0). Categories alone keep all permissions and filter by category.
|
|
138
|
+
|
|
139
|
+
CSV exports require both `utility` and `read` permissions; their category remains `utilities`.
|
|
140
|
+
|
|
141
|
+
`execute_in_transaction` requires `transaction` plus the permission for the SQL operation: `read` for SELECT, `create` or `execute` for INSERT, `update` or `execute` for UPDATE, and `delete` for DELETE. DDL also requires `ddl` and an enabled `execute_ddl` tool. Transaction permission alone does not authorize reading or modifying data.
|
|
142
|
+
|
|
143
|
+
Information queries such as SHOW/DESCRIBE/EXPLAIN require `list` or `read`. MySQL DDL may implicitly commit, even when called through a transaction tool.
|
|
144
|
+
|
|
145
|
+
`EXPLAIN ANALYZE` (MySQL 8.0.18+) executes the statement it wraps, including multi-table UPDATE/DELETE, so it is authorized as that inner statement: `read` for SELECT, `update` or `execute` for UPDATE, and `delete` for DELETE. Plan-only `EXPLAIN` (without ANALYZE) remains an information query and only requires `list` or `read` (2026-10-12 20:39:13).
|
|
146
|
+
|
|
147
|
+
`execute_write_query` accepts only INSERT, UPDATE, and DELETE. Schema changes must use enabled DDL tools, even when `execute` and `ddl` permissions are both present.
|
|
148
|
+
|
|
129
149
|
---
|
|
130
150
|
|
|
131
151
|
## Tool Categories
|
|
@@ -162,10 +182,9 @@ Tool enabled = (Has Permission) AND (Has Category OR No categories specified)
|
|
|
162
182
|
- `infer_seed_rules` - Infer advanced generators from schema, samples, unique indexes, and domain presets
|
|
163
183
|
- `seed_from_template` - Create reusable plan-first seed workflows for ecommerce, POS, and CRM domains
|
|
164
184
|
|
|
165
|
-
### 5. Query Management (
|
|
185
|
+
### 5. Query Management (2 tools)
|
|
166
186
|
- `run_select_query` - Execute SELECT queries
|
|
167
187
|
- `execute_write_query` - Execute INSERT/UPDATE (DELETE requires the `delete` permission)
|
|
168
|
-
- `repair_query` - Diagnose and fix SQL errors
|
|
169
188
|
|
|
170
189
|
### 6. Schema Management (4 tools)
|
|
171
190
|
- `create_table` - Create new tables
|
|
@@ -177,11 +196,12 @@ Tool enabled = (Has Permission) AND (Has Category OR No categories specified)
|
|
|
177
196
|
- `export_table_to_csv` - Export table data to CSV
|
|
178
197
|
- `export_query_to_csv` - Export SELECT query results to CSV
|
|
179
198
|
|
|
180
|
-
### 8. Index Management (
|
|
199
|
+
### 8. Index Management (11 tools)
|
|
181
200
|
- `list_indexes` - List table indexes
|
|
182
201
|
- `get_index_info` - Get index details
|
|
183
202
|
- `create_index` - Create indexes
|
|
184
203
|
- `drop_index` - Drop indexes
|
|
204
|
+
- `analyze_index` - Analyze and update index statistics
|
|
185
205
|
- `create_fulltext_index` - Create FULLTEXT indexes for text search
|
|
186
206
|
- `fulltext_search` - Perform full-text search with MATCH AGAINST
|
|
187
207
|
- `get_fulltext_info` - Get FULLTEXT index information
|
|
@@ -445,12 +465,19 @@ await mcp.call("commit_transaction", {});
|
|
|
445
465
|
- **Layer 1**: Broad permission categories (list, read, create, etc.)
|
|
446
466
|
- **Layer 2**: Fine-grained tool category filtering
|
|
447
467
|
- **Tool-level**: Each tool requires specific permissions
|
|
468
|
+
- **Execution-time enforcement**: Tool permissions and categories are checked for every call, including file-backed Cursor requests.
|
|
469
|
+
- **Mandatory SQL restrictions**: File access, account/privilege changes, dangerous server operations, comments, and multiple statements remain blocked even with `execute`. Execute permission permits advanced SELECT features, not bypassing these restrictions.
|
|
470
|
+
- **Quoted content (v1.44.0)**: Comment, statement-separator, and keyword checks ignore the contents of string literals and quoted identifiers, so values such as `'#fff'`, `'a;b'`, or `'x -- y'` are accepted. A literal containing a backslash is lexed differently depending on `NO_BACKSLASH_ESCAPES`, so such queries are checked strictly against the raw text.
|
|
471
|
+
- **Common table expressions (v1.44.0)**: `WITH ... SELECT/UPDATE/DELETE` is authorized as its main statement. Like derived tables and UNION, a CTE in a read query requires `execute`. A `WITH` clause that cannot be parsed is rejected.
|
|
472
|
+
|
|
473
|
+
### Vulnerability Reporting
|
|
474
|
+
|
|
475
|
+
Suspected security issues must be reported privately via GitHub Private Vulnerability Reporting; see `SECURITY.md` for the policy, reporting requirements, and disclosure timeline (added 2026-10-12 21:16:54).
|
|
448
476
|
|
|
449
477
|
### Data Protection
|
|
450
478
|
|
|
451
|
-
- **PII Masking**: Automatic sensitive data redaction in exports
|
|
452
|
-
- **Safe Exports**: `safe_export_table` masks emails, credit cards, passwords
|
|
453
479
|
- **Query Validation**: Input validation and SQL injection prevention
|
|
480
|
+
- **No result masking**: Query and export results are returned unmasked. Restrict sensitive columns with database privileges or views.
|
|
454
481
|
|
|
455
482
|
### Connection Security
|
|
456
483
|
|
|
@@ -460,37 +487,6 @@ await mcp.call("commit_transaction", {});
|
|
|
460
487
|
|
|
461
488
|
---
|
|
462
489
|
|
|
463
|
-
## Migration & Schema Management
|
|
464
|
-
|
|
465
|
-
### Schema Versioning
|
|
466
|
-
|
|
467
|
-
Complete migration support with tracking:
|
|
468
|
-
|
|
469
|
-
```javascript
|
|
470
|
-
// Initialize migration tracking
|
|
471
|
-
await mcp.call("init_migrations_table", {});
|
|
472
|
-
|
|
473
|
-
// Create migration
|
|
474
|
-
await mcp.call("create_migration", {
|
|
475
|
-
name: "add_user_avatar",
|
|
476
|
-
up_sql: "ALTER TABLE users ADD COLUMN avatar VARCHAR(255);",
|
|
477
|
-
down_sql: "ALTER TABLE users DROP COLUMN avatar;"
|
|
478
|
-
});
|
|
479
|
-
|
|
480
|
-
// Apply migrations
|
|
481
|
-
await mcp.call("apply_migrations", { dry_run: false });
|
|
482
|
-
```
|
|
483
|
-
|
|
484
|
-
### Schema Comparison
|
|
485
|
-
|
|
486
|
-
```javascript
|
|
487
|
-
// Compare table structures
|
|
488
|
-
await mcp.call("compare_table_structure", {
|
|
489
|
-
table1: "users_old",
|
|
490
|
-
table2: "users_new"
|
|
491
|
-
});
|
|
492
|
-
```
|
|
493
|
-
|
|
494
490
|
---
|
|
495
491
|
|
|
496
492
|
## Troubleshooting
|
|
@@ -508,6 +504,12 @@ If your client reports `MCP error -32000: Connection closed`, the server process
|
|
|
508
504
|
|
|
509
505
|
If you see `ReferenceError: exports is not defined in ES module scope` in the server stderr logs, update to **v1.33.2+** (fixes an ESM/CJS mismatch that caused the MCP process to exit immediately).
|
|
510
506
|
|
|
507
|
+
### Development
|
|
508
|
+
|
|
509
|
+
- `npm run build` removes `dist/` before compiling, so files deleted from `src/` are never published.
|
|
510
|
+
- `npm run dev` runs `src/mcp-server.ts` with ts-node (fixed in v1.44.0).
|
|
511
|
+
- `npm test` runs the Jest suite in `src/__tests__/` (SQL validator, permission defaults, cache invalidation).
|
|
512
|
+
|
|
511
513
|
### Error Messages
|
|
512
514
|
|
|
513
515
|
The system provides detailed error messages indicating:
|
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-
|
|
7
|
+
**Last Updated:** 2026-10-26 13:35:39
|
|
8
8
|
|
|
9
9
|
[](https://www.npmjs.com/package/@berthojoris/mcp-mysql-server)
|
|
10
10
|
[](https://www.npmjs.com/package/@berthojoris/mcp-mysql-server)
|
|
@@ -271,6 +271,24 @@ Control database access with a **dual-layer filtering system** that provides bot
|
|
|
271
271
|
| `transaction` | BEGIN, COMMIT, ROLLBACK | ACID operations |
|
|
272
272
|
| `utility` | Connection testing, diagnostics | Troubleshooting |
|
|
273
273
|
|
|
274
|
+
**Changes in v1.44.0 (review before upgrading):**
|
|
275
|
+
- **Read-only by default**: with no permissions and no categories, the server now enables only `list,read,utility` (previously every tool). To keep full access, pass `list,read,create,update,delete,execute,ddl,utility,transaction,procedure`.
|
|
276
|
+
- **No implicit `mysql` schema**: without a database in the connection string or `DB_NAME`, database-scoped tools report "No database specified" instead of using the `mysql` system schema.
|
|
277
|
+
- **Query cache off by default**: opt in with `CACHE_ENABLED=true`. Any write and every transaction commit now clears the cache.
|
|
278
|
+
- **SQL validation**: `#`, `;`, and `--` inside string values (e.g. `'#fff'`) are no longer rejected. `WITH` (CTE) queries are supported and, like derived tables, need `execute` in read queries.
|
|
279
|
+
|
|
280
|
+
**Security changes in v1.43.4:**
|
|
281
|
+
- `EXPLAIN ANALYZE` runs the statement it wraps (MySQL 8.0.18+), so it now requires that statement's permission: `delete` for DELETE, `update` or `execute` for UPDATE, `read` for SELECT. Plan-only `EXPLAIN` still needs just `list` or `read`.
|
|
282
|
+
|
|
283
|
+
**Security changes in v1.43.3:**
|
|
284
|
+
- CSV exports require both `utility` and `read`; enable the `utilities` category when filtering categories.
|
|
285
|
+
- SQL within a transaction requires the corresponding operation permission. `transaction` alone does not permit reads or writes.
|
|
286
|
+
- `execute_write_query` accepts only INSERT/UPDATE/DELETE. DDL requires enabled DDL tools.
|
|
287
|
+
- Disabled tools cannot be called directly or through the Cursor bridge. The bridge requires `utility` and an enabled destination tool.
|
|
288
|
+
- `execute` does not bypass mandatory SQL safety restrictions, including file access and account/privilege changes.
|
|
289
|
+
|
|
290
|
+
Report suspected security issues privately via [Private Vulnerability Reporting](https://github.com/berthojoris/mysql-mcp/security/advisories/new); see [SECURITY.md](SECURITY.md) for the policy.
|
|
291
|
+
|
|
274
292
|
Common configuration examples are documented in **[DOCUMENTATIONS.md → Category Filtering System](DOCUMENTATIONS.md#🆕-category-filtering-system)**.
|
|
275
293
|
|
|
276
294
|
---
|
|
@@ -292,10 +310,10 @@ Use documentation categories to fine-tune which tools are exposed (Layer 2):
|
|
|
292
310
|
| `stored_procedures` | Create, execute, and manage stored procedures | `create_stored_procedure, drop_stored_procedure, execute_stored_procedure, get_stored_procedure_info, list_stored_procedures, show_create_procedure` |
|
|
293
311
|
| `views_management` | Create and manage database views | `alter_view, create_view, drop_view, get_view_info, list_views, show_create_view` |
|
|
294
312
|
| `triggers_management` | Create and manage database triggers | `create_trigger, drop_trigger, get_trigger_info, list_triggers, show_create_trigger` |
|
|
295
|
-
| `index_management` | Optimize performance with index management | `analyze_index, create_index, drop_index, get_index_info, list_indexes` |
|
|
313
|
+
| `index_management` | Optimize performance with index and fulltext management | `analyze_index, create_fulltext_index, create_index, drop_fulltext_index, drop_index, fulltext_search, get_fulltext_info, get_fulltext_stats, get_index_info, list_indexes, optimize_fulltext` |
|
|
296
314
|
| `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` |
|
|
297
315
|
| `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` |
|
|
298
|
-
| `query_optimization` | Analyze and optimize SQL queries | `analyze_query, get_optimization_hints` |
|
|
316
|
+
| `query_optimization` | Analyze and optimize SQL queries | `analyze_query, get_optimization_hints, repair_query` |
|
|
299
317
|
| `analysis` | Data analysis, schema discovery, and reporting tools | `find_tables_by_keyword, get_column_statistics, get_database_summary, get_schema_erd, get_schema_rag_context, search_data_across_tables, search_schema` |
|
|
300
318
|
|
|
301
319
|
<details>
|
|
@@ -324,13 +342,14 @@ The server exposes **88 tools** organized into categories (CRUD, seed, schema, d
|
|
|
324
342
|
For comprehensive documentation, see **[DOCUMENTATIONS.md](DOCUMENTATIONS.md)**:
|
|
325
343
|
|
|
326
344
|
- **DDL Operations** - Create, alter, and drop tables
|
|
327
|
-
- **Data Export Tools** - Export to CSV
|
|
345
|
+
- **Data Export Tools** - Export data to CSV format
|
|
328
346
|
- **Relational Data Seeder** - Plan, preview, execute, validate, infer rules, and template FK-aware dummy data
|
|
329
|
-
- **
|
|
330
|
-
- **Data Migration Tools** - Copy, move, clone, compare, and sync data
|
|
331
|
-
- **Schema Versioning** - Version control for database schema changes
|
|
347
|
+
- **Full-Text Search** - Create and search FULLTEXT indexes with multiple search modes
|
|
332
348
|
- **Transaction Management** - ACID transactions
|
|
333
349
|
- **Stored Procedures** - Create and execute with IN/OUT/INOUT parameters
|
|
350
|
+
- **Views & Triggers** - Manage database views and triggers
|
|
351
|
+
- **Index & Constraint Management** - Optimize performance and enforce data integrity
|
|
352
|
+
- **Table Maintenance** - Analyze, optimize, check, and repair tables
|
|
334
353
|
- **Query Logging** - See all SQL queries executed automatically
|
|
335
354
|
- **Security Features** - Built-in security and best practices
|
|
336
355
|
- **Bulk Operations** - High-performance batch processing
|
package/bin/mcp-mysql.js
CHANGED
|
@@ -1,168 +1,168 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* MCP MySQL Server CLI
|
|
5
|
-
* This script allows the MySQL MCP server to be run via NPX
|
|
6
|
-
* It implements the Model Context Protocol using stdio transport
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
const dotenv = require("dotenv");
|
|
10
|
-
|
|
11
|
-
dotenv.config();
|
|
12
|
-
|
|
13
|
-
// Get MySQL connection string, permissions, and optional categories
|
|
14
|
-
const args = process.argv.slice(2);
|
|
15
|
-
const mysqlUrl = args.shift();
|
|
16
|
-
|
|
17
|
-
let permissions;
|
|
18
|
-
let categories;
|
|
19
|
-
|
|
20
|
-
for (let i = 0; i < args.length; i++) {
|
|
21
|
-
const arg = args[i];
|
|
22
|
-
|
|
23
|
-
if (permissions === undefined) {
|
|
24
|
-
permissions = arg;
|
|
25
|
-
continue;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (categories === undefined) {
|
|
29
|
-
categories = arg;
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (!mysqlUrl) {
|
|
35
|
-
console.error("Error: MySQL connection URL is required");
|
|
36
|
-
console.error(
|
|
37
|
-
"Usage: mcp-mysql mysql://user:password@host:port/dbname [permissions] [categories]",
|
|
38
|
-
);
|
|
39
|
-
console.error("");
|
|
40
|
-
console.error("Examples:");
|
|
41
|
-
console.error(" #
|
|
42
|
-
console.error(" mcp-mysql mysql://root:pass@localhost:3306/mydb");
|
|
43
|
-
console.error("");
|
|
44
|
-
console.error(" # Permission-based filtering only (Layer 1)");
|
|
45
|
-
console.error(
|
|
46
|
-
' mcp-mysql mysql://root:pass@localhost:3306/mydb "list,read,utility"',
|
|
47
|
-
);
|
|
48
|
-
console.error("");
|
|
49
|
-
console.error(
|
|
50
|
-
" # Dual-layer: Permissions + Categories (fine-grained control)",
|
|
51
|
-
);
|
|
52
|
-
console.error(
|
|
53
|
-
' mcp-mysql mysql://root:pass@localhost:3306/mydb "list,read,utility" "database_discovery,custom_queries,analysis"',
|
|
54
|
-
);
|
|
55
|
-
console.error("");
|
|
56
|
-
console.error("Permissions (Layer 1 - Broad Control):");
|
|
57
|
-
console.error(
|
|
58
|
-
" list, read, create, update, delete, execute, ddl, utility, transaction, procedure",
|
|
59
|
-
);
|
|
60
|
-
console.error("");
|
|
61
|
-
console.error("Categories (Layer 2 - Fine-Grained Control, Optional):");
|
|
62
|
-
console.error(
|
|
63
|
-
" database_discovery, crud_operations, bulk_operations, custom_queries,",
|
|
64
|
-
);
|
|
65
|
-
console.error(
|
|
66
|
-
" schema_management, utilities, transaction_management, stored_procedures,",
|
|
67
|
-
);
|
|
68
|
-
console.error(
|
|
69
|
-
" views_management, triggers_management, index_management,",
|
|
70
|
-
);
|
|
71
|
-
console.error(
|
|
72
|
-
" constraint_management, table_maintenance, query_optimization,",
|
|
73
|
-
);
|
|
74
|
-
console.error(
|
|
75
|
-
" analysis, seed_operations",
|
|
76
|
-
);
|
|
77
|
-
console.error("");
|
|
78
|
-
console.error("Filtering Logic:");
|
|
79
|
-
console.error(
|
|
80
|
-
" - If only permissions: All tools within those permissions enabled",
|
|
81
|
-
);
|
|
82
|
-
console.error(
|
|
83
|
-
" - If permissions + categories: Only tools matching BOTH layers enabled",
|
|
84
|
-
);
|
|
85
|
-
console.error(" - If nothing specified:
|
|
86
|
-
process.exit(1);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// Parse the MySQL URL to extract connection details
|
|
90
|
-
let connectionConfig;
|
|
91
|
-
let database;
|
|
92
|
-
try {
|
|
93
|
-
const url = new URL(mysqlUrl);
|
|
94
|
-
|
|
95
|
-
// Remove leading slash from pathname and make database optional
|
|
96
|
-
database = url.pathname.replace(/^\//, "") || null;
|
|
97
|
-
|
|
98
|
-
// Extract username and password from auth.
|
|
99
|
-
// Both fields may be URL-encoded (e.g. "@" -> "%40"), so always decode
|
|
100
|
-
// whatever the URL parser hands us, including when only one side is set.
|
|
101
|
-
const decodeAuthField = (value) =>
|
|
102
|
-
value ? decodeURIComponent(value) : value;
|
|
103
|
-
const auth = {
|
|
104
|
-
user: decodeAuthField(url.username) || "root",
|
|
105
|
-
password: decodeAuthField(url.password) || "",
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
connectionConfig = {
|
|
109
|
-
host: url.hostname,
|
|
110
|
-
port: url.port || 3306,
|
|
111
|
-
...auth,
|
|
112
|
-
...(database ? { database } : {}),
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
// Set environment variables for the server
|
|
116
|
-
process.env.DB_HOST = connectionConfig.host;
|
|
117
|
-
process.env.DB_PORT = connectionConfig.port;
|
|
118
|
-
process.env.DB_USER = connectionConfig.user;
|
|
119
|
-
process.env.DB_PASSWORD = connectionConfig.password;
|
|
120
|
-
if (database) {
|
|
121
|
-
process.env.DB_NAME = database;
|
|
122
|
-
}
|
|
123
|
-
} catch (error) {
|
|
124
|
-
console.error("Error parsing MySQL URL:", error.message);
|
|
125
|
-
console.error(
|
|
126
|
-
"Usage: npx @berthojoris/mcp-mysql-server mysql://user:password@host:port/dbname",
|
|
127
|
-
);
|
|
128
|
-
process.exit(1);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
const dbMessage = database
|
|
132
|
-
? `${connectionConfig.host}:${connectionConfig.port}/${database}`
|
|
133
|
-
: `${connectionConfig.host}:${connectionConfig.port} (no specific database selected)`;
|
|
134
|
-
|
|
135
|
-
// Set permissions/categories as environment variables if provided
|
|
136
|
-
if (permissions) {
|
|
137
|
-
process.env.MCP_PERMISSIONS = permissions;
|
|
138
|
-
console.error(`Permissions (Layer 1): ${permissions}`);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
if (categories) {
|
|
142
|
-
process.env.MCP_CATEGORIES = categories;
|
|
143
|
-
console.error(`Categories (Layer 2): ${categories}`);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
if (!permissions && !categories) {
|
|
147
|
-
console.error("Access Control:
|
|
148
|
-
} else if (permissions && categories) {
|
|
149
|
-
console.error("Filtering Mode: Dual-layer (Permissions + Categories)");
|
|
150
|
-
} else if (permissions && !categories) {
|
|
151
|
-
console.error("Filtering Mode: Permission-based only");
|
|
152
|
-
} else if (!permissions && categories) {
|
|
153
|
-
console.error("Filtering Mode: Category-only");
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
// Log to stderr (not stdout, which is used for MCP protocol)
|
|
157
|
-
console.error(`Starting MySQL MCP server with connection to ${dbMessage}`);
|
|
158
|
-
|
|
159
|
-
// Run the MCP server directly (no child process spawn)
|
|
160
|
-
// This ensures proper stdio communication for MCP protocol
|
|
161
|
-
try {
|
|
162
|
-
// Directly require and execute the MCP server module
|
|
163
|
-
// This avoids stdio forwarding issues with child processes
|
|
164
|
-
require("../dist/mcp-server.js");
|
|
165
|
-
} catch (error) {
|
|
166
|
-
console.error("Error starting MCP server:", error.message);
|
|
167
|
-
process.exit(1);
|
|
168
|
-
}
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* MCP MySQL Server CLI
|
|
5
|
+
* This script allows the MySQL MCP server to be run via NPX
|
|
6
|
+
* It implements the Model Context Protocol using stdio transport
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const dotenv = require("dotenv");
|
|
10
|
+
|
|
11
|
+
dotenv.config();
|
|
12
|
+
|
|
13
|
+
// Get MySQL connection string, permissions, and optional categories
|
|
14
|
+
const args = process.argv.slice(2);
|
|
15
|
+
const mysqlUrl = args.shift();
|
|
16
|
+
|
|
17
|
+
let permissions;
|
|
18
|
+
let categories;
|
|
19
|
+
|
|
20
|
+
for (let i = 0; i < args.length; i++) {
|
|
21
|
+
const arg = args[i];
|
|
22
|
+
|
|
23
|
+
if (permissions === undefined) {
|
|
24
|
+
permissions = arg;
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (categories === undefined) {
|
|
29
|
+
categories = arg;
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (!mysqlUrl) {
|
|
35
|
+
console.error("Error: MySQL connection URL is required");
|
|
36
|
+
console.error(
|
|
37
|
+
"Usage: mcp-mysql mysql://user:password@host:port/dbname [permissions] [categories]",
|
|
38
|
+
);
|
|
39
|
+
console.error("");
|
|
40
|
+
console.error("Examples:");
|
|
41
|
+
console.error(" # Read-only default (list,read,utility)");
|
|
42
|
+
console.error(" mcp-mysql mysql://root:pass@localhost:3306/mydb");
|
|
43
|
+
console.error("");
|
|
44
|
+
console.error(" # Permission-based filtering only (Layer 1)");
|
|
45
|
+
console.error(
|
|
46
|
+
' mcp-mysql mysql://root:pass@localhost:3306/mydb "list,read,utility"',
|
|
47
|
+
);
|
|
48
|
+
console.error("");
|
|
49
|
+
console.error(
|
|
50
|
+
" # Dual-layer: Permissions + Categories (fine-grained control)",
|
|
51
|
+
);
|
|
52
|
+
console.error(
|
|
53
|
+
' mcp-mysql mysql://root:pass@localhost:3306/mydb "list,read,utility" "database_discovery,custom_queries,analysis"',
|
|
54
|
+
);
|
|
55
|
+
console.error("");
|
|
56
|
+
console.error("Permissions (Layer 1 - Broad Control):");
|
|
57
|
+
console.error(
|
|
58
|
+
" list, read, create, update, delete, execute, ddl, utility, transaction, procedure",
|
|
59
|
+
);
|
|
60
|
+
console.error("");
|
|
61
|
+
console.error("Categories (Layer 2 - Fine-Grained Control, Optional):");
|
|
62
|
+
console.error(
|
|
63
|
+
" database_discovery, crud_operations, bulk_operations, custom_queries,",
|
|
64
|
+
);
|
|
65
|
+
console.error(
|
|
66
|
+
" schema_management, utilities, transaction_management, stored_procedures,",
|
|
67
|
+
);
|
|
68
|
+
console.error(
|
|
69
|
+
" views_management, triggers_management, index_management,",
|
|
70
|
+
);
|
|
71
|
+
console.error(
|
|
72
|
+
" constraint_management, table_maintenance, query_optimization,",
|
|
73
|
+
);
|
|
74
|
+
console.error(
|
|
75
|
+
" analysis, seed_operations",
|
|
76
|
+
);
|
|
77
|
+
console.error("");
|
|
78
|
+
console.error("Filtering Logic:");
|
|
79
|
+
console.error(
|
|
80
|
+
" - If only permissions: All tools within those permissions enabled",
|
|
81
|
+
);
|
|
82
|
+
console.error(
|
|
83
|
+
" - If permissions + categories: Only tools matching BOTH layers enabled",
|
|
84
|
+
);
|
|
85
|
+
console.error(" - If nothing specified: Read-only default (list,read,utility)");
|
|
86
|
+
process.exit(1);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Parse the MySQL URL to extract connection details
|
|
90
|
+
let connectionConfig;
|
|
91
|
+
let database;
|
|
92
|
+
try {
|
|
93
|
+
const url = new URL(mysqlUrl);
|
|
94
|
+
|
|
95
|
+
// Remove leading slash from pathname and make database optional
|
|
96
|
+
database = url.pathname.replace(/^\//, "") || null;
|
|
97
|
+
|
|
98
|
+
// Extract username and password from auth.
|
|
99
|
+
// Both fields may be URL-encoded (e.g. "@" -> "%40"), so always decode
|
|
100
|
+
// whatever the URL parser hands us, including when only one side is set.
|
|
101
|
+
const decodeAuthField = (value) =>
|
|
102
|
+
value ? decodeURIComponent(value) : value;
|
|
103
|
+
const auth = {
|
|
104
|
+
user: decodeAuthField(url.username) || "root",
|
|
105
|
+
password: decodeAuthField(url.password) || "",
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
connectionConfig = {
|
|
109
|
+
host: url.hostname,
|
|
110
|
+
port: url.port || 3306,
|
|
111
|
+
...auth,
|
|
112
|
+
...(database ? { database } : {}),
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
// Set environment variables for the server
|
|
116
|
+
process.env.DB_HOST = connectionConfig.host;
|
|
117
|
+
process.env.DB_PORT = connectionConfig.port;
|
|
118
|
+
process.env.DB_USER = connectionConfig.user;
|
|
119
|
+
process.env.DB_PASSWORD = connectionConfig.password;
|
|
120
|
+
if (database) {
|
|
121
|
+
process.env.DB_NAME = database;
|
|
122
|
+
}
|
|
123
|
+
} catch (error) {
|
|
124
|
+
console.error("Error parsing MySQL URL:", error.message);
|
|
125
|
+
console.error(
|
|
126
|
+
"Usage: npx @berthojoris/mcp-mysql-server mysql://user:password@host:port/dbname",
|
|
127
|
+
);
|
|
128
|
+
process.exit(1);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const dbMessage = database
|
|
132
|
+
? `${connectionConfig.host}:${connectionConfig.port}/${database}`
|
|
133
|
+
: `${connectionConfig.host}:${connectionConfig.port} (no specific database selected)`;
|
|
134
|
+
|
|
135
|
+
// Set permissions/categories as environment variables if provided
|
|
136
|
+
if (permissions) {
|
|
137
|
+
process.env.MCP_PERMISSIONS = permissions;
|
|
138
|
+
console.error(`Permissions (Layer 1): ${permissions}`);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (categories) {
|
|
142
|
+
process.env.MCP_CATEGORIES = categories;
|
|
143
|
+
console.error(`Categories (Layer 2): ${categories}`);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (!permissions && !categories) {
|
|
147
|
+
console.error("Access Control: Read-only default (list,read,utility)");
|
|
148
|
+
} else if (permissions && categories) {
|
|
149
|
+
console.error("Filtering Mode: Dual-layer (Permissions + Categories)");
|
|
150
|
+
} else if (permissions && !categories) {
|
|
151
|
+
console.error("Filtering Mode: Permission-based only");
|
|
152
|
+
} else if (!permissions && categories) {
|
|
153
|
+
console.error("Filtering Mode: Category-only");
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Log to stderr (not stdout, which is used for MCP protocol)
|
|
157
|
+
console.error(`Starting MySQL MCP server with connection to ${dbMessage}`);
|
|
158
|
+
|
|
159
|
+
// Run the MCP server directly (no child process spawn)
|
|
160
|
+
// This ensures proper stdio communication for MCP protocol
|
|
161
|
+
try {
|
|
162
|
+
// Directly require and execute the MCP server module
|
|
163
|
+
// This avoids stdio forwarding issues with child processes
|
|
164
|
+
require("../dist/mcp-server.js");
|
|
165
|
+
} catch (error) {
|
|
166
|
+
console.error("Error starting MCP server:", error.message);
|
|
167
|
+
process.exit(1);
|
|
168
|
+
}
|
package/dist/cache/queryCache.js
CHANGED
|
@@ -9,7 +9,7 @@ const crypto_1 = __importDefault(require("crypto"));
|
|
|
9
9
|
* Default cache configuration
|
|
10
10
|
*/
|
|
11
11
|
const DEFAULT_CONFIG = {
|
|
12
|
-
enabled: true
|
|
12
|
+
enabled: false, // Opt in with CACHE_ENABLED=true; writes by other clients are not detected
|
|
13
13
|
ttlMs: 60000, // 1 minute default TTL
|
|
14
14
|
maxSize: 100, // Maximum 100 cached queries
|
|
15
15
|
maxMemoryMB: 50, // Maximum 50MB memory usage
|
package/dist/config/config.js
CHANGED
|
@@ -12,7 +12,8 @@ exports.dbConfig = {
|
|
|
12
12
|
port: parseInt(process.env.DB_PORT || '3306', 10),
|
|
13
13
|
user: process.env.DB_USER || 'root',
|
|
14
14
|
password: process.env.DB_PASSWORD || '',
|
|
15
|
-
database
|
|
15
|
+
// Empty means no database selected; never default to the mysql system schema
|
|
16
|
+
database: process.env.DB_NAME || '',
|
|
16
17
|
};
|
|
17
18
|
exports.default = {
|
|
18
19
|
database: exports.dbConfig,
|
|
@@ -43,6 +43,11 @@ export declare const toolCategoryMap: Record<string, ToolCategory>;
|
|
|
43
43
|
* Map of tool names to their documentation categories (New Enhanced System)
|
|
44
44
|
*/
|
|
45
45
|
export declare const toolDocCategoryMap: Record<string, DocCategory>;
|
|
46
|
+
/**
|
|
47
|
+
* Permissions used when neither permissions nor categories are configured.
|
|
48
|
+
* Read-only by default; write and schema access must be granted explicitly.
|
|
49
|
+
*/
|
|
50
|
+
export declare const DEFAULT_PERMISSIONS = "list,read,utility";
|
|
46
51
|
/**
|
|
47
52
|
* Class to manage feature configuration based on runtime or environment variables
|
|
48
53
|
* Supports dual-layer filtering:
|