@berthojoris/mcp-mysql-server 1.4.4 โ†’ 1.4.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.
Files changed (3) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +78 -339
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -5,6 +5,24 @@ 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.4.6] - 2025-11-21
9
+
10
+ ### Changed
11
+ - Removed "Execute Permission & Advanced SQL Features" section from README.md
12
+ - Removed "Configuration" section from README.md
13
+ - Removed "REST API Mode" section from README.md
14
+ - Removed "Testing" section from README.md
15
+ - Streamlined documentation by removing outdated or less relevant sections
16
+
17
+ ## [1.4.5] - 2025-01-08
18
+
19
+ ### Changed
20
+ - Reorganized README.md structure - moved "Permission System" section to appear before "Available Tools" section for better user understanding
21
+ - Updated documentation organization to improve readability and user experience
22
+
23
+ ### Fixed
24
+ - Minor documentation formatting improvements
25
+
8
26
  ## [1.4.4] - 2025-01-07
9
27
 
10
28
  ### Fixed
package/README.md CHANGED
@@ -21,39 +21,6 @@ A fully-featured **Model Context Protocol (MCP)** server for MySQL database inte
21
21
 
22
22
  ---
23
23
 
24
- ## ๐Ÿ†• Recent Updates (v1.4.4)
25
-
26
- ### Bug Fixes
27
-
28
- #### โœ… Fixed: First Tool Call Failure Issue
29
- **Problem**: The first tool call would fail with "Connection closed" error (-32000), but subsequent calls would succeed.
30
-
31
- **Root Cause**: The MySQL MCP instance was initialized at module load time, before the MCP transport was fully connected, causing a race condition.
32
-
33
- **Solution**: Moved the initialization to occur after the MCP transport is connected, ensuring proper startup sequence.
34
-
35
- **Impact**: First tool calls now work reliably without needing retry.
36
-
37
- #### โœ… Fixed: Execute Permission Not Respected
38
- **Problem**: Users with `execute` permission would still get "Dangerous keyword detected" errors when using legitimate SQL functions like `LOAD_FILE()`, `UNION`, or accessing `INFORMATION_SCHEMA`.
39
-
40
- **Root Cause**: The security layer blocked certain SQL keywords unconditionally, regardless of granted permissions.
41
-
42
- **Solution**:
43
- - Modified security validation to respect the `execute` permission
44
- - Users with `execute` permission can now use:
45
- - SQL functions like `LOAD_FILE()`, `BENCHMARK()`, `SLEEP()`
46
- - Advanced SELECT features like `UNION` and subqueries
47
- - Access to `INFORMATION_SCHEMA` for metadata queries
48
- - Critical security operations remain blocked (GRANT, REVOKE, INTO OUTFILE, etc.)
49
-
50
- **Impact**: Users with full permissions can now use advanced SQL features as intended.
51
-
52
- ### Breaking Changes
53
- None - all changes are backward compatible.
54
-
55
- ---
56
-
57
24
  ## ๐Ÿ“ฆ Installation
58
25
 
59
26
  ### Option 1: Quick Start (npx)
@@ -144,84 +111,7 @@ Try asking your AI:
144
111
 
145
112
  ---
146
113
 
147
- ## ๐Ÿ› ๏ธ Available Tools
148
-
149
- The MCP server provides **30 powerful tools**:
150
-
151
- ### Database Discovery (4 tools)
152
-
153
- | Tool | Description |
154
- |------|-------------|
155
- | `list_databases` | Lists all databases on the MySQL server |
156
- | `list_tables` | Lists all tables in the current/specified database |
157
- | `read_table_schema` | Gets detailed schema (columns, types, keys, indexes) |
158
- | `get_table_relationships` | Discovers foreign key relationships |
159
-
160
- ### Data Operations - CRUD (4 tools)
161
-
162
- | Tool | Description |
163
- |------|-------------|
164
- | `create_record` | Insert new records with automatic SQL generation |
165
- | `read_records` | Query records with filtering, pagination, and sorting |
166
- | `update_record` | Update records based on conditions |
167
- | `delete_record` | Delete records with safety checks |
168
-
169
- ### Bulk Operations (3 tools)
170
-
171
- | Tool | Description | Performance |
172
- |------|-------------|-------------|
173
- | `bulk_insert` | Insert multiple records in batches for optimal performance | Up to 10,000 records per batch |
174
- | `bulk_update` | Update multiple records with different conditions in batches | Up to 1,000 operations per batch |
175
- | `bulk_delete` | Delete multiple record sets based on different conditions | Up to 1,000 operations per batch |
176
-
177
- ### Custom Queries (2 tools)
178
-
179
- | Tool | Description |
180
- |------|-------------|
181
- | `run_query` | Execute read-only SELECT queries |
182
- | `execute_sql` | Execute write operations (INSERT, UPDATE, DELETE, or DDL with permission) |
183
-
184
- ### Schema Management - DDL (4 tools)
185
-
186
- | Tool | Description | Requires |
187
- |------|-------------|----------|
188
- | `create_table` | Create new tables with columns and indexes | `ddl` permission |
189
- | `alter_table` | Modify table structure (add/drop/modify columns, indexes) | `ddl` permission |
190
- | `drop_table` | Delete tables | `ddl` permission |
191
- | `execute_ddl` | Execute raw DDL SQL (CREATE, ALTER, DROP, TRUNCATE, RENAME) | `ddl` permission |
192
-
193
- ### Utilities (4 tools)
194
-
195
- | Tool | Description |
196
- |------|-------------|
197
- | `test_connection` | Test database connectivity and measure latency |
198
- | `describe_connection` | Get current connection information |
199
- | `export_table_to_csv` | Export table data to CSV format with optional filtering, pagination, and sorting |
200
- | `export_query_to_csv` | Export the results of a SELECT query to CSV format |
201
-
202
- ### Transaction Management (5 tools)
203
-
204
- | Tool | Description |
205
- |------|-------------|
206
- | `begin_transaction` | Start a new database transaction |
207
- | `commit_transaction` | Commit the current transaction |
208
- | `rollback_transaction` | Rollback the current transaction |
209
- | `get_transaction_status` | Check if a transaction is active |
210
- | `execute_in_transaction` | Execute SQL within a transaction context |
211
-
212
- ### Stored Procedures (5 tools)
213
-
214
- | Tool | Description | Requires |
215
- |------|-------------|----------|
216
- | `list_stored_procedures` | List all stored procedures in a database | `procedure` permission |
217
- | `create_stored_procedure` | Create new stored procedures with parameters | `procedure` permission |
218
- | `get_stored_procedure_info` | Get detailed information about a stored procedure | `procedure` permission |
219
- | `execute_stored_procedure` | Execute stored procedures with IN/OUT/INOUT parameters | `procedure` permission |
220
- | `drop_stored_procedure` | Delete stored procedures | `procedure` permission |
221
-
222
- ---
223
-
224
- ## ๐Ÿ” Permission System
114
+ ## Permission System
225
115
 
226
116
  ### Permission Categories
227
117
 
@@ -316,103 +206,6 @@ You can have different databases with different permissions in the same AI agent
316
206
 
317
207
  ---
318
208
 
319
- ## ๐Ÿ”“ Execute Permission & Advanced SQL Features
320
-
321
- The `execute` permission unlocks advanced SQL capabilities that are restricted by default for security reasons.
322
-
323
- ### What Execute Permission Enables
324
-
325
- When you grant the `execute` permission, users can:
326
-
327
- #### 1. **Advanced SQL Functions**
328
- - `LOAD_FILE()` - Read files from the server
329
- - `BENCHMARK()` - Performance testing
330
- - `SLEEP()` - Delay execution
331
- - And other MySQL built-in functions
332
-
333
- #### 2. **Advanced SELECT Features**
334
- - `UNION` queries - Combine multiple SELECT results
335
- - Subqueries in FROM clause - Complex nested queries
336
- - Access to `INFORMATION_SCHEMA` - Database metadata queries
337
-
338
- #### 3. **Execute Custom SQL**
339
- - Use `execute_sql` tool for INSERT, UPDATE, DELETE with advanced features
340
- - Use `run_query` tool for complex SELECT queries with UNION and subqueries
341
-
342
- ### Security Considerations
343
-
344
- **Without `execute` permission:**
345
- ```sql
346
- -- โŒ BLOCKED: UNION queries
347
- SELECT * FROM users WHERE id = 1 UNION SELECT * FROM admin;
348
-
349
- -- โŒ BLOCKED: Subqueries in FROM
350
- SELECT * FROM (SELECT * FROM users WHERE active = 1) AS active_users;
351
-
352
- -- โŒ BLOCKED: LOAD_FILE function
353
- SELECT LOAD_FILE('/etc/passwd');
354
-
355
- -- โŒ BLOCKED: INFORMATION_SCHEMA access
356
- SELECT * FROM INFORMATION_SCHEMA.TABLES;
357
- ```
358
-
359
- **With `execute` permission:**
360
- ```sql
361
- -- โœ… ALLOWED: All advanced SQL features
362
- SELECT * FROM users WHERE id = 1 UNION SELECT * FROM admin;
363
- SELECT * FROM (SELECT * FROM users WHERE active = 1) AS active_users;
364
- SELECT LOAD_FILE('/path/to/file.txt');
365
- SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'mydb';
366
- ```
367
-
368
- ### When to Grant Execute Permission
369
-
370
- **Grant `execute` when:**
371
- - Users need complex analytical queries with UNION or subqueries
372
- - Developers need access to INFORMATION_SCHEMA for metadata analysis
373
- - Advanced SQL functions are required for specific operations
374
- - You trust the user with broader database access
375
-
376
- **Don't grant `execute` when:**
377
- - Users only need basic CRUD operations
378
- - Working with untrusted AI agents
379
- - Production environments with strict security policies
380
- - Read-only access is sufficient
381
-
382
- ### Example: Analytics with Execute Permission
383
-
384
- ```json
385
- {
386
- "args": [
387
- "mysql://analyst:pass@localhost:3306/analytics_db",
388
- "list,read,execute,utility"
389
- ]
390
- }
391
- ```
392
-
393
- This allows the AI agent to run complex analytical queries:
394
-
395
- ```sql
396
- -- Complex query with UNION and subqueries
397
- SELECT 'Q1' as quarter, SUM(revenue) as total
398
- FROM (SELECT * FROM sales WHERE date BETWEEN '2024-01-01' AND '2024-03-31') AS q1_sales
399
- UNION
400
- SELECT 'Q2' as quarter, SUM(revenue) as total
401
- FROM (SELECT * FROM sales WHERE date BETWEEN '2024-04-01' AND '2024-06-30') AS q2_sales;
402
- ```
403
-
404
- ### Critical Security Keywords (Always Blocked)
405
-
406
- Even with `execute` permission, these operations are **always blocked** for security:
407
-
408
- - `GRANT` / `REVOKE` - User privilege management
409
- - `INTO OUTFILE` / `INTO DUMPFILE` - Writing files to server
410
- - `LOAD DATA` - Loading data from files
411
- - Direct access to `mysql`, `performance_schema`, `sys` databases
412
- - `USER` / `PASSWORD` manipulation
413
-
414
- ---
415
-
416
209
  ## ๐Ÿšซ Permission Error Handling
417
210
 
418
211
  The MySQL MCP Server provides clear, user-friendly error messages when operations are attempted without proper permissions. This helps users understand exactly what permissions are needed and how to enable them.
@@ -527,6 +320,83 @@ After (DDL enabled):
527
320
 
528
321
  ---
529
322
 
323
+ ## ๐Ÿ› ๏ธ Available Tools
324
+
325
+ The MCP server provides **30 powerful tools**:
326
+
327
+ ### Database Discovery (4 tools)
328
+
329
+ | Tool | Description |
330
+ |------|-------------|
331
+ | `list_databases` | Lists all databases on the MySQL server |
332
+ | `list_tables` | Lists all tables in the current/specified database |
333
+ | `read_table_schema` | Gets detailed schema (columns, types, keys, indexes) |
334
+ | `get_table_relationships` | Discovers foreign key relationships |
335
+
336
+ ### Data Operations - CRUD (4 tools)
337
+
338
+ | Tool | Description |
339
+ |------|-------------|
340
+ | `create_record` | Insert new records with automatic SQL generation |
341
+ | `read_records` | Query records with filtering, pagination, and sorting |
342
+ | `update_record` | Update records based on conditions |
343
+ | `delete_record` | Delete records with safety checks |
344
+
345
+ ### Bulk Operations (3 tools)
346
+
347
+ | Tool | Description | Performance |
348
+ |------|-------------|-------------|
349
+ | `bulk_insert` | Insert multiple records in batches for optimal performance | Up to 10,000 records per batch |
350
+ | `bulk_update` | Update multiple records with different conditions in batches | Up to 1,000 operations per batch |
351
+ | `bulk_delete` | Delete multiple record sets based on different conditions | Up to 1,000 operations per batch |
352
+
353
+ ### Custom Queries (2 tools)
354
+
355
+ | Tool | Description |
356
+ |------|-------------|
357
+ | `run_query` | Execute read-only SELECT queries |
358
+ | `execute_sql` | Execute write operations (INSERT, UPDATE, DELETE, or DDL with permission) |
359
+
360
+ ### Schema Management - DDL (4 tools)
361
+
362
+ | Tool | Description | Requires |
363
+ |------|-------------|----------|
364
+ | `create_table` | Create new tables with columns and indexes | `ddl` permission |
365
+ | `alter_table` | Modify table structure (add/drop/modify columns, indexes) | `ddl` permission |
366
+ | `drop_table` | Delete tables | `ddl` permission |
367
+ | `execute_ddl` | Execute raw DDL SQL (CREATE, ALTER, DROP, TRUNCATE, RENAME) | `ddl` permission |
368
+
369
+ ### Utilities (4 tools)
370
+
371
+ | Tool | Description |
372
+ |------|-------------|
373
+ | `test_connection` | Test database connectivity and measure latency |
374
+ | `describe_connection` | Get current connection information |
375
+ | `export_table_to_csv` | Export table data to CSV format with optional filtering, pagination, and sorting |
376
+ | `export_query_to_csv` | Export the results of a SELECT query to CSV format |
377
+
378
+ ### Transaction Management (5 tools)
379
+
380
+ | Tool | Description |
381
+ |------|-------------|
382
+ | `begin_transaction` | Start a new database transaction |
383
+ | `commit_transaction` | Commit the current transaction |
384
+ | `rollback_transaction` | Rollback the current transaction |
385
+ | `get_transaction_status` | Check if a transaction is active |
386
+ | `execute_in_transaction` | Execute SQL within a transaction context |
387
+
388
+ ### Stored Procedures (5 tools)
389
+
390
+ | Tool | Description | Requires |
391
+ |------|-------------|----------|
392
+ | `list_stored_procedures` | List all stored procedures in a database | `procedure` permission |
393
+ | `create_stored_procedure` | Create new stored procedures with parameters | `procedure` permission |
394
+ | `get_stored_procedure_info` | Get detailed information about a stored procedure | `procedure` permission |
395
+ | `execute_stored_procedure` | Execute stored procedures with IN/OUT/INOUT parameters | `procedure` permission |
396
+ | `drop_stored_procedure` | Delete stored procedures | `procedure` permission |
397
+
398
+ ---
399
+
530
400
  ## ๐Ÿ—๏ธ DDL Operations
531
401
 
532
402
  DDL (Data Definition Language) operations allow AI to create, modify, and delete tables.
@@ -1189,51 +1059,6 @@ END IF;
1189
1059
 
1190
1060
  ---
1191
1061
 
1192
- ## โš™๏ธ Configuration
1193
-
1194
- ### Connection String Format
1195
-
1196
- ```
1197
- mysql://username:password@host:port/database
1198
- ```
1199
-
1200
- **Examples:**
1201
- ```
1202
- mysql://root:pass@localhost:3306/myapp
1203
- mysql://user:pass@192.168.1.100:3306/production
1204
- mysql://admin:pass@db.example.com:3306/analytics
1205
- ```
1206
-
1207
- **Database name is optional:**
1208
- ```
1209
- mysql://user:pass@localhost:3306/
1210
- ```
1211
-
1212
- When omitted, AI can switch between databases using SQL commands.
1213
-
1214
- ### Environment Variables
1215
-
1216
- Create `.env` file for local development:
1217
-
1218
- ```env
1219
- # MySQL Connection
1220
- DB_HOST=localhost
1221
- DB_PORT=3306
1222
- DB_USER=root
1223
- DB_PASSWORD=yourpassword
1224
- DB_NAME=yourdatabase
1225
-
1226
- # Default Permissions (optional, can be overridden per-project)
1227
- MCP_CONFIG=list,read,utility
1228
-
1229
- # REST API Mode (optional)
1230
- PORT=3000
1231
- JWT_SECRET=your_jwt_secret
1232
- NODE_ENV=development
1233
- ```
1234
-
1235
- ---
1236
-
1237
1062
  ## ๐Ÿ”’ Security Features
1238
1063
 
1239
1064
  ### Built-in Security
@@ -1281,92 +1106,6 @@ NODE_ENV=development
1281
1106
 
1282
1107
  ---
1283
1108
 
1284
- ## ๐ŸŒ REST API Mode
1285
-
1286
- In addition to MCP protocol, this server can run as a REST API.
1287
-
1288
- ### Start API Server
1289
-
1290
- ```bash
1291
- npm run start:api
1292
- ```
1293
-
1294
- Server runs on `http://localhost:3000` (or configured PORT).
1295
-
1296
- ### API Endpoints
1297
-
1298
- All endpoints require JWT authentication (except `/health`).
1299
-
1300
- **Health Check:**
1301
- ```
1302
- GET /health
1303
- ```
1304
-
1305
- **Database Operations:**
1306
- ```
1307
- GET /api/databases # List databases
1308
- GET /api/tables # List tables
1309
- GET /api/tables/:name/schema # Get table schema
1310
- GET /api/tables/:name/records # Read records
1311
- POST /api/tables/:name/records # Create record
1312
- PUT /api/tables/:name/records/:id # Update record
1313
- DELETE /api/tables/:name/records/:id # Delete record
1314
- ```
1315
-
1316
- **Query Operations:**
1317
- ```
1318
- POST /api/query # Execute SELECT query
1319
- POST /api/execute # Execute write query
1320
- ```
1321
-
1322
- **Utilities:**
1323
- ```
1324
- GET /api/connection # Connection info
1325
- GET /api/connection/test # Test connection
1326
- GET /api/tables/:name/relationships # Get foreign keys
1327
- ```
1328
-
1329
- ### Authentication
1330
-
1331
- Include JWT token in Authorization header:
1332
-
1333
- ```bash
1334
- curl -H "Authorization: Bearer YOUR_JWT_TOKEN" \
1335
- http://localhost:3000/api/tables
1336
- ```
1337
-
1338
- ---
1339
-
1340
- ## ๐Ÿงช Testing
1341
-
1342
- ### Test MCP Server Locally
1343
-
1344
- ```bash
1345
- # Test connection using npx (recommended)
1346
- npx -y @berthojoris/mcp-mysql-server mysql://user:pass@localhost:3306/test "list,read,utility"
1347
-
1348
- # Or if you cloned the repository locally
1349
- node bin/mcp-mysql.js mysql://user:pass@localhost:3306/test "list,read,utility"
1350
- ```
1351
-
1352
- ### Test with Claude Desktop
1353
-
1354
- 1. Configure `claude_desktop_config.json`
1355
- 2. Restart Claude Desktop
1356
- 3. Ask: *"What databases are available?"*
1357
-
1358
- ### Test REST API
1359
-
1360
- ```bash
1361
- # Start API server
1362
- npm run start:api
1363
-
1364
- # Test health endpoint
1365
- curl http://localhost:3000/health
1366
- ```
1367
-
1368
- ---
1369
-
1370
1109
  ## ๐Ÿš€ Bulk Operations
1371
1110
 
1372
1111
  The MySQL MCP server includes powerful bulk operation tools designed for high-performance data processing. These tools are optimized for handling large datasets efficiently.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@berthojoris/mcp-mysql-server",
3
- "version": "1.4.4",
3
+ "version": "1.4.6",
4
4
  "description": "Model Context Protocol server for MySQL database integration with dynamic per-project permissions and data export capabilities",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",