@berthojoris/mcp-mysql-server 1.16.4 β†’ 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,8 +6,8 @@ This file contains detailed documentation for all features of the MySQL MCP Serv
6
6
 
7
7
  ## Table of Contents
8
8
 
9
- 1. [Category Filtering System](#πŸ†•-category-filtering-system) - NEW!
10
- 2. [πŸ”§ Complete Tools Reference](#πŸ”§-complete-tools-reference) - All 145 tools organized by category
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
11
  3. [DDL Operations](#πŸ—οΈ-ddl-operations)
12
12
  4. [Data Export Tools](#πŸ“€-data-export-tools)
13
13
  5. [Data Import Tools](#πŸ“₯-data-import-tools)
@@ -24,10 +24,60 @@ This file contains detailed documentation for all features of the MySQL MCP Serv
24
24
  16. [Table Maintenance](#πŸ”§-table-maintenance)
25
25
  17. [Process & Server Management](#πŸ“Š-process--server-management)
26
26
  18. [Performance Monitoring](#πŸ“ˆ-performance-monitoring)
27
- 19. [AI Enhancement Tools](#πŸ€–-ai-enhancement-tools) - NEW!
27
+ 19. [AI Enhancement Tools](#πŸ€–-ai-enhancement-tools)
28
28
  20. [Usage Examples](#πŸ“‹-usage-examples)
29
29
  21. [Query Logging & Automatic SQL Display](#πŸ“-query-logging--automatic-sql-display)
30
30
 
31
+ ---
32
+
33
+ ## Setup & Configuration (Extended)
34
+
35
+ This server is configured with **two access-control settings**:
36
+
37
+ - **Permissions (Layer 1)**: `MCP_PERMISSIONS` (comma-separated)
38
+ - **Categories (Layer 2)**: `MCP_CATEGORIES` (comma-separated)
39
+
40
+ ### Recommended: Permissions + Categories (Dual-Layer)
41
+
42
+ ```json
43
+ {
44
+ "mcpServers": {
45
+ "mysql": {
46
+ "command": "npx",
47
+ "args": [
48
+ "-y",
49
+ "@berthojoris/mysql-mcp",
50
+ "mysql://user:password@localhost:3306/database",
51
+ "list,read,utility",
52
+ "database_discovery,performance_monitoring"
53
+ ]
54
+ }
55
+ }
56
+ }
57
+ ```
58
+
59
+ ### Environment Variables: Permissions + Categories
60
+
61
+ ```json
62
+ {
63
+ "mcpServers": {
64
+ "mysql": {
65
+ "command": "npx",
66
+ "args": ["-y", "@berthojoris/mysql-mcp"],
67
+ "env": {
68
+ "DB_HOST": "localhost",
69
+ "DB_PORT": "3306",
70
+ "DB_USER": "root",
71
+ "DB_PASSWORD": "your_password",
72
+ "DB_NAME": "your_database",
73
+ "MCP_PERMISSIONS": "list,read,utility",
74
+ "MCP_CATEGORIES": "database_discovery,performance_monitoring"
75
+ }
76
+ }
77
+ }
78
+ }
79
+ ```
80
+
31
81
  Control which database operations are available to AI using a **dual-layer filtering system**:
32
82
 
33
83
  - **Layer 1 (Permissions)**: Broad operation-level control using legacy categories (required)
@@ -38,19 +88,9 @@ Control which database operations are available to AI using a **dual-layer filte
38
88
  ### Why Use Dual-Layer Filtering?
39
89
 
40
90
  - **Security**: Multiple layers of protection - broad permissions + specific tool access
41
- - **Flexibility**: Simple permission-only mode OR advanced dual-layer mode
42
- - **Backward Compatible**: Existing single-layer configurations continue to work
43
- - **Granular Control**: 10 permissions Γ— 22 categories = precise access control
91
+ - **Fine control**: broad permissions + specific tool access
44
92
  - **Clear Intent**: Separate "what operations are allowed" from "which specific tools"
45
93
 
46
- ### Filtering Modes
47
-
48
- | Mode | Configuration | Use Case |
49
- |------|--------------|----------|
50
- | **No Filtering** | No args specified | Development, full trust |
51
- | **Single-Layer** | Permissions only (2nd arg) | Simple, broad control |
52
- | **Dual-Layer** | Permissions + Categories (2nd + 3rd args) | Production, precise control |
53
-
54
94
  ### Documentation Categories Reference
55
95
 
56
96
  ```bash
@@ -66,30 +106,7 @@ analysis,ai_enhancement
66
106
 
67
107
  ### Configuration Examples
68
108
 
69
- #### Example 1: Single-Layer (Permissions Only) - Backward Compatible
70
-
71
- Use only the 2nd argument for broad control:
72
-
73
- ```json
74
- {
75
- "mcpServers": {
76
- "mysql": {
77
- "command": "node",
78
- "args": [
79
- "/path/to/bin/mcp-mysql.js",
80
- "mysql://user:pass@localhost:3306/db",
81
- "list,read,utility"
82
- ]
83
- }
84
- }
85
- }
86
- ```
87
-
88
- **Result**: All tools within `list`, `read`, and `utility` permissions are enabled.
89
-
90
- **Enabled tools**: `list_databases`, `list_tables`, `read_records`, `run_query`, `test_connection`, `export_table_to_csv`, etc.
91
-
92
- #### Example 2: Dual-Layer (Permissions + Categories) - Production Read-Only
109
+ #### Example: Dual-Layer (Permissions + Categories)
93
110
 
94
111
  Use both 2nd argument (permissions) and 3rd argument (categories):
95
112
 
@@ -119,98 +136,6 @@ Use both 2nd argument (permissions) and 3rd argument (categories):
119
136
  - `test_connection` - Has `utility` permission but category is `utilities` (not in category list)
120
137
  - `create_record` - No `create` permission (blocked by Layer 1)
121
138
 
122
- #### Example 3: Development Environment - Single-Layer
123
-
124
- Full access using permissions only:
125
-
126
- ```json
127
- {
128
- "mcpServers": {
129
- "mysql-dev": {
130
- "command": "node",
131
- "args": [
132
- "/path/to/bin/mcp-mysql.js",
133
- "mysql://dev:pass@localhost:3306/dev_db",
134
- "list,read,create,update,delete,ddl,transaction,utility"
135
- ]
136
- }
137
- }
138
- }
139
- ```
140
-
141
- **Result**: All tools within specified permissions are enabled (no category filtering).
142
-
143
- #### Example 4: DBA Tasks - Dual-Layer
144
-
145
- Schema management and maintenance only:
146
-
147
- ```json
148
- {
149
- "mcpServers": {
150
- "mysql-dba": {
151
- "command": "node",
152
- "args": [
153
- "/path/to/bin/mcp-mysql.js",
154
- "mysql://dba:pass@server:3306/app_db",
155
- "list,ddl,utility",
156
- "database_discovery,schema_management,table_maintenance,backup_restore,index_management"
157
- ]
158
- }
159
- }
160
- }
161
- ```
162
-
163
- **Enabled**: Schema changes, backups, maintenance - NO data modification.
164
-
165
- #### Example 5: Application Backend - Dual-Layer
166
-
167
- Data operations without schema changes:
168
-
169
- ```json
170
- {
171
- "mcpServers": {
172
- "mysql-app": {
173
- "command": "node",
174
- "args": [
175
- "/path/to/bin/mcp-mysql.js",
176
- "mysql://app:pass@localhost:3306/app_db",
177
- "list,read,create,update,delete,transaction,utility",
178
- "crud_operations,bulk_operations,transaction_management,cache_management"
179
- ]
180
- }
181
- }
182
- }
183
- ```
184
-
185
- **Enabled**: Full data CRUD + bulk ops + transactions - NO schema changes (no `ddl` permission).
186
-
187
- ### Adaptive Permission Presets (ReadOnly/Analyst/DBA Lite)
188
-
189
- Preset bundles provide safe starting points and **merge** with any explicit permissions/categories you pass (CLI args or env vars).
190
-
191
- | Preset | Permissions | Categories | Intended Use |
192
- |--------|-------------|------------|--------------|
193
- | `readonly` | `list,read,utility` | `database_discovery,crud_operations,custom_queries,utilities,import_export,performance_monitoring,analysis` | Safe read-only access, exports, and diagnostics |
194
- | `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 |
195
- | `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 |
196
- | `dev` | ALL | ALL | Full access to all tools (Development environment) |
197
- | `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** |
198
- | `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) |
199
-
200
- ### Connection Profiles (Allow/Deny Lists)
201
-
202
- The new mechanism introduces "Connection Profiles" which can enforce strict `allow` and `deny` lists for tools, providing security beyond standard permissions.
203
-
204
- - **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.
205
- - **Explicit Allow**: Tools in the `allowedTools` list are enabled even if their category is not listed (unless denied).
206
-
207
- **Usage**
208
-
209
- - CLI: `mcp-mysql mysql://user:pass@host:3306/db --preset readonly`
210
- - CLI with overrides: `mcp-mysql mysql://... --preset analyst "list,read,utility" "performance_monitoring"`
211
- - Env: `MCP_PRESET=analyst` (or `MCP_PERMISSION_PRESET=analyst`) and optionally extend with `MCP_PERMISSIONS` / `MCP_CATEGORIES`
212
-
213
- 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.
214
139
 
215
140
  ### Permissions Reference (Layer 1)
216
141
 
@@ -240,9 +165,7 @@ The system uses both arguments to determine access:
240
165
  - **3rd argument**: Categories (Layer 2, optional) - comma-separated documentation categories
241
166
 
242
167
  **Decision logic**:
243
- 1. If no arguments: All 145 tools enabled
244
- 2. If only 2nd argument (permissions): Tools enabled if they match permission
245
- 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
246
169
 
247
170
  **Example**:
248
171
  ```bash
@@ -250,15 +173,6 @@ The system uses both arguments to determine access:
250
173
  # Permission required: create
251
174
  # Category required: bulk_operations
252
175
 
253
- # Single-layer (permissions only)
254
- args: ["mysql://...", "list,create,read"]
255
- Result: βœ… Enabled (has 'create' permission)
256
-
257
- # Dual-layer (permissions + categories)
258
- args: ["mysql://...", "list,create,read", "database_discovery,crud_operations"]
259
- Result: βœ— Disabled (has 'create' but category is 'bulk_operations', not in list)
260
-
261
- # Dual-layer with correct category
262
176
  args: ["mysql://...", "list,create,read", "bulk_operations,crud_operations"]
263
177
  Result: βœ… Enabled (has both 'create' permission AND 'bulk_operations' category)
264
178
  ```
@@ -285,7 +199,7 @@ Add 'bulk_operations' to the categories argument.
285
199
 
286
200
  ## πŸ”§ Complete Tools Reference
287
201
 
288
- This section provides a comprehensive reference of all 145 available tools organized by category.
202
+ This section provides a comprehensive reference of all 150 available tools organized by category.
289
203
 
290
204
  ### Database Discovery
291
205
 
@@ -770,7 +684,7 @@ Workflow Macros are composite tools designed to execute complex, multi-step oper
770
684
 
771
685
  ### safe_export_table
772
686
 
773
- 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.
774
688
 
775
689
  **Parameters:**
776
690
  - `table_name` (required): Name of the table to export.
@@ -1341,13 +1255,20 @@ The MySQL MCP Server provides comprehensive schema versioning and migration tool
1341
1255
  Schema versioning operations require `ddl` permission:
1342
1256
 
1343
1257
  ```json
1344
- "args": [
1345
- "--mysql-host", "localhost",
1346
- "--mysql-user", "root",
1347
- "--mysql-password", "password",
1348
- "--mysql-database", "mydb",
1349
- "--permissions", "list,read,create,update,delete,ddl"
1350
- ]
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
+ }
1351
1272
  ```
1352
1273
 
1353
1274
  ### Initialize Migrations Table
@@ -3005,7 +2926,38 @@ Reset Performance Schema statistics to start fresh monitoring.
3005
2926
 
3006
2927
  ## πŸ€– AI Enhancement Tools
3007
2928
 
3008
- The AI Enhancement tools provide intelligent, AI-powered features for database exploration, query generation, documentation, schema design, security auditing, and index recommendations. These tools include **Phase 1-2** enhancements.
2929
+ The AI Enhancement tools provide intelligent, AI-powered features for database exploration, query generation, documentation, schema design, security auditing, index recommendations, data generation, visualization, and forecasting. These tools include **Phase 1-3** enhancements.
2930
+
2931
+ ### At a Glance (Phase 1–3 - Implemented)
2932
+
2933
+ - **Intelligent Query Assistant**
2934
+ - **`build_query_from_intent`** - Converts natural language to optimized SQL queries
2935
+ - **`suggest_query_improvements`** - AI-powered query optimization suggestions
2936
+ - *Use case: "Show me active users from last month" β†’ Automatically generates SQL*
2937
+
2938
+ - **Smart Data Discovery Agent**
2939
+ - **`smart_search`** - Semantic search for tables, columns, and data patterns
2940
+ - **`find_similar_columns`** - Discover columns with similar names or data patterns
2941
+ - **`discover_data_patterns`** - Automatic identification of data patterns and relationships
2942
+ - *Use case: Find all customer-related columns across hundreds of tables*
2943
+
2944
+ - **AI-Powered Documentation Generator**
2945
+ - **`generate_documentation`** - Automatic database documentation with business glossary
2946
+ - **`generate_data_dictionary`** - Interactive data dictionaries with examples
2947
+ - **`generate_business_glossary`** - Business terminology mapping to technical fields
2948
+ - *Use case: Generate complete documentation for a new database in seconds*
2949
+
2950
+ - **Schema + Security + Indexing**
2951
+ - **`design_schema_from_requirements`** - Generate proposed tables, relationships, and DDL from business requirements
2952
+ - **`audit_database_security`** - Best-effort MySQL security audit with prioritized findings
2953
+ - **`recommend_indexes`** - Concrete index recommendations from observed query patterns (performance_schema)
2954
+
2955
+ - **Data Generation + Patterns + Visualization + Forecasting**
2956
+ - **`generate_test_data`** - Generate FK-aware SQL INSERT statements for synthetic test data (does not execute)
2957
+ - **`analyze_schema_patterns`** - Detect schema anti-patterns (missing PKs, wide tables, unindexed FKs, EAV-like tables)
2958
+ - **`visualize_query`** - Mermaid flowchart visualization of queries using EXPLAIN FORMAT=JSON
2959
+ - **`predict_query_performance`** - Heuristic prediction of EXPLAIN scan/cost under growth assumptions
2960
+ - **`forecast_database_growth`** - Forecast table/database size growth from current sizes and user-supplied rates
3009
2961
 
3010
2962
  ### Tool Overview
3011
2963
 
@@ -3022,6 +2974,11 @@ The AI Enhancement tools provide intelligent, AI-powered features for database e
3022
2974
  | `design_schema_from_requirements` | Designs a proposed schema and outputs DDL from natural language requirements | `ai_enhancement` |
3023
2975
  | `audit_database_security` | Audits MySQL security configuration and (optionally) accounts/privileges | `ai_enhancement` |
3024
2976
  | `recommend_indexes` | Suggests concrete CREATE INDEX statements from observed query patterns | `ai_enhancement` |
2977
+ | `generate_test_data` | Generates SQL INSERT statements for synthetic test data (non-executing) | `ai_enhancement` |
2978
+ | `analyze_schema_patterns` | Detects schema patterns/anti-patterns and provides recommendations | `ai_enhancement` |
2979
+ | `visualize_query` | Produces Mermaid query diagrams from EXPLAIN JSON | `ai_enhancement` |
2980
+ | `predict_query_performance` | Predicts query scan/cost changes under growth assumptions (heuristic) | `ai_enhancement` |
2981
+ | `forecast_database_growth` | Forecasts table/database growth from current sizes and rates | `ai_enhancement` |
3025
2982
 
3026
2983
  ### Intelligent Query Assistant
3027
2984
 
@@ -4172,316 +4129,6 @@ Each bulk operation returns performance metrics:
4172
4129
 
4173
4130
  ---
4174
4131
 
4175
- ## 🎭 Data Masking
4176
-
4177
- 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.
4178
-
4179
- ### Features
4180
-
4181
- - **Profile-Based Masking**: Easy configuration profiles (`none`, `soft`, `partial`, `strict`)
4182
- - **Automatic Detection**: Automatically identifies sensitive columns by name (e.g., `email`, `password`, `ssn`)
4183
- - **Multiple Strategies**:
4184
- - **REDACT**: Replaces value with `[REDACTED]`
4185
- - **PARTIAL**: Partially masks email (`j***@d.com`) and phone/CC (`***1234`)
4186
- - **HASH**: (Internal placeholder)
4187
-
4188
- ### Configuration
4189
-
4190
- Configure the masking profile via the `MCP_MASKING_PROFILE` environment variable:
4191
-
4192
- ```bash
4193
- MCP_MASKING_PROFILE=partial
4194
- ```
4195
-
4196
- ### Profiles Reference
4197
-
4198
- | Profile | Description | Credentials (password, key) | PII (email, phone, ssn) |
4199
- |---------|-------------|-----------------------------|-------------------------|
4200
- | `none` | No masking (default) | Show | Show |
4201
- | `soft` | Protect secrets only | **REDACT** | Show |
4202
- | `partial` | Balanced security | **REDACT** | **PARTIAL** (j***@...) |
4203
- | `strict` | Maximum security | **REDACT** | **REDACT** |
4204
-
4205
- ### Behavior
4206
-
4207
- - Masking applies automatically to `run_query` and `read_records` results.
4208
- - 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).
4209
-
4210
- ---
4211
-
4212
-
4213
- ---
4214
-
4215
- ## ⚑ Workflow Macros
4216
-
4217
- 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.
4218
-
4219
- ### Safe Export Table
4220
-
4221
- 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.
4222
-
4223
- #### Features
4224
-
4225
- - **Forced Masking**: Applies a masking profile (default: `strict`) to all exported data.
4226
- - **Hard Limit**: Enforces a maximum row limit (10,000) to prevent Out-Of-Memory errors during large exports.
4227
- - **CSV Formatting**: Automatically handles special characters, quotes, and newlines.
4228
- - **Header Control**: Option to include or exclude CSV headers.
4229
-
4230
- #### Usage
4231
-
4232
- ```json
4233
- {
4234
- "tool": "safe_export_table",
4235
- "arguments": {
4236
- "table_name": "users",
4237
- "masking_profile": "partial",
4238
- "limit": 1000
4239
- }
4240
- }
4241
- ```
4242
-
4243
- #### Parameters
4244
-
4245
- | Parameter | Type | Required | Description | Default |
4246
- |-----------|------|----------|-------------|---------|
4247
- | `table_name` | string | Yes | Name of the table to export | - |
4248
- | `masking_profile` | string | No | Masking profile to apply (`strict`, `partial`, `soft`) | `strict` |
4249
- | `limit` | number | No | Number of rows to export (max 10,000) | 1000 |
4250
- | `include_headers` | boolean | No | Whether to include CSV headers | `true` |
4251
-
4252
- #### Response
4253
-
4254
- ```json
4255
- {
4256
- "status": "success",
4257
- "data": {
4258
- "csv": "id,name,email\n1,John Doe,j***@example.com...",
4259
- "row_count": 50,
4260
- "applied_profile": "partial"
4261
- }
4262
- }
4263
- ```
4264
-
4265
- ---
4266
-
4267
- ## πŸ€– OpenAI Codex Integration
4268
-
4269
- 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.
4270
-
4271
- ### Configuration Overview
4272
-
4273
- | Feature | Details |
4274
- |---------|---------|
4275
- | **Config File** | `~/.codex/config.toml` |
4276
- | **Shared Config** | CLI and VS Code extension use the same file |
4277
- | **Transport** | STDIO (standard input/output) |
4278
- | **Format** | TOML |
4279
-
4280
- ### Quick Setup via CLI
4281
-
4282
- The fastest way to add MySQL MCP to Codex:
4283
-
4284
- ```bash
4285
- # Basic setup with connection string
4286
- codex mcp add mysql -- npx -y @berthojoris/mcp-mysql-server mysql://user:password@localhost:3306/database list,read,utility
4287
-
4288
- # With environment variables
4289
- 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
4290
- ```
4291
-
4292
- ### Manual TOML Configuration
4293
-
4294
- Edit `~/.codex/config.toml` directly for more control:
4295
-
4296
- #### Basic Configuration
4297
-
4298
- ```toml
4299
- [mcp_servers.mysql]
4300
- command = "npx"
4301
- args = ["-y", "@berthojoris/mcp-mysql-server", "mysql://user:password@localhost:3306/database", "list,read,utility"]
4302
- ```
4303
-
4304
- #### With Environment Variables
4305
-
4306
- ```toml
4307
- [mcp_servers.mysql]
4308
- command = "npx"
4309
- args = ["-y", "@berthojoris/mcp-mysql-server"]
4310
-
4311
- [mcp_servers.mysql.env]
4312
- DB_HOST = "localhost"
4313
- DB_PORT = "3306"
4314
- DB_USER = "root"
4315
- DB_PASSWORD = "your_password"
4316
- DB_NAME = "your_database"
4317
- MCP_PERMISSIONS = "list,read,utility"
4318
- ```
4319
-
4320
- #### Local Path Configuration (Development)
4321
-
4322
- ```toml
4323
- [mcp_servers.mysql]
4324
- command = "node"
4325
- args = ["C:\\DEKSTOP\\MCP\\mcp_mysql\\bin\\mcp-mysql.js", "mysql://user:pass@localhost:3306/database", "list,read,utility"]
4326
- cwd = "C:\\DEKSTOP\\MCP\\mcp_mysql"
4327
- ```
4328
-
4329
- ### Configuration Options Reference
4330
-
4331
- | Option | Type | Default | Description |
4332
- |--------|------|---------|-------------|
4333
- | `command` | String | Required | The executable to launch the server |
4334
- | `args` | Array | `[]` | Command-line arguments passed to the server |
4335
- | `env` | Table | `{}` | Environment variables for the server process |
4336
- | `env_vars` | Array | `[]` | Additional env vars to whitelist/forward |
4337
- | `cwd` | String | - | Working directory to launch the server from |
4338
- | `startup_timeout_sec` | Number | `10` | Server startup timeout in seconds |
4339
- | `tool_timeout_sec` | Number | `60` | Per-tool execution timeout in seconds |
4340
- | `enabled` | Boolean | `true` | Set to `false` to disable without deleting |
4341
- | `enabled_tools` | Array | - | Allow-list of tools to expose from server |
4342
- | `disabled_tools` | Array | - | Deny-list of tools to hide |
4343
-
4344
- ### Advanced Configurations
4345
-
4346
- #### Production (Read-Only) + Development (Full Access)
4347
-
4348
- ```toml
4349
- # Production database - Read Only
4350
- [mcp_servers.mysql-prod]
4351
- command = "npx"
4352
- args = ["-y", "@berthojoris/mcp-mysql-server", "mysql://reader:pass@prod-server:3306/prod_db", "list,read,utility"]
4353
- startup_timeout_sec = 30
4354
- tool_timeout_sec = 120
4355
-
4356
- # Development database - Full Access
4357
- [mcp_servers.mysql-dev]
4358
- command = "npx"
4359
- args = ["-y", "@berthojoris/mcp-mysql-server", "mysql://root:pass@localhost:3306/dev_db", "list,read,create,update,delete,execute,ddl,transaction,utility"]
4360
- ```
4361
-
4362
- #### With Tool Filtering (Limit Exposed Tools)
4363
-
4364
- ```toml
4365
- [mcp_servers.mysql]
4366
- command = "npx"
4367
- args = ["-y", "@berthojoris/mcp-mysql-server", "mysql://user:pass@localhost:3306/db", "list,read,utility"]
4368
-
4369
- # Only expose specific tools
4370
- enabled_tools = [
4371
- "list_tables",
4372
- "read_table_schema",
4373
- "read_records",
4374
- "run_query",
4375
- "test_connection"
4376
- ]
4377
-
4378
- # Or hide specific dangerous tools
4379
- # disabled_tools = ["drop_table", "delete_record", "execute_sql"]
4380
- ```
4381
-
4382
- #### With Custom Timeouts for Large Operations
4383
-
4384
- ```toml
4385
- [mcp_servers.mysql]
4386
- command = "npx"
4387
- args = ["-y", "@berthojoris/mcp-mysql-server", "mysql://user:pass@localhost:3306/db", "list,read,create,update,delete,utility"]
4388
- startup_timeout_sec = 30 # Allow more time for startup
4389
- tool_timeout_sec = 300 # 5 minutes for large bulk operations
4390
- ```
4391
-
4392
- ### Codex MCP Management Commands
4393
-
4394
- ```bash
4395
- # List all configured MCP servers
4396
- codex mcp list
4397
-
4398
- # List with JSON output (for scripting)
4399
- codex mcp list --json
4400
-
4401
- # Get details about a specific server
4402
- codex mcp get mysql
4403
-
4404
- # Remove an MCP server
4405
- codex mcp remove mysql
4406
-
4407
- # Add server with multiple env vars
4408
- codex mcp add mysql --env DB_HOST=localhost --env DB_USER=root -- npx -y @berthojoris/mcp-mysql-server
4409
- ```
4410
-
4411
- ### VS Code Extension Setup
4412
-
4413
- 1. Install the Codex VS Code Extension
4414
- 2. Open the extension settings (gear icon in top right)
4415
- 3. Click "MCP settings" > "Open config.toml"
4416
- 4. Add your MySQL MCP configuration
4417
- 5. Save the file - changes apply immediately
4418
-
4419
- ### Verifying the Setup
4420
-
4421
- After configuration, test your setup:
4422
-
4423
- ```bash
4424
- # In Codex CLI
4425
- codex mcp list
4426
-
4427
- # You should see:
4428
- # mysql: npx -y @berthojoris/mcp-mysql-server ...
4429
- ```
4430
-
4431
- Then ask Codex:
4432
- - "What databases are available?"
4433
- - "List all tables in my database"
4434
- - "Show me the structure of the users table"
4435
-
4436
- ### Troubleshooting Codex Integration
4437
-
4438
- #### Server Not Starting
4439
-
4440
- 1. **Check TOML syntax** - A single syntax error breaks both CLI and VS Code extension
4441
- 2. **Verify paths** - Use absolute paths for local installations
4442
- 3. **Check startup timeout** - Increase `startup_timeout_sec` if server takes time to initialize
4443
-
4444
- #### Tools Not Appearing
4445
-
4446
- 1. Verify server configuration with `codex mcp list --json`
4447
- 2. Check that `enabled = true` (or not set, defaults to true)
4448
- 3. Ensure `enabled_tools` doesn't accidentally filter out needed tools
4449
-
4450
- #### Connection Errors
4451
-
4452
- 1. Test MySQL connection manually: `mysql -u user -p -h host database`
4453
- 2. Verify credentials in connection string
4454
- 3. Check network connectivity to MySQL server
4455
-
4456
- #### Common TOML Syntax Errors
4457
-
4458
- ```toml
4459
- # WRONG - missing quotes around string values
4460
- args = [-y, @berthojoris/mcp-mysql-server]
4461
-
4462
- # CORRECT
4463
- args = ["-y", "@berthojoris/mcp-mysql-server"]
4464
-
4465
- # WRONG - using JSON syntax
4466
- "mcp_servers": { "mysql": { ... } }
4467
-
4468
- # CORRECT - TOML table syntax
4469
- [mcp_servers.mysql]
4470
- command = "npx"
4471
- ```
4472
-
4473
- ### Permission Sets for Common Use Cases
4474
-
4475
- | Use Case | Permissions |
4476
- |----------|-------------|
4477
- | Read-Only Analysis | `list,read,utility` |
4478
- | Data Entry | `list,read,create,utility` |
4479
- | Full Data Access | `list,read,create,update,delete,utility` |
4480
- | With Transactions | `list,read,create,update,delete,transaction,utility` |
4481
- | Development (Full) | `list,read,create,update,delete,execute,ddl,transaction,procedure,utility` |
4482
-
4483
- ---
4484
-
4485
4132
  ## πŸ› οΈ Troubleshooting
4486
4133
 
4487
4134
  ### MCP Server Not Connecting
@@ -4573,89 +4220,3 @@ This error occurred in earlier versions (< 1.4.1) when AI agents called MCP tool
4573
4220
  ## πŸ“„ License
4574
4221
 
4575
4222
  MIT License - see [LICENSE](LICENSE) file for details.
4576
-
4577
- ---
4578
-
4579
- ## πŸ—ΊοΈ Roadmap
4580
-
4581
- ### Core Features
4582
- - βœ… **Transaction support (BEGIN, COMMIT, ROLLBACK)** - **COMPLETED!**
4583
- - βœ… **Stored procedure execution** - **COMPLETED!**
4584
- - βœ… **Bulk operations (batch insert/update/delete)** - **COMPLETED!**
4585
- - βœ… **Add query log on output** - **COMPLETED!**
4586
- - βœ… **Query result caching** - **COMPLETED!**
4587
- - βœ… **Advanced query optimization hints** - **COMPLETED!**
4588
-
4589
- ### Essential Database Objects (v1.6.0)
4590
- - βœ… **Views Management** - Create, alter, drop, and query database views - **COMPLETED!**
4591
- - βœ… **Triggers Management** - Full trigger lifecycle management - **COMPLETED!**
4592
- - βœ… **Functions Management** - Stored function creation and execution - **COMPLETED!**
4593
-
4594
- ### Administration Features (v1.6.0)
4595
- - βœ… **Index Management** - Create, drop, and analyze indexes - **COMPLETED!**
4596
- - βœ… **Foreign Keys & Constraints** - Constraint management with referential integrity - **COMPLETED!**
4597
- - βœ… **Table Maintenance** - Analyze, optimize, check, repair tables - **COMPLETED!**
4598
- - βœ… **Process Management** - Server processes, status, and query analysis - **COMPLETED!**
4599
-
4600
- ### Enterprise Features
4601
- - βœ… **Database backup and restore tools** - **COMPLETED!**
4602
- - βœ… **Data export/import utilities** (CSV, JSON, SQL dumps) - **COMPLETED!**
4603
- - βœ… **Data migration utilities** - **COMPLETED!**
4604
- - βœ… **Schema versioning and migrations** - **COMPLETED!**
4605
-
4606
- ### Recommended Implementation Order
4607
-
4608
- #### **Phase 1: Performance & Monitoring** πŸš€
4609
- - βœ… **Query result caching** - Dramatically improve response times for repeated queries - **COMPLETED!**
4610
- - βœ… **Performance metrics** - Track query execution times and database performance - **COMPLETED!**
4611
- - βœ… **Connection pool monitoring** - Monitor database connection health and usage - **COMPLETED!**
4612
- - βœ… **Database health checks** - Comprehensive system health monitoring - **COMPLETED!**
4613
-
4614
- #### **Phase 2: Data Management** πŸ“Š
4615
- - βœ… **Database backup and restore tools** - Essential for production data safety - **COMPLETED!**
4616
- - βœ… **Data migration utilities** - Move data between databases and environments - **COMPLETED!**
4617
- - βœ… **Enhanced export/import** - Support for JSON, SQL dump formats - **COMPLETED!**
4618
-
4619
- #### **Phase 3: Enterprise Features** 🏒
4620
- - βœ… **Schema versioning and migrations** - Version control for database schema changes - **COMPLETED!**
4621
- - βœ… **Query optimization** - Automatic query analysis and optimization suggestions - **COMPLETED!**
4622
-
4623
- #### **Implementation Priority Matrix**
4624
-
4625
- | Feature | Impact | Effort | Priority | Status |
4626
- |---------|--------|--------|----------|--------|
4627
- | Query Result Caching | High | Medium | 1 | βœ… COMPLETED |
4628
- | Views Management | High | Medium | 2 | βœ… COMPLETED |
4629
- | Triggers Management | High | Medium | 3 | βœ… COMPLETED |
4630
- | Functions Management | High | Medium | 4 | βœ… COMPLETED |
4631
- | Index Management | High | Medium | 5 | βœ… COMPLETED |
4632
- | Foreign Keys & Constraints | High | Medium | 6 | βœ… COMPLETED |
4633
- | Table Maintenance | High | Low | 7 | βœ… COMPLETED |
4634
- | Process Management | High | Medium | 8 | βœ… COMPLETED |
4635
- | Query Optimization | Medium | Medium | 9 | βœ… COMPLETED |
4636
- | Database Backup/Restore | High | High | 10 | βœ… COMPLETED |
4637
- | Data Export/Import (JSON, SQL) | High | Medium | 11 | βœ… COMPLETED |
4638
- | Data Migration | High | High | 12 | βœ… COMPLETED |
4639
- | Schema Versioning | Medium | Medium | 13 | βœ… COMPLETED |
4640
- | Performance Monitoring | High | Medium | 14 | βœ… COMPLETED |
4641
-
4642
- #### **Proposed Enhancements (AI Productivity)**
4643
-
4644
- | Feature | Impact | Effort | Priority | Status |
4645
- |---------|--------|--------|----------|--------|
4646
- | Adaptive Permission Presets (ReadOnly/Analyst/DBA Lite) | High | Medium | 1 | βœ… Completed |
4647
- | Schema-Aware RAG Context Pack | High | Medium | 2 | βœ… Completed |
4648
- | Guided Query Builder/Fixer (Intent β†’ Safe SQL + EXPLAIN Repair) | High | Medium | 3 | βœ… Completed |
4649
- | Drift & Migration Assistant (Schema diff + risk summary) | High | High | 4 | βœ… Completed |
4650
- | Safety Sandbox Mode (runQuery dry-run/EXPLAIN-only) | Medium | Low | 5 | βœ… Completed |
4651
- | Anomaly & Slow-Query Watcher | Medium | Medium | 6 | βœ… Completed |
4652
- | Data Masking Profiles for Responses | Medium | Medium | 7 | βœ… Completed |
4653
- | Workflow Macros (e.g., safe_export_table) | Medium | Low | 8 | βœ… Completed |
4654
- | Agent-Facing Changelog Feed | Medium | Low | 9 | βœ… Completed |
4655
- | Connection Profiles (dev/stage/prod with allow/deny) | High | Low | 10 | βœ… Completed |
4656
-
4657
- ---
4658
-
4659
- **Made with ❀️ for the AI community**
4660
-
4661
- *Help AI agents interact with MySQL databases safely and efficiently!*