@berthojoris/mcp-mysql-server 1.4.5 โ 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.
- package/CHANGELOG.md +9 -0
- package/README.md +0 -261
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,15 @@ 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
|
+
|
|
8
17
|
## [1.4.5] - 2025-01-08
|
|
9
18
|
|
|
10
19
|
### Changed
|
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)
|
|
@@ -239,103 +206,6 @@ You can have different databases with different permissions in the same AI agent
|
|
|
239
206
|
|
|
240
207
|
---
|
|
241
208
|
|
|
242
|
-
## ๐ Execute Permission & Advanced SQL Features
|
|
243
|
-
|
|
244
|
-
The `execute` permission unlocks advanced SQL capabilities that are restricted by default for security reasons.
|
|
245
|
-
|
|
246
|
-
### What Execute Permission Enables
|
|
247
|
-
|
|
248
|
-
When you grant the `execute` permission, users can:
|
|
249
|
-
|
|
250
|
-
#### 1. **Advanced SQL Functions**
|
|
251
|
-
- `LOAD_FILE()` - Read files from the server
|
|
252
|
-
- `BENCHMARK()` - Performance testing
|
|
253
|
-
- `SLEEP()` - Delay execution
|
|
254
|
-
- And other MySQL built-in functions
|
|
255
|
-
|
|
256
|
-
#### 2. **Advanced SELECT Features**
|
|
257
|
-
- `UNION` queries - Combine multiple SELECT results
|
|
258
|
-
- Subqueries in FROM clause - Complex nested queries
|
|
259
|
-
- Access to `INFORMATION_SCHEMA` - Database metadata queries
|
|
260
|
-
|
|
261
|
-
#### 3. **Execute Custom SQL**
|
|
262
|
-
- Use `execute_sql` tool for INSERT, UPDATE, DELETE with advanced features
|
|
263
|
-
- Use `run_query` tool for complex SELECT queries with UNION and subqueries
|
|
264
|
-
|
|
265
|
-
### Security Considerations
|
|
266
|
-
|
|
267
|
-
**Without `execute` permission:**
|
|
268
|
-
```sql
|
|
269
|
-
-- โ BLOCKED: UNION queries
|
|
270
|
-
SELECT * FROM users WHERE id = 1 UNION SELECT * FROM admin;
|
|
271
|
-
|
|
272
|
-
-- โ BLOCKED: Subqueries in FROM
|
|
273
|
-
SELECT * FROM (SELECT * FROM users WHERE active = 1) AS active_users;
|
|
274
|
-
|
|
275
|
-
-- โ BLOCKED: LOAD_FILE function
|
|
276
|
-
SELECT LOAD_FILE('/etc/passwd');
|
|
277
|
-
|
|
278
|
-
-- โ BLOCKED: INFORMATION_SCHEMA access
|
|
279
|
-
SELECT * FROM INFORMATION_SCHEMA.TABLES;
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
**With `execute` permission:**
|
|
283
|
-
```sql
|
|
284
|
-
-- โ
ALLOWED: All advanced SQL features
|
|
285
|
-
SELECT * FROM users WHERE id = 1 UNION SELECT * FROM admin;
|
|
286
|
-
SELECT * FROM (SELECT * FROM users WHERE active = 1) AS active_users;
|
|
287
|
-
SELECT LOAD_FILE('/path/to/file.txt');
|
|
288
|
-
SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'mydb';
|
|
289
|
-
```
|
|
290
|
-
|
|
291
|
-
### When to Grant Execute Permission
|
|
292
|
-
|
|
293
|
-
**Grant `execute` when:**
|
|
294
|
-
- Users need complex analytical queries with UNION or subqueries
|
|
295
|
-
- Developers need access to INFORMATION_SCHEMA for metadata analysis
|
|
296
|
-
- Advanced SQL functions are required for specific operations
|
|
297
|
-
- You trust the user with broader database access
|
|
298
|
-
|
|
299
|
-
**Don't grant `execute` when:**
|
|
300
|
-
- Users only need basic CRUD operations
|
|
301
|
-
- Working with untrusted AI agents
|
|
302
|
-
- Production environments with strict security policies
|
|
303
|
-
- Read-only access is sufficient
|
|
304
|
-
|
|
305
|
-
### Example: Analytics with Execute Permission
|
|
306
|
-
|
|
307
|
-
```json
|
|
308
|
-
{
|
|
309
|
-
"args": [
|
|
310
|
-
"mysql://analyst:pass@localhost:3306/analytics_db",
|
|
311
|
-
"list,read,execute,utility"
|
|
312
|
-
]
|
|
313
|
-
}
|
|
314
|
-
```
|
|
315
|
-
|
|
316
|
-
This allows the AI agent to run complex analytical queries:
|
|
317
|
-
|
|
318
|
-
```sql
|
|
319
|
-
-- Complex query with UNION and subqueries
|
|
320
|
-
SELECT 'Q1' as quarter, SUM(revenue) as total
|
|
321
|
-
FROM (SELECT * FROM sales WHERE date BETWEEN '2024-01-01' AND '2024-03-31') AS q1_sales
|
|
322
|
-
UNION
|
|
323
|
-
SELECT 'Q2' as quarter, SUM(revenue) as total
|
|
324
|
-
FROM (SELECT * FROM sales WHERE date BETWEEN '2024-04-01' AND '2024-06-30') AS q2_sales;
|
|
325
|
-
```
|
|
326
|
-
|
|
327
|
-
### Critical Security Keywords (Always Blocked)
|
|
328
|
-
|
|
329
|
-
Even with `execute` permission, these operations are **always blocked** for security:
|
|
330
|
-
|
|
331
|
-
- `GRANT` / `REVOKE` - User privilege management
|
|
332
|
-
- `INTO OUTFILE` / `INTO DUMPFILE` - Writing files to server
|
|
333
|
-
- `LOAD DATA` - Loading data from files
|
|
334
|
-
- Direct access to `mysql`, `performance_schema`, `sys` databases
|
|
335
|
-
- `USER` / `PASSWORD` manipulation
|
|
336
|
-
|
|
337
|
-
---
|
|
338
|
-
|
|
339
209
|
## ๐ซ Permission Error Handling
|
|
340
210
|
|
|
341
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.
|
|
@@ -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.
|
|
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",
|