@berthojoris/mcp-mysql-server 1.16.3 → 1.17.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/CHANGELOG.md CHANGED
@@ -5,6 +5,33 @@ 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.17.0] - 2025-12-12
9
+
10
+ ### Added
11
+ - **Phase 3: AI Enhancement Tools** - 5 new tools for data generation, schema review, visualization, and forecasting:
12
+ - `generate_test_data` - Generate FK-aware SQL INSERT statements for synthetic test data (does not execute)
13
+ - `analyze_schema_patterns` - Detect common schema anti-patterns (missing PKs, wide tables, unindexed FKs, EAV-like design)
14
+ - `visualize_query` - Produce a Mermaid flowchart representation of a query using EXPLAIN FORMAT=JSON
15
+ - `predict_query_performance` - Heuristic prediction of query scan/cost impact under growth assumptions
16
+ - `forecast_database_growth` - Forecast table/database size growth from current INFORMATION_SCHEMA sizes and user-supplied rates
17
+
18
+ ### Changed
19
+ - Updated total tool count from 145 to 150 tools.
20
+
21
+ ### Documentation
22
+ - Updated README.md and DOCUMENTATIONS.md to include Phase 3 AI Enhancement tools.
23
+
24
+ ## [1.16.4] - 2025-12-12
25
+
26
+ ### Added
27
+ - **Phase 2: AI Enhancement Tools** - 3 new tools to improve AI-assisted database engineering:
28
+ - `design_schema_from_requirements` - Natural-language schema design assistant that proposes tables, relationships, and DDL (non-executing)
29
+ - `audit_database_security` - Best-effort database security audit assistant with prioritized findings and recommendations
30
+ - `recommend_indexes` - Automated index recommendation system using performance_schema query digests and existing index introspection
31
+
32
+ ### Documentation
33
+ - Updated README.md and DOCUMENTATIONS.md to include the new Phase 2 AI Enhancement tools.
34
+
8
35
  ## [1.16.3] - 2025-12-11
9
36
 
10
37
  ### Documentation
package/DOCUMENTATIONS.md CHANGED
@@ -6,27 +6,263 @@ 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 134 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) - NEW!
28
- 20. [Usage Examples](#📋-usage-examples)
29
- 21. [Query Logging & Automatic SQL Display](#📝-query-logging--automatic-sql-display)
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)
31
+
32
+ ---
33
+
34
+ ## Setup & Configuration (Extended)
35
+
36
+ This section collects **client-specific configuration snippets** and **advanced setup patterns**. For the shortest setup, see [README.md](README.md).
37
+
38
+ ### Agent Configuration Examples
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**
76
+
77
+ ```json
78
+ {
79
+ "mcpServers": {
80
+ "mysql": {
81
+ "command": "npx",
82
+ "args": [
83
+ "-y",
84
+ "@berthojoris/mysql-mcp",
85
+ "mysql://user:password@localhost:3306/database",
86
+ "list,read,utility",
87
+ "database_discovery,performance_monitoring"
88
+ ]
89
+ }
90
+ }
91
+ }
92
+ ```
93
+
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)**
167
+
168
+ ```json
169
+ {
170
+ "mcpServers": {
171
+ "mysql": {
172
+ "command": "npx",
173
+ "args": ["-y", "@berthojoris/mysql-mcp"],
174
+ "env": {
175
+ "DB_HOST": "localhost",
176
+ "DB_PORT": "3306",
177
+ "DB_USER": "root",
178
+ "DB_PASSWORD": "your_password",
179
+ "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
+ "MCP_PERMISSIONS": "list,read,utility",
226
+ "MCP_CATEGORIES": "performance_monitoring"
227
+ }
228
+ }
229
+ }
230
+ }
231
+ ```
232
+
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
+ ```
30
266
 
31
267
  Control which database operations are available to AI using a **dual-layer filtering system**:
32
268
 
@@ -240,7 +476,7 @@ The system uses both arguments to determine access:
240
476
  - **3rd argument**: Categories (Layer 2, optional) - comma-separated documentation categories
241
477
 
242
478
  **Decision logic**:
243
- 1. If no arguments: All 120 tools enabled
479
+ 1. If no arguments: All 150 tools enabled
244
480
  2. If only 2nd argument (permissions): Tools enabled if they match permission
245
481
  3. If both arguments: Tools enabled if they match BOTH permission AND category
246
482
 
@@ -285,7 +521,7 @@ Add 'bulk_operations' to the categories argument.
285
521
 
286
522
  ## 🔧 Complete Tools Reference
287
523
 
288
- This section provides a comprehensive reference of all 120 available tools organized by category.
524
+ This section provides a comprehensive reference of all 150 available tools organized by category.
289
525
 
290
526
  ### Database Discovery
291
527
 
@@ -3005,7 +3241,38 @@ Reset Performance Schema statistics to start fresh monitoring.
3005
3241
 
3006
3242
  ## 🤖 AI Enhancement Tools
3007
3243
 
3008
- The AI Enhancement tools provide intelligent, AI-powered features for database exploration, query generation, and documentation. These tools are part of **Phase 1: Core AI Enhancement**.
3244
+ 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.
3245
+
3246
+ ### At a Glance (Phase 1–3 - Implemented)
3247
+
3248
+ - **Intelligent Query Assistant**
3249
+ - **`build_query_from_intent`** - Converts natural language to optimized SQL queries
3250
+ - **`suggest_query_improvements`** - AI-powered query optimization suggestions
3251
+ - *Use case: "Show me active users from last month" → Automatically generates SQL*
3252
+
3253
+ - **Smart Data Discovery Agent**
3254
+ - **`smart_search`** - Semantic search for tables, columns, and data patterns
3255
+ - **`find_similar_columns`** - Discover columns with similar names or data patterns
3256
+ - **`discover_data_patterns`** - Automatic identification of data patterns and relationships
3257
+ - *Use case: Find all customer-related columns across hundreds of tables*
3258
+
3259
+ - **AI-Powered Documentation Generator**
3260
+ - **`generate_documentation`** - Automatic database documentation with business glossary
3261
+ - **`generate_data_dictionary`** - Interactive data dictionaries with examples
3262
+ - **`generate_business_glossary`** - Business terminology mapping to technical fields
3263
+ - *Use case: Generate complete documentation for a new database in seconds*
3264
+
3265
+ - **Schema + Security + Indexing**
3266
+ - **`design_schema_from_requirements`** - Generate proposed tables, relationships, and DDL from business requirements
3267
+ - **`audit_database_security`** - Best-effort MySQL security audit with prioritized findings
3268
+ - **`recommend_indexes`** - Concrete index recommendations from observed query patterns (performance_schema)
3269
+
3270
+ - **Data Generation + Patterns + Visualization + Forecasting**
3271
+ - **`generate_test_data`** - Generate FK-aware SQL INSERT statements for synthetic test data (does not execute)
3272
+ - **`analyze_schema_patterns`** - Detect schema anti-patterns (missing PKs, wide tables, unindexed FKs, EAV-like tables)
3273
+ - **`visualize_query`** - Mermaid flowchart visualization of queries using EXPLAIN FORMAT=JSON
3274
+ - **`predict_query_performance`** - Heuristic prediction of EXPLAIN scan/cost under growth assumptions
3275
+ - **`forecast_database_growth`** - Forecast table/database size growth from current sizes and user-supplied rates
3009
3276
 
3010
3277
  ### Tool Overview
3011
3278
 
@@ -3019,6 +3286,14 @@ The AI Enhancement tools provide intelligent, AI-powered features for database e
3019
3286
  | `generate_documentation` | Generates comprehensive database documentation | `ai_enhancement` |
3020
3287
  | `generate_data_dictionary` | Creates detailed data dictionaries for tables | `ai_enhancement` |
3021
3288
  | `generate_business_glossary` | Builds business glossaries from column names | `ai_enhancement` |
3289
+ | `design_schema_from_requirements` | Designs a proposed schema and outputs DDL from natural language requirements | `ai_enhancement` |
3290
+ | `audit_database_security` | Audits MySQL security configuration and (optionally) accounts/privileges | `ai_enhancement` |
3291
+ | `recommend_indexes` | Suggests concrete CREATE INDEX statements from observed query patterns | `ai_enhancement` |
3292
+ | `generate_test_data` | Generates SQL INSERT statements for synthetic test data (non-executing) | `ai_enhancement` |
3293
+ | `analyze_schema_patterns` | Detects schema patterns/anti-patterns and provides recommendations | `ai_enhancement` |
3294
+ | `visualize_query` | Produces Mermaid query diagrams from EXPLAIN JSON | `ai_enhancement` |
3295
+ | `predict_query_performance` | Predicts query scan/cost changes under growth assumptions (heuristic) | `ai_enhancement` |
3296
+ | `forecast_database_growth` | Forecasts table/database growth from current sizes and rates | `ai_enhancement` |
3022
3297
 
3023
3298
  ### Intelligent Query Assistant
3024
3299
 
@@ -3081,6 +3356,85 @@ Analyzes a SQL query and provides suggestions for optimization.
3081
3356
  - `memory` - Focuses on memory usage optimization
3082
3357
  - `readability` - Suggests formatting and clarity improvements
3083
3358
 
3359
+ ### Schema Design
3360
+
3361
+ #### `design_schema_from_requirements`
3362
+
3363
+ Design a proposed schema (tables, columns, relationships) from business requirements and output suggested DDL. This tool **does not execute** any DDL.
3364
+
3365
+ ```javascript
3366
+ {
3367
+ "tool": "design_schema_from_requirements",
3368
+ "arguments": {
3369
+ "requirements_text": "We need to manage customers and orders. A customer has many orders. Orders have total_amount and order_date.",
3370
+ "naming_convention": "snake_case",
3371
+ "include_audit_columns": true,
3372
+ "id_type": "BIGINT"
3373
+ }
3374
+ }
3375
+
3376
+ // With explicit entity hints to improve accuracy
3377
+ {
3378
+ "tool": "design_schema_from_requirements",
3379
+ "arguments": {
3380
+ "requirements_text": "Basic e-commerce",
3381
+ "entities": [
3382
+ { "name": "customers", "fields": ["email", "name"] },
3383
+ { "name": "orders", "fields": ["total_amount", "order_date"] }
3384
+ ]
3385
+ }
3386
+ }
3387
+ ```
3388
+
3389
+ **Response includes:**
3390
+ - Proposed tables + columns (with inferred types)
3391
+ - Inferred relationships (FK suggestions)
3392
+ - `ddl_statements` array with CREATE TABLE / CREATE INDEX suggestions
3393
+
3394
+ ### Security Audit
3395
+
3396
+ #### `audit_database_security`
3397
+
3398
+ Runs a best-effort security audit using read-only inspection queries (e.g., `SHOW VARIABLES`, and optionally `mysql.user` / `INFORMATION_SCHEMA` where permitted).
3399
+
3400
+ ```javascript
3401
+ {
3402
+ "tool": "audit_database_security",
3403
+ "arguments": {
3404
+ "include_user_account_checks": true,
3405
+ "include_privilege_checks": true
3406
+ }
3407
+ }
3408
+ ```
3409
+
3410
+ **Response includes:**
3411
+ - Prioritized findings with severities and recommendations
3412
+ - Summary counts by severity
3413
+ - Notes when checks are skipped due to missing privileges
3414
+
3415
+ ### Index Recommendations
3416
+
3417
+ #### `recommend_indexes`
3418
+
3419
+ Analyzes `performance_schema` digests to propose concrete indexing strategies.
3420
+
3421
+ ```javascript
3422
+ {
3423
+ "tool": "recommend_indexes",
3424
+ "arguments": {
3425
+ "max_query_patterns": 25,
3426
+ "min_execution_count": 10,
3427
+ "min_avg_time_ms": 5,
3428
+ "max_recommendations": 20,
3429
+ "include_unused_index_warnings": true
3430
+ }
3431
+ }
3432
+ ```
3433
+
3434
+ **Notes:**
3435
+ - Requires `performance_schema` enabled and accessible by the MySQL user.
3436
+ - Always validate recommendations with `EXPLAIN` and production-like testing.
3437
+
3084
3438
  ### Smart Data Discovery
3085
3439
 
3086
3440
  #### `smart_search`