@berthojoris/mcp-mysql-server 1.40.4 → 1.40.6
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 +72 -51
- package/DOCUMENTATIONS.md +40 -11
- package/README.md +32 -6
- package/dist/config/featureConfig.js +4 -0
- package/dist/mcp-server.js +101 -1
- package/dist/tools/databaseTools.js +2 -0
- package/manifest.json +13 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,27 @@ 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.6] - 2026-05-04
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- Added `cursor_execute_request`, a no-argument compatibility bridge for Cursor MCP wrappers that cannot send tool `arguments`.
|
|
12
|
+
- The bridge reads `.cursor/mysql-mcp-request.json` or `MYSQL_MCP_CURSOR_REQUEST_FILE` and dispatches to existing MCP tools or auto-routes SQL to SELECT, write, or DDL execution.
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
- Updated tool totals in documentation to include the Cursor bridge.
|
|
16
|
+
- Synchronized version metadata to `1.40.6`.
|
|
17
|
+
|
|
18
|
+
## [1.40.5] - 2026-04-08
|
|
19
|
+
|
|
20
|
+
### Fixed
|
|
21
|
+
- **Critical Bug in `read_table_schema`**: Fixed query that returned mixed data from multiple schemas
|
|
22
|
+
- Query was missing `TABLE_SCHEMA` filter, causing columns from tables with same name in different databases to be returned
|
|
23
|
+
- Added `TABLE_SCHEMA = ?` filter to ensure only columns from the connected database are returned
|
|
24
|
+
- This fixes the issue where AI agents received incorrect schema information when multiple databases had tables with identical names
|
|
25
|
+
|
|
26
|
+
### Changed
|
|
27
|
+
- Synchronized version to `1.40.5` in `package.json`, `src/mcp-server.ts`
|
|
28
|
+
|
|
8
29
|
## [1.40.4] - 2026-03-07
|
|
9
30
|
|
|
10
31
|
### Removed
|
|
@@ -21,57 +42,57 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
21
42
|
- Updated devDependencies: 10 → 9 (removed @types/winston)
|
|
22
43
|
- Synchronized version to `1.40.4` in `package.json`
|
|
23
44
|
|
|
24
|
-
## [1.40.3] - 2026-03-07
|
|
25
|
-
|
|
26
|
-
### Fixed
|
|
27
|
-
- Added missing tool-category mappings for snake_case and camelCase variants in `src/config/featureConfig.ts`
|
|
28
|
-
- Resolved unmapped tools: `get_schema_erd`, `repair_query`, `export_table_to_csv`, `export_query_to_csv`, `analyze_query`, `get_optimization_hints`
|
|
29
|
-
- Ensured dual-layer filtering recognizes all registered MCP tools from `src/mcp-server.ts`
|
|
30
|
-
|
|
31
|
-
### Changed
|
|
32
|
-
- Synchronized versions to `1.40.3` in `package.json`, `src/mcp-server.ts`, and `manifest.json`
|
|
33
|
-
- Updated `README.md` and `DOCUMENTATIONS.md` Last Updated metadata
|
|
34
|
-
|
|
35
|
-
## [1.40.2] - 2026-03-07
|
|
36
|
-
|
|
37
|
-
### Removed
|
|
38
|
-
- **Functions Management Category**: Removed category `functions_management` and all 6 tools
|
|
39
|
-
- `list_functions` - List user-defined functions
|
|
40
|
-
- `get_function_info` - Get function details
|
|
41
|
-
- `create_function` - Create function
|
|
42
|
-
- `drop_function` - Drop function
|
|
43
|
-
- `show_create_function` - Show CREATE FUNCTION statement
|
|
44
|
-
- `execute_function` - Execute function
|
|
45
|
-
- **Backup & Restore Category**: Removed category `backup_restore` and all 5 tools
|
|
46
|
-
- `backup_table` - Backup a single table
|
|
47
|
-
- `backup_database` - Backup entire database
|
|
48
|
-
- `restore_from_sql` - Restore from SQL dump
|
|
49
|
-
- `get_create_table_statement` - Get CREATE TABLE statement
|
|
50
|
-
- `get_database_schema` - Get complete schema snapshot
|
|
51
|
-
- Removed tool modules `src/tools/functionTools.ts` and `src/tools/backupRestoreTools.ts`
|
|
52
|
-
|
|
53
|
-
### Changed
|
|
54
|
-
- Updated tool count: 73 → 62 tools (-11 tools)
|
|
55
|
-
- Updated category count: 15 → 13 categories (removed `functions_management`, `backup_restore`)
|
|
56
|
-
- Updated `src/mcp-server.ts` to remove tool schemas and call routing for all 11 tools
|
|
57
|
-
- Updated `src/index.ts` to remove MySQLMCP imports, fields, initialization, and methods for removed tool sets
|
|
58
|
-
- Updated `src/config/featureConfig.ts` to remove enum values and category mappings for both categories
|
|
59
|
-
- Updated CLI category help in `bin/mcp-mysql.js`
|
|
60
|
-
- Updated `README.md` and `DOCUMENTATIONS.md` to reflect new category list and tool totals
|
|
61
|
-
- Synchronized versions to `1.40.2` in `package.json`, `src/mcp-server.ts`, and `manifest.json`
|
|
62
|
-
|
|
63
|
-
### Fixed
|
|
64
|
-
- Updated procedure permission example in docs to reference `execute_stored_procedure` instead of removed function execution tool
|
|
65
|
-
|
|
66
|
-
## [1.40.1] - 2026-03-06
|
|
67
|
-
|
|
68
|
-
### Changed
|
|
69
|
-
- Synchronized version metadata across `package.json`, `src/mcp-server.ts`, and `manifest.json` to `1.40.1`
|
|
70
|
-
- Updated CLI category examples in `bin/mcp-mysql.js` to match active category set
|
|
71
|
-
- Updated category examples in `README.md` and `DOCUMENTATIONS.md` to remove removed categories
|
|
72
|
-
- Refactored tool registry filtering into `src/tools/toolRegistry.ts`
|
|
73
|
-
- Refactored tool argument validation registry into `src/tools/toolArgumentValidation.ts`
|
|
74
|
-
|
|
45
|
+
## [1.40.3] - 2026-03-07
|
|
46
|
+
|
|
47
|
+
### Fixed
|
|
48
|
+
- Added missing tool-category mappings for snake_case and camelCase variants in `src/config/featureConfig.ts`
|
|
49
|
+
- Resolved unmapped tools: `get_schema_erd`, `repair_query`, `export_table_to_csv`, `export_query_to_csv`, `analyze_query`, `get_optimization_hints`
|
|
50
|
+
- Ensured dual-layer filtering recognizes all registered MCP tools from `src/mcp-server.ts`
|
|
51
|
+
|
|
52
|
+
### Changed
|
|
53
|
+
- Synchronized versions to `1.40.3` in `package.json`, `src/mcp-server.ts`, and `manifest.json`
|
|
54
|
+
- Updated `README.md` and `DOCUMENTATIONS.md` Last Updated metadata
|
|
55
|
+
|
|
56
|
+
## [1.40.2] - 2026-03-07
|
|
57
|
+
|
|
58
|
+
### Removed
|
|
59
|
+
- **Functions Management Category**: Removed category `functions_management` and all 6 tools
|
|
60
|
+
- `list_functions` - List user-defined functions
|
|
61
|
+
- `get_function_info` - Get function details
|
|
62
|
+
- `create_function` - Create function
|
|
63
|
+
- `drop_function` - Drop function
|
|
64
|
+
- `show_create_function` - Show CREATE FUNCTION statement
|
|
65
|
+
- `execute_function` - Execute function
|
|
66
|
+
- **Backup & Restore Category**: Removed category `backup_restore` and all 5 tools
|
|
67
|
+
- `backup_table` - Backup a single table
|
|
68
|
+
- `backup_database` - Backup entire database
|
|
69
|
+
- `restore_from_sql` - Restore from SQL dump
|
|
70
|
+
- `get_create_table_statement` - Get CREATE TABLE statement
|
|
71
|
+
- `get_database_schema` - Get complete schema snapshot
|
|
72
|
+
- Removed tool modules `src/tools/functionTools.ts` and `src/tools/backupRestoreTools.ts`
|
|
73
|
+
|
|
74
|
+
### Changed
|
|
75
|
+
- Updated tool count: 73 → 62 tools (-11 tools)
|
|
76
|
+
- Updated category count: 15 → 13 categories (removed `functions_management`, `backup_restore`)
|
|
77
|
+
- Updated `src/mcp-server.ts` to remove tool schemas and call routing for all 11 tools
|
|
78
|
+
- Updated `src/index.ts` to remove MySQLMCP imports, fields, initialization, and methods for removed tool sets
|
|
79
|
+
- Updated `src/config/featureConfig.ts` to remove enum values and category mappings for both categories
|
|
80
|
+
- Updated CLI category help in `bin/mcp-mysql.js`
|
|
81
|
+
- Updated `README.md` and `DOCUMENTATIONS.md` to reflect new category list and tool totals
|
|
82
|
+
- Synchronized versions to `1.40.2` in `package.json`, `src/mcp-server.ts`, and `manifest.json`
|
|
83
|
+
|
|
84
|
+
### Fixed
|
|
85
|
+
- Updated procedure permission example in docs to reference `execute_stored_procedure` instead of removed function execution tool
|
|
86
|
+
|
|
87
|
+
## [1.40.1] - 2026-03-06
|
|
88
|
+
|
|
89
|
+
### Changed
|
|
90
|
+
- Synchronized version metadata across `package.json`, `src/mcp-server.ts`, and `manifest.json` to `1.40.1`
|
|
91
|
+
- Updated CLI category examples in `bin/mcp-mysql.js` to match active category set
|
|
92
|
+
- Updated category examples in `README.md` and `DOCUMENTATIONS.md` to remove removed categories
|
|
93
|
+
- Refactored tool registry filtering into `src/tools/toolRegistry.ts`
|
|
94
|
+
- Refactored tool argument validation registry into `src/tools/toolArgumentValidation.ts`
|
|
95
|
+
|
|
75
96
|
## [1.40.0] - 2026-03-06
|
|
76
97
|
|
|
77
98
|
### Removed
|
package/DOCUMENTATIONS.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# MySQL MCP Server - Documentation
|
|
2
2
|
|
|
3
|
-
**Last Updated:** 2026-
|
|
4
|
-
**Version:** 1.40.
|
|
5
|
-
**Total Tools:**
|
|
3
|
+
**Last Updated:** 2026-05-04 18:07:52
|
|
4
|
+
**Version:** 1.40.6
|
|
5
|
+
**Total Tools:** 79
|
|
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,custom_queries,analysis"
|
|
40
|
+
"database_discovery,custom_queries,analysis"
|
|
41
41
|
]
|
|
42
42
|
}
|
|
43
43
|
}
|
|
@@ -58,13 +58,41 @@ 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,custom_queries,analysis"
|
|
61
|
+
"MCP_CATEGORIES": "database_discovery,custom_queries,analysis"
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
```
|
|
65
65
|
|
|
66
66
|
---
|
|
67
67
|
|
|
68
|
+
### Cursor Compatibility Bridge
|
|
69
|
+
|
|
70
|
+
Some Cursor MCP wrappers can call a tool by name but cannot pass `arguments`. For that flow, write a request file at `.cursor/mysql-mcp-request.json` and call the no-argument `cursor_execute_request` tool.
|
|
71
|
+
|
|
72
|
+
Execute any existing MCP tool:
|
|
73
|
+
|
|
74
|
+
```json
|
|
75
|
+
{
|
|
76
|
+
"tool": "execute_ddl",
|
|
77
|
+
"arguments": {
|
|
78
|
+
"query": "DROP TABLE IF EXISTS spark_processes;"
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Or execute SQL directly with automatic routing:
|
|
84
|
+
|
|
85
|
+
```json
|
|
86
|
+
{
|
|
87
|
+
"query": "DROP TABLE IF EXISTS spark_processes;",
|
|
88
|
+
"mode": "auto"
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Supported `mode` values are `auto`, `select`, `write`, and `ddl`. Set `MYSQL_MCP_CURSOR_REQUEST_FILE` to override the request file path.
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
68
96
|
## Permission System
|
|
69
97
|
|
|
70
98
|
### Available Permissions
|
|
@@ -80,7 +108,7 @@ Configure MySQL MCP with two access-control layers:
|
|
|
80
108
|
| `ddl` | Schema changes | `create_table`, `alter_table` |
|
|
81
109
|
| `utility` | Utility operations | `test_connection`, `analyze_table` |
|
|
82
110
|
| `transaction` | Transaction management | `begin_transaction`, `commit_transaction` |
|
|
83
|
-
| `procedure` | Stored procedures | `create_stored_procedure`, `execute_stored_procedure` |
|
|
111
|
+
| `procedure` | Stored procedures | `create_stored_procedure`, `execute_stored_procedure` |
|
|
84
112
|
|
|
85
113
|
### Filtering Logic
|
|
86
114
|
|
|
@@ -169,7 +197,7 @@ Tool enabled = (Has Permission) AND (Has Category OR No categories specified)
|
|
|
169
197
|
- `drop_trigger` - Remove triggers
|
|
170
198
|
- `show_create_trigger` - Show CREATE statement
|
|
171
199
|
|
|
172
|
-
### 11. Table Maintenance (8 tools)
|
|
200
|
+
### 11. Table Maintenance (8 tools)
|
|
173
201
|
- `analyze_table` - Update statistics
|
|
174
202
|
- `optimize_table` - Reclaim space
|
|
175
203
|
- `check_table` - Check for errors
|
|
@@ -179,23 +207,24 @@ Tool enabled = (Has Permission) AND (Has Category OR No categories specified)
|
|
|
179
207
|
- `flush_table` - Close/reopen table
|
|
180
208
|
- `get_table_size` - Get size information
|
|
181
209
|
|
|
182
|
-
### 12. Transaction Management (5 tools)
|
|
210
|
+
### 12. Transaction Management (5 tools)
|
|
183
211
|
- `begin_transaction` - Start transaction
|
|
184
212
|
- `commit_transaction` - Commit transaction
|
|
185
213
|
- `rollback_transaction` - Rollback transaction
|
|
186
214
|
- `get_transaction_status` - Check transaction state
|
|
187
215
|
- `execute_in_transaction` - Execute within transaction
|
|
188
216
|
|
|
189
|
-
### 13. Query Optimization (3 tools)
|
|
217
|
+
### 13. Query Optimization (3 tools)
|
|
190
218
|
- `analyze_query` - Analyze query performance
|
|
191
219
|
- `get_optimization_hints` - Get optimizer hints
|
|
192
220
|
- `repair_query` - Repair broken SQL queries
|
|
193
221
|
|
|
194
|
-
### 14. Utilities (
|
|
222
|
+
### 14. Utilities (5 tools)
|
|
195
223
|
- `test_connection` - Test connectivity
|
|
196
224
|
- `describe_connection` - Connection info
|
|
197
225
|
- `read_changelog` - Read changelog
|
|
198
226
|
- `invalidate_table_cache` - Clear table cache
|
|
227
|
+
- `cursor_execute_request` - Execute a file-backed request for clients that cannot send MCP arguments
|
|
199
228
|
|
|
200
229
|
---
|
|
201
230
|
|
|
@@ -383,4 +412,4 @@ The system provides detailed error messages indicating:
|
|
|
383
412
|
|
|
384
413
|
---
|
|
385
414
|
|
|
386
|
-
*For detailed examples and advanced usage patterns, see the project README.md.*
|
|
415
|
+
*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-
|
|
7
|
+
**Last Updated:** 2026-05-04 18:07:52
|
|
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,custom_queries,analysis"
|
|
203
|
+
"MCP_CATEGORIES": "database_discovery,custom_queries,analysis"
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
206
|
}
|
|
@@ -211,6 +211,32 @@ For more client-specific config snippets, see **[DOCUMENTATIONS.md → Setup & C
|
|
|
211
211
|
|
|
212
212
|
---
|
|
213
213
|
|
|
214
|
+
### Cursor Compatibility Bridge
|
|
215
|
+
|
|
216
|
+
If a Cursor MCP wrapper can call tools but cannot send `arguments`, use the no-argument `cursor_execute_request` bridge. Create `.cursor/mysql-mcp-request.json` in the workspace, then call `cursor_execute_request`:
|
|
217
|
+
|
|
218
|
+
```json
|
|
219
|
+
{
|
|
220
|
+
"tool": "execute_ddl",
|
|
221
|
+
"arguments": {
|
|
222
|
+
"query": "DROP TABLE IF EXISTS spark_processes;"
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
For direct SQL, the bridge can infer the right SQL tool:
|
|
228
|
+
|
|
229
|
+
```json
|
|
230
|
+
{
|
|
231
|
+
"query": "DROP TABLE IF EXISTS spark_processes;",
|
|
232
|
+
"mode": "auto"
|
|
233
|
+
}
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
Set `MYSQL_MCP_CURSOR_REQUEST_FILE` to override the request file path.
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
214
240
|
## Permission System
|
|
215
241
|
|
|
216
242
|
Control database access with a **dual-layer filtering system** that provides both broad and fine-grained control:
|
|
@@ -245,12 +271,12 @@ Use documentation categories to fine-tune which tools are exposed (Layer 2):
|
|
|
245
271
|
|
|
246
272
|
| Category List | Use Case | List Tools |
|
|
247
273
|
|---------------|----------|-----------|
|
|
248
|
-
| `database_discovery` | Explore databases, tables, and schema structure | `get_all_tables_relationships, list_databases, list_tables, read_table_schema` |
|
|
274
|
+
| `database_discovery` | Explore databases, tables, and schema structure | `get_all_tables_relationships, list_databases, list_tables, read_table_schema` |
|
|
249
275
|
| `crud_operations` | Create, read, update, delete operations on data | `create_record, delete_record, read_records, update_record` |
|
|
250
276
|
| `bulk_operations` | High-performance batch processing operations | `bulk_delete, bulk_insert, bulk_update` |
|
|
251
277
|
| `custom_queries` | Execute custom SQL queries and advanced operations | `execute_write_query, run_select_query` |
|
|
252
278
|
| `schema_management` | Manage database schema, tables, and structure | `alter_table, create_table, drop_table, execute_ddl` |
|
|
253
|
-
| `utilities` | Database utilities, diagnostics, and helper functions | `describe_connection, export_query_to_csv, export_table_to_csv, list_all_tools, read_changelog, test_connection` |
|
|
279
|
+
| `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` |
|
|
254
280
|
| `transaction_management` | Handle ACID transactions and rollback operations | `begin_transaction, commit_transaction, execute_in_transaction, get_transaction_status, rollback_transaction` |
|
|
255
281
|
| `stored_procedures` | Create, execute, and manage stored procedures | `create_stored_procedure, drop_stored_procedure, execute_stored_procedure, get_stored_procedure_info, list_stored_procedures, show_create_procedure` |
|
|
256
282
|
| `views_management` | Create and manage database views | `alter_view, create_view, drop_view, get_view_info, list_views, show_create_view` |
|
|
@@ -265,7 +291,7 @@ Use documentation categories to fine-tune which tools are exposed (Layer 2):
|
|
|
265
291
|
<summary>Copy/paste list (comma-separated, no spaces)</summary>
|
|
266
292
|
|
|
267
293
|
```text
|
|
268
|
-
database_discovery,crud_operations,bulk_operations,custom_queries,schema_management,utilities,transaction_management,stored_procedures,views_management,triggers_management,index_management,constraint_management,table_maintenance,query_optimization,analysis
|
|
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
|
|
269
295
|
```
|
|
270
296
|
|
|
271
297
|
</details>
|
|
@@ -276,7 +302,7 @@ Full category → tool mapping (and examples) lives in **[DOCUMENTATIONS.md →
|
|
|
276
302
|
|
|
277
303
|
## Available Tools
|
|
278
304
|
|
|
279
|
-
The server exposes **
|
|
305
|
+
The server exposes **79 tools** organized into categories (CRUD, schema, and utilities).
|
|
280
306
|
|
|
281
307
|
- Complete list of tools: **[DOCUMENTATIONS.md → Complete Tools Reference](DOCUMENTATIONS.md#🔧-complete-tools-reference)**
|
|
282
308
|
|
|
@@ -81,6 +81,8 @@ exports.toolCategoryMap = {
|
|
|
81
81
|
executeDdl: ToolCategory.DDL,
|
|
82
82
|
// Utility tools
|
|
83
83
|
describeConnection: ToolCategory.UTILITY,
|
|
84
|
+
cursorExecuteRequest: ToolCategory.UTILITY,
|
|
85
|
+
cursor_execute_request: ToolCategory.UTILITY,
|
|
84
86
|
testConnection: ToolCategory.UTILITY,
|
|
85
87
|
getAllTablesRelationships: ToolCategory.UTILITY,
|
|
86
88
|
exportTableToCSV: ToolCategory.UTILITY,
|
|
@@ -183,6 +185,8 @@ exports.toolDocCategoryMap = {
|
|
|
183
185
|
// Utilities
|
|
184
186
|
testConnection: DocCategory.UTILITIES,
|
|
185
187
|
describeConnection: DocCategory.UTILITIES,
|
|
188
|
+
cursorExecuteRequest: DocCategory.UTILITIES,
|
|
189
|
+
cursor_execute_request: DocCategory.UTILITIES,
|
|
186
190
|
exportTableToCSV: DocCategory.UTILITIES,
|
|
187
191
|
exportTableToCsv: DocCategory.UTILITIES,
|
|
188
192
|
export_table_to_csv: DocCategory.UTILITIES,
|
package/dist/mcp-server.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
3
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
4
9
|
const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js");
|
|
5
10
|
const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
6
11
|
const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
|
|
@@ -641,6 +646,14 @@ const TOOLS = [
|
|
|
641
646
|
properties: {},
|
|
642
647
|
},
|
|
643
648
|
},
|
|
649
|
+
{
|
|
650
|
+
name: "cursor_execute_request",
|
|
651
|
+
description: "Cursor compatibility bridge for clients that can call MCP tools but cannot send arguments. Reads .cursor/mysql-mcp-request.json (or MYSQL_MCP_CURSOR_REQUEST_FILE) and dispatches to the requested MySQL MCP tool. The request file supports {\"tool\":\"execute_ddl\",\"arguments\":{\"query\":\"DROP TABLE IF EXISTS t;\"}} or direct SQL with {\"query\":\"...\",\"mode\":\"auto\"}.",
|
|
652
|
+
inputSchema: {
|
|
653
|
+
type: "object",
|
|
654
|
+
properties: {},
|
|
655
|
+
},
|
|
656
|
+
},
|
|
644
657
|
{
|
|
645
658
|
name: "read_changelog",
|
|
646
659
|
description: "Reads the MySQL MCP Server changelog to see version history, new features, bug fixes, and breaking changes. Useful for understanding tool capabilities and recent updates.",
|
|
@@ -1850,7 +1863,7 @@ const TOOLS = [
|
|
|
1850
1863
|
// Create the MCP server
|
|
1851
1864
|
const server = new index_js_1.Server({
|
|
1852
1865
|
name: "mysql-mcp-server",
|
|
1853
|
-
version: "1.40.
|
|
1866
|
+
version: "1.40.6",
|
|
1854
1867
|
}, {
|
|
1855
1868
|
capabilities: {
|
|
1856
1869
|
tools: {},
|
|
@@ -1865,6 +1878,90 @@ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => {
|
|
|
1865
1878
|
tools: enabledTools,
|
|
1866
1879
|
};
|
|
1867
1880
|
});
|
|
1881
|
+
const TOOL_METHOD_OVERRIDES = {
|
|
1882
|
+
get_schema_erd: "getSchemaERD",
|
|
1883
|
+
export_table_to_csv: "exportTableToCSV",
|
|
1884
|
+
export_query_to_csv: "exportQueryToCSV",
|
|
1885
|
+
};
|
|
1886
|
+
const toCamelCase = (value) => value.replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
1887
|
+
const getCursorRequestFilePath = () => {
|
|
1888
|
+
const configuredPath = process.env.MYSQL_MCP_CURSOR_REQUEST_FILE ||
|
|
1889
|
+
process.env.MCP_MYSQL_REQUEST_FILE ||
|
|
1890
|
+
".cursor/mysql-mcp-request.json";
|
|
1891
|
+
return path_1.default.isAbsolute(configuredPath)
|
|
1892
|
+
? configuredPath
|
|
1893
|
+
: path_1.default.resolve(process.cwd(), configuredPath);
|
|
1894
|
+
};
|
|
1895
|
+
const inferSqlToolName = (query, mode = "auto") => {
|
|
1896
|
+
const upperQuery = query.trim().toUpperCase();
|
|
1897
|
+
if (mode === "select")
|
|
1898
|
+
return "run_select_query";
|
|
1899
|
+
if (mode === "write")
|
|
1900
|
+
return "execute_write_query";
|
|
1901
|
+
if (mode === "ddl")
|
|
1902
|
+
return "execute_ddl";
|
|
1903
|
+
if (/^(CREATE|ALTER|DROP|TRUNCATE|RENAME)\b/.test(upperQuery)) {
|
|
1904
|
+
return "execute_ddl";
|
|
1905
|
+
}
|
|
1906
|
+
if (/^(INSERT|UPDATE|DELETE|REPLACE)\b/.test(upperQuery)) {
|
|
1907
|
+
return "execute_write_query";
|
|
1908
|
+
}
|
|
1909
|
+
if (/^(SELECT|WITH)\b/.test(upperQuery)) {
|
|
1910
|
+
return "run_select_query";
|
|
1911
|
+
}
|
|
1912
|
+
throw new Error("Unable to infer SQL tool. Set mode to one of: select, write, ddl.");
|
|
1913
|
+
};
|
|
1914
|
+
const executeToolByName = async (toolName, args = {}) => {
|
|
1915
|
+
const knownToolNames = new Set(TOOLS.map((tool) => tool.name));
|
|
1916
|
+
if (!knownToolNames.has(toolName)) {
|
|
1917
|
+
throw new Error(`Unknown tool for Cursor bridge: ${toolName}`);
|
|
1918
|
+
}
|
|
1919
|
+
if (toolName === "cursor_execute_request") {
|
|
1920
|
+
throw new Error("cursor_execute_request cannot dispatch to itself");
|
|
1921
|
+
}
|
|
1922
|
+
const methodName = TOOL_METHOD_OVERRIDES[toolName] || toCamelCase(toolName);
|
|
1923
|
+
const method = mysqlMCP[methodName];
|
|
1924
|
+
if (typeof method !== "function") {
|
|
1925
|
+
throw new Error(`No handler method found for Cursor bridge tool: ${toolName}`);
|
|
1926
|
+
}
|
|
1927
|
+
return await method.call(mysqlMCP, args);
|
|
1928
|
+
};
|
|
1929
|
+
const executeCursorRequest = async () => {
|
|
1930
|
+
const requestFilePath = getCursorRequestFilePath();
|
|
1931
|
+
if (!fs_1.default.existsSync(requestFilePath)) {
|
|
1932
|
+
return {
|
|
1933
|
+
status: "error",
|
|
1934
|
+
error: `Cursor request file not found: ${requestFilePath}. ` +
|
|
1935
|
+
'Create it with JSON like {"tool":"execute_ddl","arguments":{"query":"DROP TABLE IF EXISTS spark_processes;"}}',
|
|
1936
|
+
};
|
|
1937
|
+
}
|
|
1938
|
+
let request;
|
|
1939
|
+
try {
|
|
1940
|
+
request = JSON.parse(fs_1.default.readFileSync(requestFilePath, "utf8"));
|
|
1941
|
+
}
|
|
1942
|
+
catch (error) {
|
|
1943
|
+
return {
|
|
1944
|
+
status: "error",
|
|
1945
|
+
error: `Failed to read Cursor request file: ${error.message}`,
|
|
1946
|
+
};
|
|
1947
|
+
}
|
|
1948
|
+
const requestedTool = request.tool || request.toolName || request.name;
|
|
1949
|
+
if (requestedTool) {
|
|
1950
|
+
return await executeToolByName(requestedTool, request.arguments || request.args || {});
|
|
1951
|
+
}
|
|
1952
|
+
if (request.query) {
|
|
1953
|
+
const inferredTool = inferSqlToolName(request.query, request.mode || "auto");
|
|
1954
|
+
return await executeToolByName(inferredTool, {
|
|
1955
|
+
query: request.query,
|
|
1956
|
+
params: request.params,
|
|
1957
|
+
dry_run: request.dry_run,
|
|
1958
|
+
});
|
|
1959
|
+
}
|
|
1960
|
+
return {
|
|
1961
|
+
status: "error",
|
|
1962
|
+
error: "Cursor request must contain either tool/toolName/name with arguments, or query with optional mode.",
|
|
1963
|
+
};
|
|
1964
|
+
};
|
|
1868
1965
|
// Handle tool call requests
|
|
1869
1966
|
server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
|
|
1870
1967
|
const { name, arguments: args } = request.params;
|
|
@@ -1951,6 +2048,9 @@ server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
|
|
|
1951
2048
|
case "describe_connection":
|
|
1952
2049
|
result = await mysqlMCP.describeConnection();
|
|
1953
2050
|
break;
|
|
2051
|
+
case "cursor_execute_request":
|
|
2052
|
+
result = await executeCursorRequest();
|
|
2053
|
+
break;
|
|
1954
2054
|
case "test_connection":
|
|
1955
2055
|
result = await mysqlMCP.testConnection();
|
|
1956
2056
|
break;
|
|
@@ -120,11 +120,13 @@ class DatabaseTools {
|
|
|
120
120
|
FROM
|
|
121
121
|
INFORMATION_SCHEMA.COLUMNS
|
|
122
122
|
WHERE
|
|
123
|
+
TABLE_SCHEMA = ? AND
|
|
123
124
|
TABLE_NAME = ?
|
|
124
125
|
ORDER BY
|
|
125
126
|
ORDINAL_POSITION
|
|
126
127
|
`;
|
|
127
128
|
const results = await this.db.query(query, [
|
|
129
|
+
config_1.dbConfig.database,
|
|
128
130
|
params.table_name,
|
|
129
131
|
]);
|
|
130
132
|
return {
|
package/manifest.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mysql-mcp",
|
|
3
3
|
"description": "A Model Context Protocol for MySQL database interaction",
|
|
4
|
-
"version": "1.40.
|
|
4
|
+
"version": "1.40.6",
|
|
5
5
|
"tools": [
|
|
6
6
|
{
|
|
7
7
|
"name": "list_databases",
|
|
@@ -348,6 +348,17 @@
|
|
|
348
348
|
}
|
|
349
349
|
}
|
|
350
350
|
},
|
|
351
|
+
{
|
|
352
|
+
"name": "cursor_execute_request",
|
|
353
|
+
"description": "Cursor compatibility bridge for clients that cannot send MCP tool arguments. Reads .cursor/mysql-mcp-request.json or MYSQL_MCP_CURSOR_REQUEST_FILE and dispatches to an existing MySQL MCP tool.",
|
|
354
|
+
"input_schema": {
|
|
355
|
+
"type": "object",
|
|
356
|
+
"properties": {}
|
|
357
|
+
},
|
|
358
|
+
"output_schema": {
|
|
359
|
+
"type": "object"
|
|
360
|
+
}
|
|
361
|
+
},
|
|
351
362
|
{
|
|
352
363
|
"name": "list_all_tools",
|
|
353
364
|
"description": "Lists all available MCP tools with their definitions and server metadata.",
|
|
@@ -730,4 +741,4 @@
|
|
|
730
741
|
}
|
|
731
742
|
}
|
|
732
743
|
]
|
|
733
|
-
}
|
|
744
|
+
}
|
package/package.json
CHANGED