@berthojoris/mcp-mysql-server 1.17.0 β†’ 1.18.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/DOCUMENTATIONS.md CHANGED
@@ -6,73 +6,38 @@ This file contains detailed documentation for all features of the MySQL MCP Serv
6
6
 
7
7
  ## Table of Contents
8
8
 
9
- 1. [Setup & Configuration (Extended)](#setup--configuration-extended) - Agent clients, env vars, local path, multi-DB
10
- 2. [Category Filtering System](#πŸ†•-category-filtering-system) - NEW!
11
- 3. [πŸ”§ Complete Tools Reference](#πŸ”§-complete-tools-reference) - All 150 tools organized by category
12
- 4. [DDL Operations](#πŸ—οΈ-ddl-operations)
13
- 5. [Data Export Tools](#πŸ“€-data-export-tools)
14
- 6. [Data Import Tools](#πŸ“₯-data-import-tools)
15
- 7. [Database Backup & Restore](#πŸ’Ύ-database-backup--restore)
16
- 8. [Data Migration Tools](#πŸ”„-data-migration-tools)
17
- 9. [Schema Versioning & Migrations](#πŸ”„-schema-versioning-and-migrations)
18
- 10. [Transaction Management](#πŸ’°-transaction-management)
19
- 11. [Stored Procedures](#πŸ”§-stored-procedures)
20
- 12. [Views Management](#πŸ‘οΈ-views-management)
21
- 13. [Triggers Management](#⚑-triggers-management)
22
- 14. [Functions Management](#πŸ”’-functions-management)
23
- 15. [Index Management](#πŸ“‡-index-management)
24
- 16. [Constraint Management](#πŸ”—-constraint-management)
25
- 17. [Table Maintenance](#πŸ”§-table-maintenance)
26
- 18. [Process & Server Management](#πŸ“Š-process--server-management)
27
- 19. [Performance Monitoring](#πŸ“ˆ-performance-monitoring)
28
- 20. [AI Enhancement Tools](#πŸ€–-ai-enhancement-tools) - NEW!
29
- 21. [Usage Examples](#πŸ“‹-usage-examples)
30
- 22. [Query Logging & Automatic SQL Display](#πŸ“-query-logging--automatic-sql-display)
9
+ 1. [Setup & Configuration (Extended)](#setup--configuration-extended) - Permissions + Categories
10
+ 2. [πŸ”§ Complete Tools Reference](#πŸ”§-complete-tools-reference) - All 150 tools organized by category
11
+ 3. [DDL Operations](#πŸ—οΈ-ddl-operations)
12
+ 4. [Data Export Tools](#πŸ“€-data-export-tools)
13
+ 5. [Data Import Tools](#πŸ“₯-data-import-tools)
14
+ 6. [Database Backup & Restore](#πŸ’Ύ-database-backup--restore)
15
+ 7. [Data Migration Tools](#πŸ”„-data-migration-tools)
16
+ 8. [Schema Versioning & Migrations](#πŸ”„-schema-versioning-and-migrations)
17
+ 9. [Transaction Management](#πŸ’°-transaction-management)
18
+ 10. [Stored Procedures](#πŸ”§-stored-procedures)
19
+ 11. [Views Management](#πŸ‘οΈ-views-management)
20
+ 12. [Triggers Management](#⚑-triggers-management)
21
+ 13. [Functions Management](#πŸ”’-functions-management)
22
+ 14. [Index Management](#πŸ“‡-index-management)
23
+ 15. [Constraint Management](#πŸ”—-constraint-management)
24
+ 16. [Table Maintenance](#πŸ”§-table-maintenance)
25
+ 17. [Process & Server Management](#πŸ“Š-process--server-management)
26
+ 18. [Performance Monitoring](#πŸ“ˆ-performance-monitoring)
27
+ 19. [AI Enhancement Tools](#πŸ€–-ai-enhancement-tools)
28
+ 20. [Usage Examples](#πŸ“‹-usage-examples)
29
+ 21. [Query Logging & Automatic SQL Display](#πŸ“-query-logging--automatic-sql-display)
31
30
 
32
31
  ---
33
32
 
34
33
  ## Setup & Configuration (Extended)
35
34
 
36
- This section collects **client-specific configuration snippets** and **advanced setup patterns**. For the shortest setup, see [README.md](README.md).
35
+ This server is configured with **two access-control settings**:
37
36
 
38
- ### Agent Configuration Examples
37
+ - **Permissions (Layer 1)**: `MCP_PERMISSIONS` (comma-separated)
38
+ - **Categories (Layer 2)**: `MCP_CATEGORIES` (comma-separated)
39
39
 
40
- Most clients ultimately need the same `command` + `args` shape, but the **config file path** differs.
41
-
42
- | AI Agent | Config File Location |
43
- |----------|---------------------|
44
- | **Claude Code** | `.mcp.json` (project root) or `~/.mcp.json` (global) |
45
- | **Cursor** | `.cursor/mcp.json` |
46
- | **Windsurf** | `~/.codeium/windsurf/mcp_config.json` |
47
- | **Cline** | VS Code settings or Cline config file |
48
- | **Gemini CLI** | `~/.gemini/settings.json` |
49
- | **Kilo Code** | VS Code MCP settings |
50
- | **Roo Code** | VS Code MCP settings |
51
- | **Trae AI** | MCP configuration in settings |
52
- | **Qwen Code** | MCP configuration in settings |
53
- | **Droid CLI** | MCP configuration in settings |
54
-
55
- #### Standard JSON Configuration (Universal)
56
-
57
- **Option 1: Single-Layer (Permissions Only) - Simple Setup**
58
-
59
- ```json
60
- {
61
- "mcpServers": {
62
- "mysql": {
63
- "command": "npx",
64
- "args": [
65
- "-y",
66
- "@berthojoris/mysql-mcp",
67
- "mysql://user:password@localhost:3306/database",
68
- "list,read,utility"
69
- ]
70
- }
71
- }
72
- }
73
- ```
74
-
75
- **Option 2: Dual-Layer (Permissions + Categories) - Recommended for Fine Control**
40
+ ### Recommended: Permissions + Categories (Dual-Layer)
76
41
 
77
42
  ```json
78
43
  {
@@ -91,79 +56,7 @@ Most clients ultimately need the same `command` + `args` shape, but the **config
91
56
  }
92
57
  ```
93
58
 
94
- #### Multiple Database Configuration
95
-
96
- ```json
97
- {
98
- "mcpServers": {
99
- "mysql-prod": {
100
- "command": "npx",
101
- "args": [
102
- "-y",
103
- "@berthojoris/mysql-mcp",
104
- "mysql://reader:pass@prod-server:3306/prod_db",
105
- "list,read,utility"
106
- ]
107
- },
108
- "mysql-dev": {
109
- "command": "npx",
110
- "args": [
111
- "-y",
112
- "@berthojoris/mysql-mcp",
113
- "mysql://root:pass@localhost:3306/dev_db",
114
- "list,read,create,update,delete,execute,ddl,utility"
115
- ]
116
- }
117
- }
118
- }
119
- ```
120
-
121
- ### OpenAI Codex CLI & VS Code Extension
122
-
123
- OpenAI Codex uses TOML format in `~/.codex/config.toml`.
124
-
125
- **Quick setup via CLI:**
126
-
127
- ```bash
128
- codex mcp add mysql -- npx -y @berthojoris/mysql-mcp mysql://user:pass@localhost:3306/db list,read,utility
129
- ```
130
-
131
- **Manual TOML configuration:**
132
-
133
- ```toml
134
- [mcp_servers.mysql]
135
- command = "npx"
136
- args = ["-y", "@berthojoris/mysql-mcp", "mysql://user:pass@localhost:3306/db", "list,read,utility"]
137
- startup_timeout_sec = 20
138
- ```
139
-
140
- ### Zed IDE
141
-
142
- Zed uses `~/.config/zed/settings.json`:
143
-
144
- ```json
145
- {
146
- "context_servers": {
147
- "mysql": {
148
- "command": {
149
- "path": "npx",
150
- "args": [
151
- "-y",
152
- "@berthojoris/mysql-mcp",
153
- "mysql://user:password@localhost:3306/database",
154
- "list,read,utility"
155
- ]
156
- }
157
- }
158
- }
159
- }
160
- ```
161
-
162
- ### Environment Variables Configuration
163
-
164
- Alternative approach using environment variables instead of a connection string.
165
-
166
- **Option 1: Permissions Only (Simple)**
59
+ ### Environment Variables: Permissions + Categories
167
60
 
168
61
  ```json
169
62
  {
@@ -177,93 +70,14 @@ Alternative approach using environment variables instead of a connection string.
177
70
  "DB_USER": "root",
178
71
  "DB_PASSWORD": "your_password",
179
72
  "DB_NAME": "your_database",
180
- "MCP_PERMISSIONS": "list,read,utility"
181
- }
182
- }
183
- }
184
- }
185
- ```
186
-
187
- **Option 2: Permissions + Categories (Recommended)**
188
-
189
- ```json
190
- {
191
- "mcpServers": {
192
- "mysql": {
193
- "command": "npx",
194
- "args": ["-y", "@berthojoris/mysql-mcp"],
195
- "env": {
196
- "DB_HOST": "localhost",
197
- "DB_PORT": "3306",
198
- "DB_USER": "root",
199
- "DB_PASSWORD": "your_password",
200
- "DB_NAME": "your_database",
201
- "MCP_PERMISSIONS": "list,read,utility",
202
- "MCP_CATEGORIES": "database_discovery,performance_monitoring",
203
- "MCP_MASKING_PROFILE": "partial"
204
- }
205
- }
206
- }
207
- }
208
- ```
209
-
210
- **Option 3: Adaptive Preset (Merges with Overrides)**
211
-
212
- ```json
213
- {
214
- "mcpServers": {
215
- "mysql": {
216
- "command": "npx",
217
- "args": ["-y", "@berthojoris/mysql-mcp"],
218
- "env": {
219
- "DB_HOST": "localhost",
220
- "DB_PORT": "3306",
221
- "DB_USER": "root",
222
- "DB_PASSWORD": "your_password",
223
- "DB_NAME": "your_database",
224
- "MCP_PRESET": "readonly",
225
73
  "MCP_PERMISSIONS": "list,read,utility",
226
- "MCP_CATEGORIES": "performance_monitoring"
74
+ "MCP_CATEGORIES": "database_discovery,performance_monitoring"
227
75
  }
228
76
  }
229
77
  }
230
78
  }
231
79
  ```
232
80
 
233
- Presets and profiles (`dev`/`stage`/`prod`) are described in the [Category Filtering System](#πŸ†•-category-filtering-system).
234
-
235
- ### Local Path Configuration
236
-
237
- For development or when you need full control over the source code:
238
-
239
- ```json
240
- {
241
- "mcpServers": {
242
- "mysql": {
243
- "command": "node",
244
- "args": [
245
- "/path/to/mcp_mysql/bin/mcp-mysql.js",
246
- "mysql://user:password@localhost:3306/database",
247
- "list,read,utility"
248
- ]
249
- }
250
- }
251
- }
252
- ```
253
-
254
- When to use local path:
255
-
256
- - You need offline usage (no npm registry access)
257
- - You are developing/debugging the server
258
- - You need to pin to a custom build
259
-
260
- Build requirements:
261
-
262
- ```bash
263
- npm install
264
- npm run build
265
- ```
266
-
267
81
  Control which database operations are available to AI using a **dual-layer filtering system**:
268
82
 
269
83
  - **Layer 1 (Permissions)**: Broad operation-level control using legacy categories (required)
@@ -274,19 +88,9 @@ Control which database operations are available to AI using a **dual-layer filte
274
88
  ### Why Use Dual-Layer Filtering?
275
89
 
276
90
  - **Security**: Multiple layers of protection - broad permissions + specific tool access
277
- - **Flexibility**: Simple permission-only mode OR advanced dual-layer mode
278
- - **Backward Compatible**: Existing single-layer configurations continue to work
279
- - **Granular Control**: 10 permissions Γ— 22 categories = precise access control
91
+ - **Fine control**: broad permissions + specific tool access
280
92
  - **Clear Intent**: Separate "what operations are allowed" from "which specific tools"
281
93
 
282
- ### Filtering Modes
283
-
284
- | Mode | Configuration | Use Case |
285
- |------|--------------|----------|
286
- | **No Filtering** | No args specified | Development, full trust |
287
- | **Single-Layer** | Permissions only (2nd arg) | Simple, broad control |
288
- | **Dual-Layer** | Permissions + Categories (2nd + 3rd args) | Production, precise control |
289
-
290
94
  ### Documentation Categories Reference
291
95
 
292
96
  ```bash
@@ -302,30 +106,7 @@ analysis,ai_enhancement
302
106
 
303
107
  ### Configuration Examples
304
108
 
305
- #### Example 1: Single-Layer (Permissions Only) - Backward Compatible
306
-
307
- Use only the 2nd argument for broad control:
308
-
309
- ```json
310
- {
311
- "mcpServers": {
312
- "mysql": {
313
- "command": "node",
314
- "args": [
315
- "/path/to/bin/mcp-mysql.js",
316
- "mysql://user:pass@localhost:3306/db",
317
- "list,read,utility"
318
- ]
319
- }
320
- }
321
- }
322
- ```
323
-
324
- **Result**: All tools within `list`, `read`, and `utility` permissions are enabled.
325
-
326
- **Enabled tools**: `list_databases`, `list_tables`, `read_records`, `run_query`, `test_connection`, `export_table_to_csv`, etc.
327
-
328
- #### Example 2: Dual-Layer (Permissions + Categories) - Production Read-Only
109
+ #### Example: Dual-Layer (Permissions + Categories)
329
110
 
330
111
  Use both 2nd argument (permissions) and 3rd argument (categories):
331
112
 
@@ -355,98 +136,6 @@ Use both 2nd argument (permissions) and 3rd argument (categories):
355
136
  - `test_connection` - Has `utility` permission but category is `utilities` (not in category list)
356
137
  - `create_record` - No `create` permission (blocked by Layer 1)
357
138
 
358
- #### Example 3: Development Environment - Single-Layer
359
-
360
- Full access using permissions only:
361
-
362
- ```json
363
- {
364
- "mcpServers": {
365
- "mysql-dev": {
366
- "command": "node",
367
- "args": [
368
- "/path/to/bin/mcp-mysql.js",
369
- "mysql://dev:pass@localhost:3306/dev_db",
370
- "list,read,create,update,delete,ddl,transaction,utility"
371
- ]
372
- }
373
- }
374
- }
375
- ```
376
-
377
- **Result**: All tools within specified permissions are enabled (no category filtering).
378
-
379
- #### Example 4: DBA Tasks - Dual-Layer
380
-
381
- Schema management and maintenance only:
382
-
383
- ```json
384
- {
385
- "mcpServers": {
386
- "mysql-dba": {
387
- "command": "node",
388
- "args": [
389
- "/path/to/bin/mcp-mysql.js",
390
- "mysql://dba:pass@server:3306/app_db",
391
- "list,ddl,utility",
392
- "database_discovery,schema_management,table_maintenance,backup_restore,index_management"
393
- ]
394
- }
395
- }
396
- }
397
- ```
398
-
399
- **Enabled**: Schema changes, backups, maintenance - NO data modification.
400
-
401
- #### Example 5: Application Backend - Dual-Layer
402
-
403
- Data operations without schema changes:
404
-
405
- ```json
406
- {
407
- "mcpServers": {
408
- "mysql-app": {
409
- "command": "node",
410
- "args": [
411
- "/path/to/bin/mcp-mysql.js",
412
- "mysql://app:pass@localhost:3306/app_db",
413
- "list,read,create,update,delete,transaction,utility",
414
- "crud_operations,bulk_operations,transaction_management,cache_management"
415
- ]
416
- }
417
- }
418
- }
419
- ```
420
-
421
- **Enabled**: Full data CRUD + bulk ops + transactions - NO schema changes (no `ddl` permission).
422
-
423
- ### Adaptive Permission Presets (ReadOnly/Analyst/DBA Lite)
424
-
425
- Preset bundles provide safe starting points and **merge** with any explicit permissions/categories you pass (CLI args or env vars).
426
-
427
- | Preset | Permissions | Categories | Intended Use |
428
- |--------|-------------|------------|--------------|
429
- | `readonly` | `list,read,utility` | `database_discovery,crud_operations,custom_queries,utilities,import_export,performance_monitoring,analysis` | Safe read-only access, exports, and diagnostics |
430
- | `analyst` | `list,read,utility` | `database_discovery,crud_operations,custom_queries,utilities,import_export,performance_monitoring,analysis,query_optimization,cache_management,server_management` | Exploration with EXPLAIN, cache, and performance visibility |
431
- | `dba-lite` | `list,read,utility,ddl,transaction,procedure` | `database_discovery,custom_queries,utilities,server_management,schema_management,table_maintenance,index_management,constraint_management,backup_restore,schema_migrations,performance_monitoring,views_management,triggers_management,functions_management,stored_procedures` | Admin-lite schema care, maintenance, and migrations |
432
- | `dev` | ALL | ALL | Full access to all tools (Development environment) |
433
- | `stage` | `list,read,create,update,delete,utility,transaction` | Most categories (except schema_management) | Data modification allowed, but destructive DDL (drop_table, truncate_table) is **explicitly denied** |
434
- | `prod` | `list,read,utility` | `database_discovery,crud_operations,custom_queries,utilities,performance_monitoring,analysis` | Strict read-only. Data modification and DDL are **strictly denied** (even if permissions suggest otherwise) |
435
-
436
- ### Connection Profiles (Allow/Deny Lists)
437
-
438
- The new mechanism introduces "Connection Profiles" which can enforce strict `allow` and `deny` lists for tools, providing security beyond standard permissions.
439
-
440
- - **Explicit Deny**: Tools in the `deniedTools` list are blocked *regardless* of their permissions. E.g., `prod` profile denies `create_record` even if `create` permission is somehow granted.
441
- - **Explicit Allow**: Tools in the `allowedTools` list are enabled even if their category is not listed (unless denied).
442
-
443
- **Usage**
444
-
445
- - CLI: `mcp-mysql mysql://user:pass@host:3306/db --preset readonly`
446
- - CLI with overrides: `mcp-mysql mysql://... --preset analyst "list,read,utility" "performance_monitoring"`
447
- - Env: `MCP_PRESET=analyst` (or `MCP_PERMISSION_PRESET=analyst`) and optionally extend with `MCP_PERMISSIONS` / `MCP_CATEGORIES`
448
-
449
- If a preset name is not recognized and no overrides are provided, the server falls back to a safe read-only baseline instead of enabling everything.
450
139
 
451
140
  ### Permissions Reference (Layer 1)
452
141
 
@@ -476,9 +165,7 @@ The system uses both arguments to determine access:
476
165
  - **3rd argument**: Categories (Layer 2, optional) - comma-separated documentation categories
477
166
 
478
167
  **Decision logic**:
479
- 1. If no arguments: All 150 tools enabled
480
- 2. If only 2nd argument (permissions): Tools enabled if they match permission
481
- 3. If both arguments: Tools enabled if they match BOTH permission AND category
168
+ 1. If both permissions + categories are provided: tools must match **BOTH** layers
482
169
 
483
170
  **Example**:
484
171
  ```bash
@@ -486,15 +173,6 @@ The system uses both arguments to determine access:
486
173
  # Permission required: create
487
174
  # Category required: bulk_operations
488
175
 
489
- # Single-layer (permissions only)
490
- args: ["mysql://...", "list,create,read"]
491
- Result: βœ… Enabled (has 'create' permission)
492
-
493
- # Dual-layer (permissions + categories)
494
- args: ["mysql://...", "list,create,read", "database_discovery,crud_operations"]
495
- Result: βœ— Disabled (has 'create' but category is 'bulk_operations', not in list)
496
-
497
- # Dual-layer with correct category
498
176
  args: ["mysql://...", "list,create,read", "bulk_operations,crud_operations"]
499
177
  Result: βœ… Enabled (has both 'create' permission AND 'bulk_operations' category)
500
178
  ```
@@ -1006,7 +684,7 @@ Workflow Macros are composite tools designed to execute complex, multi-step oper
1006
684
 
1007
685
  ### safe_export_table
1008
686
 
1009
- Exports table data to CSV format *with enforced data masking*. This is safer than standard export tools because it ensures sensitive data is masked before leaving the database layer, regardless of the global masking configuration.
687
+ Exports table data to CSV format *with enforced data masking*. This is safer than standard export tools because it ensures sensitive data is masked before leaving the database layer.
1010
688
 
1011
689
  **Parameters:**
1012
690
  - `table_name` (required): Name of the table to export.
@@ -1577,13 +1255,20 @@ The MySQL MCP Server provides comprehensive schema versioning and migration tool
1577
1255
  Schema versioning operations require `ddl` permission:
1578
1256
 
1579
1257
  ```json
1580
- "args": [
1581
- "--mysql-host", "localhost",
1582
- "--mysql-user", "root",
1583
- "--mysql-password", "password",
1584
- "--mysql-database", "mydb",
1585
- "--permissions", "list,read,create,update,delete,ddl"
1586
- ]
1258
+ {
1259
+ "mcpServers": {
1260
+ "mysql": {
1261
+ "command": "npx",
1262
+ "args": [
1263
+ "-y",
1264
+ "@berthojoris/mysql-mcp",
1265
+ "mysql://user:password@localhost:3306/mydb",
1266
+ "list,ddl,utility",
1267
+ "schema_migrations"
1268
+ ]
1269
+ }
1270
+ }
1271
+ }
1587
1272
  ```
1588
1273
 
1589
1274
  ### Initialize Migrations Table
@@ -4444,316 +4129,6 @@ Each bulk operation returns performance metrics:
4444
4129
 
4445
4130
  ---
4446
4131
 
4447
- ## 🎭 Data Masking
4448
-
4449
- The MySQL MCP server includes a robust data masking layer to protect sensitive information (PII, credentials) in query results. This is useful when sharing database access with AI agents or third parties.
4450
-
4451
- ### Features
4452
-
4453
- - **Profile-Based Masking**: Easy configuration profiles (`none`, `soft`, `partial`, `strict`)
4454
- - **Automatic Detection**: Automatically identifies sensitive columns by name (e.g., `email`, `password`, `ssn`)
4455
- - **Multiple Strategies**:
4456
- - **REDACT**: Replaces value with `[REDACTED]`
4457
- - **PARTIAL**: Partially masks email (`j***@d.com`) and phone/CC (`***1234`)
4458
- - **HASH**: (Internal placeholder)
4459
-
4460
- ### Configuration
4461
-
4462
- Configure the masking profile via the `MCP_MASKING_PROFILE` environment variable:
4463
-
4464
- ```bash
4465
- MCP_MASKING_PROFILE=partial
4466
- ```
4467
-
4468
- ### Profiles Reference
4469
-
4470
- | Profile | Description | Credentials (password, key) | PII (email, phone, ssn) |
4471
- |---------|-------------|-----------------------------|-------------------------|
4472
- | `none` | No masking (default) | Show | Show |
4473
- | `soft` | Protect secrets only | **REDACT** | Show |
4474
- | `partial` | Balanced security | **REDACT** | **PARTIAL** (j***@...) |
4475
- | `strict` | Maximum security | **REDACT** | **REDACT** |
4476
-
4477
- ### Behavior
4478
-
4479
- - Masking applies automatically to `run_query` and `read_records` results.
4480
- - It filters output **after** the query is run, so WHERE clauses still work on the real data (e.g., you can search by email, but the result will be masked).
4481
-
4482
- ---
4483
-
4484
-
4485
- ---
4486
-
4487
- ## ⚑ Workflow Macros
4488
-
4489
- Workflow macros are high-level tools that combine multiple operations into a single, safe, and efficient workflow. They are designed to simplify complex tasks and ensure best practices (like data masking) are automatically applied.
4490
-
4491
- ### Safe Export Table
4492
-
4493
- The `safe_export_table` tool allows you to export table data to CSV while strictly enforcing data masking rules. This ensures that sensitive information (PII) is never leaked during exports, even if the agent forgets to apply masking manually.
4494
-
4495
- #### Features
4496
-
4497
- - **Forced Masking**: Applies a masking profile (default: `strict`) to all exported data.
4498
- - **Hard Limit**: Enforces a maximum row limit (10,000) to prevent Out-Of-Memory errors during large exports.
4499
- - **CSV Formatting**: Automatically handles special characters, quotes, and newlines.
4500
- - **Header Control**: Option to include or exclude CSV headers.
4501
-
4502
- #### Usage
4503
-
4504
- ```json
4505
- {
4506
- "tool": "safe_export_table",
4507
- "arguments": {
4508
- "table_name": "users",
4509
- "masking_profile": "partial",
4510
- "limit": 1000
4511
- }
4512
- }
4513
- ```
4514
-
4515
- #### Parameters
4516
-
4517
- | Parameter | Type | Required | Description | Default |
4518
- |-----------|------|----------|-------------|---------|
4519
- | `table_name` | string | Yes | Name of the table to export | - |
4520
- | `masking_profile` | string | No | Masking profile to apply (`strict`, `partial`, `soft`) | `strict` |
4521
- | `limit` | number | No | Number of rows to export (max 10,000) | 1000 |
4522
- | `include_headers` | boolean | No | Whether to include CSV headers | `true` |
4523
-
4524
- #### Response
4525
-
4526
- ```json
4527
- {
4528
- "status": "success",
4529
- "data": {
4530
- "csv": "id,name,email\n1,John Doe,j***@example.com...",
4531
- "row_count": 50,
4532
- "applied_profile": "partial"
4533
- }
4534
- }
4535
- ```
4536
-
4537
- ---
4538
-
4539
- ## πŸ€– OpenAI Codex Integration
4540
-
4541
- OpenAI Codex CLI and VS Code Extension support MCP servers through a shared TOML configuration file. This section provides detailed setup instructions for integrating the MySQL MCP Server with Codex.
4542
-
4543
- ### Configuration Overview
4544
-
4545
- | Feature | Details |
4546
- |---------|---------|
4547
- | **Config File** | `~/.codex/config.toml` |
4548
- | **Shared Config** | CLI and VS Code extension use the same file |
4549
- | **Transport** | STDIO (standard input/output) |
4550
- | **Format** | TOML |
4551
-
4552
- ### Quick Setup via CLI
4553
-
4554
- The fastest way to add MySQL MCP to Codex:
4555
-
4556
- ```bash
4557
- # Basic setup with connection string
4558
- codex mcp add mysql -- npx -y @berthojoris/mcp-mysql-server mysql://user:password@localhost:3306/database list,read,utility
4559
-
4560
- # With environment variables
4561
- codex mcp add mysql --env DB_HOST=localhost --env DB_PORT=3306 --env DB_USER=root --env DB_PASSWORD=secret --env DB_NAME=mydb --env MCP_PERMISSIONS=list,read,utility -- npx -y @berthojoris/mcp-mysql-server
4562
- ```
4563
-
4564
- ### Manual TOML Configuration
4565
-
4566
- Edit `~/.codex/config.toml` directly for more control:
4567
-
4568
- #### Basic Configuration
4569
-
4570
- ```toml
4571
- [mcp_servers.mysql]
4572
- command = "npx"
4573
- args = ["-y", "@berthojoris/mcp-mysql-server", "mysql://user:password@localhost:3306/database", "list,read,utility"]
4574
- ```
4575
-
4576
- #### With Environment Variables
4577
-
4578
- ```toml
4579
- [mcp_servers.mysql]
4580
- command = "npx"
4581
- args = ["-y", "@berthojoris/mcp-mysql-server"]
4582
-
4583
- [mcp_servers.mysql.env]
4584
- DB_HOST = "localhost"
4585
- DB_PORT = "3306"
4586
- DB_USER = "root"
4587
- DB_PASSWORD = "your_password"
4588
- DB_NAME = "your_database"
4589
- MCP_PERMISSIONS = "list,read,utility"
4590
- ```
4591
-
4592
- #### Local Path Configuration (Development)
4593
-
4594
- ```toml
4595
- [mcp_servers.mysql]
4596
- command = "node"
4597
- args = ["C:\\DEKSTOP\\MCP\\mcp_mysql\\bin\\mcp-mysql.js", "mysql://user:pass@localhost:3306/database", "list,read,utility"]
4598
- cwd = "C:\\DEKSTOP\\MCP\\mcp_mysql"
4599
- ```
4600
-
4601
- ### Configuration Options Reference
4602
-
4603
- | Option | Type | Default | Description |
4604
- |--------|------|---------|-------------|
4605
- | `command` | String | Required | The executable to launch the server |
4606
- | `args` | Array | `[]` | Command-line arguments passed to the server |
4607
- | `env` | Table | `{}` | Environment variables for the server process |
4608
- | `env_vars` | Array | `[]` | Additional env vars to whitelist/forward |
4609
- | `cwd` | String | - | Working directory to launch the server from |
4610
- | `startup_timeout_sec` | Number | `10` | Server startup timeout in seconds |
4611
- | `tool_timeout_sec` | Number | `60` | Per-tool execution timeout in seconds |
4612
- | `enabled` | Boolean | `true` | Set to `false` to disable without deleting |
4613
- | `enabled_tools` | Array | - | Allow-list of tools to expose from server |
4614
- | `disabled_tools` | Array | - | Deny-list of tools to hide |
4615
-
4616
- ### Advanced Configurations
4617
-
4618
- #### Production (Read-Only) + Development (Full Access)
4619
-
4620
- ```toml
4621
- # Production database - Read Only
4622
- [mcp_servers.mysql-prod]
4623
- command = "npx"
4624
- args = ["-y", "@berthojoris/mcp-mysql-server", "mysql://reader:pass@prod-server:3306/prod_db", "list,read,utility"]
4625
- startup_timeout_sec = 30
4626
- tool_timeout_sec = 120
4627
-
4628
- # Development database - Full Access
4629
- [mcp_servers.mysql-dev]
4630
- command = "npx"
4631
- args = ["-y", "@berthojoris/mcp-mysql-server", "mysql://root:pass@localhost:3306/dev_db", "list,read,create,update,delete,execute,ddl,transaction,utility"]
4632
- ```
4633
-
4634
- #### With Tool Filtering (Limit Exposed Tools)
4635
-
4636
- ```toml
4637
- [mcp_servers.mysql]
4638
- command = "npx"
4639
- args = ["-y", "@berthojoris/mcp-mysql-server", "mysql://user:pass@localhost:3306/db", "list,read,utility"]
4640
-
4641
- # Only expose specific tools
4642
- enabled_tools = [
4643
- "list_tables",
4644
- "read_table_schema",
4645
- "read_records",
4646
- "run_query",
4647
- "test_connection"
4648
- ]
4649
-
4650
- # Or hide specific dangerous tools
4651
- # disabled_tools = ["drop_table", "delete_record", "execute_sql"]
4652
- ```
4653
-
4654
- #### With Custom Timeouts for Large Operations
4655
-
4656
- ```toml
4657
- [mcp_servers.mysql]
4658
- command = "npx"
4659
- args = ["-y", "@berthojoris/mcp-mysql-server", "mysql://user:pass@localhost:3306/db", "list,read,create,update,delete,utility"]
4660
- startup_timeout_sec = 30 # Allow more time for startup
4661
- tool_timeout_sec = 300 # 5 minutes for large bulk operations
4662
- ```
4663
-
4664
- ### Codex MCP Management Commands
4665
-
4666
- ```bash
4667
- # List all configured MCP servers
4668
- codex mcp list
4669
-
4670
- # List with JSON output (for scripting)
4671
- codex mcp list --json
4672
-
4673
- # Get details about a specific server
4674
- codex mcp get mysql
4675
-
4676
- # Remove an MCP server
4677
- codex mcp remove mysql
4678
-
4679
- # Add server with multiple env vars
4680
- codex mcp add mysql --env DB_HOST=localhost --env DB_USER=root -- npx -y @berthojoris/mcp-mysql-server
4681
- ```
4682
-
4683
- ### VS Code Extension Setup
4684
-
4685
- 1. Install the Codex VS Code Extension
4686
- 2. Open the extension settings (gear icon in top right)
4687
- 3. Click "MCP settings" > "Open config.toml"
4688
- 4. Add your MySQL MCP configuration
4689
- 5. Save the file - changes apply immediately
4690
-
4691
- ### Verifying the Setup
4692
-
4693
- After configuration, test your setup:
4694
-
4695
- ```bash
4696
- # In Codex CLI
4697
- codex mcp list
4698
-
4699
- # You should see:
4700
- # mysql: npx -y @berthojoris/mcp-mysql-server ...
4701
- ```
4702
-
4703
- Then ask Codex:
4704
- - "What databases are available?"
4705
- - "List all tables in my database"
4706
- - "Show me the structure of the users table"
4707
-
4708
- ### Troubleshooting Codex Integration
4709
-
4710
- #### Server Not Starting
4711
-
4712
- 1. **Check TOML syntax** - A single syntax error breaks both CLI and VS Code extension
4713
- 2. **Verify paths** - Use absolute paths for local installations
4714
- 3. **Check startup timeout** - Increase `startup_timeout_sec` if server takes time to initialize
4715
-
4716
- #### Tools Not Appearing
4717
-
4718
- 1. Verify server configuration with `codex mcp list --json`
4719
- 2. Check that `enabled = true` (or not set, defaults to true)
4720
- 3. Ensure `enabled_tools` doesn't accidentally filter out needed tools
4721
-
4722
- #### Connection Errors
4723
-
4724
- 1. Test MySQL connection manually: `mysql -u user -p -h host database`
4725
- 2. Verify credentials in connection string
4726
- 3. Check network connectivity to MySQL server
4727
-
4728
- #### Common TOML Syntax Errors
4729
-
4730
- ```toml
4731
- # WRONG - missing quotes around string values
4732
- args = [-y, @berthojoris/mcp-mysql-server]
4733
-
4734
- # CORRECT
4735
- args = ["-y", "@berthojoris/mcp-mysql-server"]
4736
-
4737
- # WRONG - using JSON syntax
4738
- "mcp_servers": { "mysql": { ... } }
4739
-
4740
- # CORRECT - TOML table syntax
4741
- [mcp_servers.mysql]
4742
- command = "npx"
4743
- ```
4744
-
4745
- ### Permission Sets for Common Use Cases
4746
-
4747
- | Use Case | Permissions |
4748
- |----------|-------------|
4749
- | Read-Only Analysis | `list,read,utility` |
4750
- | Data Entry | `list,read,create,utility` |
4751
- | Full Data Access | `list,read,create,update,delete,utility` |
4752
- | With Transactions | `list,read,create,update,delete,transaction,utility` |
4753
- | Development (Full) | `list,read,create,update,delete,execute,ddl,transaction,procedure,utility` |
4754
-
4755
- ---
4756
-
4757
4132
  ## πŸ› οΈ Troubleshooting
4758
4133
 
4759
4134
  ### MCP Server Not Connecting
@@ -4845,89 +4220,3 @@ This error occurred in earlier versions (< 1.4.1) when AI agents called MCP tool
4845
4220
  ## πŸ“„ License
4846
4221
 
4847
4222
  MIT License - see [LICENSE](LICENSE) file for details.
4848
-
4849
- ---
4850
-
4851
- ## πŸ—ΊοΈ Roadmap
4852
-
4853
- ### Core Features
4854
- - βœ… **Transaction support (BEGIN, COMMIT, ROLLBACK)** - **COMPLETED!**
4855
- - βœ… **Stored procedure execution** - **COMPLETED!**
4856
- - βœ… **Bulk operations (batch insert/update/delete)** - **COMPLETED!**
4857
- - βœ… **Add query log on output** - **COMPLETED!**
4858
- - βœ… **Query result caching** - **COMPLETED!**
4859
- - βœ… **Advanced query optimization hints** - **COMPLETED!**
4860
-
4861
- ### Essential Database Objects (v1.6.0)
4862
- - βœ… **Views Management** - Create, alter, drop, and query database views - **COMPLETED!**
4863
- - βœ… **Triggers Management** - Full trigger lifecycle management - **COMPLETED!**
4864
- - βœ… **Functions Management** - Stored function creation and execution - **COMPLETED!**
4865
-
4866
- ### Administration Features (v1.6.0)
4867
- - βœ… **Index Management** - Create, drop, and analyze indexes - **COMPLETED!**
4868
- - βœ… **Foreign Keys & Constraints** - Constraint management with referential integrity - **COMPLETED!**
4869
- - βœ… **Table Maintenance** - Analyze, optimize, check, repair tables - **COMPLETED!**
4870
- - βœ… **Process Management** - Server processes, status, and query analysis - **COMPLETED!**
4871
-
4872
- ### Enterprise Features
4873
- - βœ… **Database backup and restore tools** - **COMPLETED!**
4874
- - βœ… **Data export/import utilities** (CSV, JSON, SQL dumps) - **COMPLETED!**
4875
- - βœ… **Data migration utilities** - **COMPLETED!**
4876
- - βœ… **Schema versioning and migrations** - **COMPLETED!**
4877
-
4878
- ### Recommended Implementation Order
4879
-
4880
- #### **Phase 1: Performance & Monitoring** πŸš€
4881
- - βœ… **Query result caching** - Dramatically improve response times for repeated queries - **COMPLETED!**
4882
- - βœ… **Performance metrics** - Track query execution times and database performance - **COMPLETED!**
4883
- - βœ… **Connection pool monitoring** - Monitor database connection health and usage - **COMPLETED!**
4884
- - βœ… **Database health checks** - Comprehensive system health monitoring - **COMPLETED!**
4885
-
4886
- #### **Phase 2: Data Management** πŸ“Š
4887
- - βœ… **Database backup and restore tools** - Essential for production data safety - **COMPLETED!**
4888
- - βœ… **Data migration utilities** - Move data between databases and environments - **COMPLETED!**
4889
- - βœ… **Enhanced export/import** - Support for JSON, SQL dump formats - **COMPLETED!**
4890
-
4891
- #### **Phase 3: Enterprise Features** 🏒
4892
- - βœ… **Schema versioning and migrations** - Version control for database schema changes - **COMPLETED!**
4893
- - βœ… **Query optimization** - Automatic query analysis and optimization suggestions - **COMPLETED!**
4894
-
4895
- #### **Implementation Priority Matrix**
4896
-
4897
- | Feature | Impact | Effort | Priority | Status |
4898
- |---------|--------|--------|----------|--------|
4899
- | Query Result Caching | High | Medium | 1 | βœ… COMPLETED |
4900
- | Views Management | High | Medium | 2 | βœ… COMPLETED |
4901
- | Triggers Management | High | Medium | 3 | βœ… COMPLETED |
4902
- | Functions Management | High | Medium | 4 | βœ… COMPLETED |
4903
- | Index Management | High | Medium | 5 | βœ… COMPLETED |
4904
- | Foreign Keys & Constraints | High | Medium | 6 | βœ… COMPLETED |
4905
- | Table Maintenance | High | Low | 7 | βœ… COMPLETED |
4906
- | Process Management | High | Medium | 8 | βœ… COMPLETED |
4907
- | Query Optimization | Medium | Medium | 9 | βœ… COMPLETED |
4908
- | Database Backup/Restore | High | High | 10 | βœ… COMPLETED |
4909
- | Data Export/Import (JSON, SQL) | High | Medium | 11 | βœ… COMPLETED |
4910
- | Data Migration | High | High | 12 | βœ… COMPLETED |
4911
- | Schema Versioning | Medium | Medium | 13 | βœ… COMPLETED |
4912
- | Performance Monitoring | High | Medium | 14 | βœ… COMPLETED |
4913
-
4914
- #### **Proposed Enhancements (AI Productivity)**
4915
-
4916
- | Feature | Impact | Effort | Priority | Status |
4917
- |---------|--------|--------|----------|--------|
4918
- | Adaptive Permission Presets (ReadOnly/Analyst/DBA Lite) | High | Medium | 1 | βœ… Completed |
4919
- | Schema-Aware RAG Context Pack | High | Medium | 2 | βœ… Completed |
4920
- | Guided Query Builder/Fixer (Intent β†’ Safe SQL + EXPLAIN Repair) | High | Medium | 3 | βœ… Completed |
4921
- | Drift & Migration Assistant (Schema diff + risk summary) | High | High | 4 | βœ… Completed |
4922
- | Safety Sandbox Mode (runQuery dry-run/EXPLAIN-only) | Medium | Low | 5 | βœ… Completed |
4923
- | Anomaly & Slow-Query Watcher | Medium | Medium | 6 | βœ… Completed |
4924
- | Data Masking Profiles for Responses | Medium | Medium | 7 | βœ… Completed |
4925
- | Workflow Macros (e.g., safe_export_table) | Medium | Low | 8 | βœ… Completed |
4926
- | Agent-Facing Changelog Feed | Medium | Low | 9 | βœ… Completed |
4927
- | Connection Profiles (dev/stage/prod with allow/deny) | High | Low | 10 | βœ… Completed |
4928
-
4929
- ---
4930
-
4931
- **Made with ❀️ for the AI community**
4932
-
4933
- *Help AI agents interact with MySQL databases safely and efficiently!*