@berthojoris/mcp-mysql-server 1.10.5 β†’ 1.13.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,25 @@ 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.13.0] - 2025-12-07
9
+
10
+ ### Added
11
+ - **Guided Query Builder/Fixer** - New `repair_query` tool that uses deterministic heuristics and `EXPLAIN` to analyze and fix SQL queries.
12
+ - Suggests optimizations (e.g., adding indexes, limits).
13
+ - Analyzes execution plans for performance issues like full table scans.
14
+ - Provides actionable feedback for specific error messages.
15
+
16
+ ## [1.12.0] - 2025-12-05
17
+
18
+ ### Added
19
+ - Schema-Aware RAG Context Pack via `get_schema_rag_context`, delivering compact table/column/PK/FK snapshots with row estimates for embeddings-friendly prompts.
20
+
21
+ ### Fixed
22
+ - Exposed analysis tools (`get_database_summary`, `get_schema_erd`, `get_column_statistics`) and the new RAG context pack through MCP tool registration and routing.
23
+
24
+ ### Changed
25
+ - Updated documentation and tool counts to 120, reflecting the new analysis capability and refreshed README guidance.
26
+
8
27
  ## [1.10.5] - 2025-12-02
9
28
 
10
29
  ### Changed
@@ -14,6 +33,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
14
33
 
15
34
  ## [1.10.4] - 2025-12-02
16
35
 
36
+ ### Added
37
+ - **AI Context Optimization** - Added 4 new AI-centric tools:
38
+ - `get_database_summary` - High-level database overview (tables, columns, row counts) optimized for context window
39
+ - `get_schema_erd` - Generates Mermaid.js ER diagrams for visual schema representation
40
+ - `get_column_statistics` - Deep data profiling (min/max, nulls, distinct counts) for intelligent query building
41
+ - `run_query` Safe Mode - Added `dry_run` flag to preview query plans and costs without execution
42
+
17
43
  ### Fixed
18
44
  - Removed "IMPORTANT_INSTRUCTION_TO_ASSISTANT" instruction from documentation - no longer needed
19
45
  - Removed "SQL_QUERY_EXECUTED" message references from documentation - simplified response structure
@@ -467,6 +493,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
467
493
  - Direct access to `mysql`, `performance_schema`, `sys` databases
468
494
  - `USER` / `PASSWORD` manipulation
469
495
 
496
+ ## [1.11.0] - 2025-12-05
497
+
498
+ ### Added
499
+ - Adaptive permission presets (`readonly`, `analyst`, `dba-lite`) with mergeable overrides
500
+ - CLI `--preset` flag and `MCP_PRESET`/`MCP_PERMISSION_PRESET` env support with resolved-config logging
501
+
502
+ ### Changed
503
+ - Safe fallback to read-only defaults when an unknown preset is requested without overrides
504
+ - Feature status endpoint now exposes preset-aware configuration snapshots for easier debugging
505
+
470
506
  ## [1.4.3] - 2025-01-06
471
507
 
472
508
  ### Added
@@ -512,6 +548,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
512
548
 
513
549
  ## Version History Summary
514
550
 
551
+ - **1.11.0** - Adaptive permission presets with CLI/env support and preset-aware logging
515
552
  - **1.9.0** - Schema Versioning & Migrations (9 new tools), MCP integration for 12 AI tools
516
553
  - **1.8.0** - Data Migration Tools
517
554
  - **1.7.0** - Database Backup/Restore, Data Import/Export
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 119 tools organized by category
9
+ 1. [Category Filtering System](#πŸ†•-category-filtering-system) - NEW!
10
+ 2. [πŸ”§ Complete Tools Reference](#πŸ”§-complete-tools-reference) - All 120 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)
@@ -29,15 +29,16 @@ This file contains detailed documentation for all features of the MySQL MCP Serv
29
29
  21. [Security Features](#πŸ”’-security-features)
30
30
  22. [Query Result Caching](#πŸ’Ύ-query-result-caching)
31
31
  23. [Query Optimization Hints](#🎯-query-optimization-hints)
32
- 24. [Bulk Operations](#πŸš€-bulk-operations)
33
- 25. [OpenAI Codex Integration](#πŸ€–-openai-codex-integration)
34
- 26. [Troubleshooting](#πŸ› οΈ-troubleshooting)
35
- 27. [License](#πŸ“„-license)
36
- 28. [Roadmap](#πŸ—ΊοΈ-roadmap)
32
+ 24. [Guided Query Builder/Fixer](#πŸ€–-guided-query-builderfixer)
33
+ 25. [Bulk Operations](#πŸš€-bulk-operations)
34
+ 26. [OpenAI Codex Integration](#πŸ€–-openai-codex-integration)
35
+ 27. [Troubleshooting](#πŸ› οΈ-troubleshooting)
36
+ 28. [License](#πŸ“„-license)
37
+ 29. [Roadmap](#πŸ—ΊοΈ-roadmap)
37
38
 
38
39
  ---
39
40
 
40
- ## πŸ†• Dual-Layer Filtering System
41
+ ## Dual-Layer Filtering System
41
42
 
42
43
  Control which database operations are available to AI using a **dual-layer filtering system**:
43
44
 
@@ -71,7 +72,8 @@ schema_management,utilities,transaction_management,stored_procedures,
71
72
  views_management,triggers_management,functions_management,index_management,
72
73
  constraint_management,table_maintenance,server_management,
73
74
  performance_monitoring,cache_management,query_optimization,
74
- backup_restore,import_export,data_migration,schema_migrations
75
+ backup_restore,import_export,data_migration,schema_migrations,
76
+ analysis
75
77
  ```
76
78
 
77
79
  ### Configuration Examples
@@ -194,6 +196,24 @@ Data operations without schema changes:
194
196
 
195
197
  **Enabled**: Full data CRUD + bulk ops + transactions - NO schema changes (no `ddl` permission).
196
198
 
199
+ ### Adaptive Permission Presets (ReadOnly/Analyst/DBA Lite)
200
+
201
+ Preset bundles provide safe starting points and **merge** with any explicit permissions/categories you pass (CLI args or env vars).
202
+
203
+ | Preset | Permissions | Categories | Intended Use |
204
+ |--------|-------------|------------|--------------|
205
+ | `readonly` | `list,read,utility` | `database_discovery,crud_operations,custom_queries,utilities,import_export,performance_monitoring,analysis` | Safe read-only access, exports, and diagnostics |
206
+ | `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 |
207
+ | `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 |
208
+
209
+ **Usage**
210
+
211
+ - CLI: `mcp-mysql mysql://user:pass@host:3306/db --preset readonly`
212
+ - CLI with overrides: `mcp-mysql mysql://... --preset analyst "list,read,utility" "performance_monitoring"`
213
+ - Env: `MCP_PRESET=analyst` (or `MCP_PERMISSION_PRESET=analyst`) and optionally extend with `MCP_PERMISSIONS` / `MCP_CATEGORIES`
214
+
215
+ 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.
216
+
197
217
  ### Permissions Reference (Layer 1)
198
218
 
199
219
  | Permission | Operations Allowed | Example Tools |
@@ -222,7 +242,7 @@ The system uses both arguments to determine access:
222
242
  - **3rd argument**: Categories (Layer 2, optional) - comma-separated documentation categories
223
243
 
224
244
  **Decision logic**:
225
- 1. If no arguments: All 119 tools enabled
245
+ 1. If no arguments: All 120 tools enabled
226
246
  2. If only 2nd argument (permissions): Tools enabled if they match permission
227
247
  3. If both arguments: Tools enabled if they match BOTH permission AND category
228
248
 
@@ -267,7 +287,7 @@ Add 'bulk_operations' to the categories argument.
267
287
 
268
288
  ## πŸ”§ Complete Tools Reference
269
289
 
270
- This section provides a comprehensive reference of all 119 available tools organized by category.
290
+ This section provides a comprehensive reference of all 120 available tools organized by category.
271
291
 
272
292
  ### Database Discovery
273
293
 
@@ -498,6 +518,21 @@ This section provides a comprehensive reference of all 119 available tools organ
498
518
  | `reset_failed_migration` | Reset failed migration to pending | `ddl` |
499
519
  | `generate_migration_from_diff` | Generate migration from table diff | `ddl` |
500
520
 
521
+ ### AI Context & Analysis Tools
522
+
523
+ | Tool | Description | Requires |
524
+ |------|-------------|----------|
525
+ | `get_database_summary` | High-level overview (tables, columns, rows) for AI context | `list` |
526
+ | `get_schema_erd` | Generate Mermaid.js ER diagram for visualization | `list` |
527
+ | `get_schema_rag_context` | Condensed schema snapshot (tables, PK/FK, row estimates) for RAG prompts | `list` |
528
+ | `get_column_statistics` | Profile data (min, max, nulls, distinct) for analysis | `read` |
529
+
530
+ #### Schema-Aware RAG Context Pack
531
+ - Purpose-built for embeddings: returns a `context_text` block plus structured `tables` and `relationships` so agents can self-orient without pulling a full ERD.
532
+ - Tunable size: `max_tables` (default 50, max 200) and `max_columns` (default 12) to control output length; set `include_relationships` to `false` to omit FK lines.
533
+ - Safety: respects the connected database onlyβ€”cannot introspect other schemasβ€”and notes when tables/columns are truncated.
534
+ - Output includes per-table PKs, FK targets, nullable flags, and approximate row counts from `INFORMATION_SCHEMA.TABLES` (InnoDB estimates).
535
+
501
536
  ---
502
537
 
503
538
  ## πŸ—οΈ DDL Operations
@@ -3605,6 +3640,50 @@ Available goals:
3605
3640
 
3606
3641
  ---
3607
3642
 
3643
+ ---
3644
+
3645
+ ## πŸ€– Guided Query Builder/Fixer
3646
+
3647
+ The `repair_query` tool acts as an AI-powered assistant for SQL query optimization and troubleshooting.
3648
+
3649
+ ### Features
3650
+
3651
+ - **Query Analysis**: Uses `EXPLAIN` to understand query execution plans.
3652
+ - **Auto-Fixing**: Identifying missing indexes, inefficient scans, and syntax errors.
3653
+ - **Heuristic suggestions**: Provides actionable advice (e.g. "Add index on column X", "Add LIMIT clause").
3654
+
3655
+ ### Usage Example
3656
+
3657
+ **Request:**
3658
+ ```json
3659
+ {
3660
+ "tool": "repair_query",
3661
+ "arguments": {
3662
+ "query": "SELECT * FROM users WHERE email = 'test@example.com'",
3663
+ "error_message": "Optional error message if query failed"
3664
+ }
3665
+ }
3666
+ ```
3667
+
3668
+ **Response:**
3669
+ ```json
3670
+ {
3671
+ "status": "success",
3672
+ "analysis": {
3673
+ "complexity": "HIGH",
3674
+ "issues": ["Full Table Scan on table 'users'"],
3675
+ "suggestions": ["Consider adding an index on table 'users' for the columns used in WHERE clause."]
3676
+ },
3677
+ "fixed_query": "SELECT * FROM users WHERE email = 'test@example.com'",
3678
+ "suggestions": [
3679
+ "Consider adding an index on table 'users' for the columns used in WHERE clause.",
3680
+ "Consider adding 'LIMIT 100' to prevent massive data transfer."
3681
+ ]
3682
+ }
3683
+ ```
3684
+
3685
+ ---
3686
+
3608
3687
  ## πŸš€ Bulk Operations
3609
3688
 
3610
3689
  The MySQL MCP server includes powerful bulk operation tools designed for high-performance data processing. These tools are optimized for handling large datasets efficiently.
@@ -4018,16 +4097,6 @@ MIT License - see [LICENSE](LICENSE) file for details.
4018
4097
  - βœ… **Data export/import utilities** (CSV, JSON, SQL dumps) - **COMPLETED!**
4019
4098
  - βœ… **Data migration utilities** - **COMPLETED!**
4020
4099
  - βœ… **Schema versioning and migrations** - **COMPLETED!**
4021
- - [ ] **Performance monitoring and metrics**
4022
- - [ ] **Connection pool monitoring**
4023
- - [ ] **Audit logging and compliance**
4024
-
4025
- ### Database Adapters
4026
- - [ ] PostgreSQL adapter
4027
- - [ ] MongoDB adapter
4028
- - [ ] SQLite adapter
4029
- - [ ] Oracle Database adapter
4030
- - [ ] SQL Server adapter
4031
4100
 
4032
4101
  ### Recommended Implementation Order
4033
4102
 
@@ -4041,19 +4110,10 @@ MIT License - see [LICENSE](LICENSE) file for details.
4041
4110
  - βœ… **Database backup and restore tools** - Essential for production data safety - **COMPLETED!**
4042
4111
  - βœ… **Data migration utilities** - Move data between databases and environments - **COMPLETED!**
4043
4112
  - βœ… **Enhanced export/import** - Support for JSON, SQL dump formats - **COMPLETED!**
4044
- - [ ] **Query history & analytics** - Track and analyze database usage patterns
4045
4113
 
4046
4114
  #### **Phase 3: Enterprise Features** 🏒
4047
- - [ ] **Audit logging and compliance** - Track all database operations for security
4048
4115
  - βœ… **Schema versioning and migrations** - Version control for database schema changes - **COMPLETED!**
4049
4116
  - βœ… **Query optimization** - Automatic query analysis and optimization suggestions - **COMPLETED!**
4050
- - [ ] **Advanced security features** - Enhanced access control and monitoring
4051
-
4052
- #### **Phase 4: Multi-Database Support** 🌐
4053
- - [ ] **PostgreSQL adapter** - Extend support to PostgreSQL databases
4054
- - [ ] **MongoDB adapter** - Add NoSQL document database support
4055
- - [ ] **SQLite adapter** - Support for lightweight embedded databases
4056
- - [ ] **Database-agnostic operations** - Unified API across different database types
4057
4117
 
4058
4118
  #### **Implementation Priority Matrix**
4059
4119
 
@@ -4073,8 +4133,21 @@ MIT License - see [LICENSE](LICENSE) file for details.
4073
4133
  | Data Migration | High | High | 12 | βœ… COMPLETED |
4074
4134
  | Schema Versioning | Medium | Medium | 13 | βœ… COMPLETED |
4075
4135
  | Performance Monitoring | High | Medium | 14 | βœ… COMPLETED |
4076
- | PostgreSQL Adapter | High | High | 15 | Pending |
4077
- | Audit Logging | Medium | Low | 16 | Pending |
4136
+
4137
+ #### **Proposed Enhancements (AI Productivity)**
4138
+
4139
+ | Feature | Impact | Effort | Priority | Status |
4140
+ |---------|--------|--------|----------|--------|
4141
+ | Adaptive Permission Presets (ReadOnly/Analyst/DBA Lite) | High | Medium | 1 | βœ… Completed |
4142
+ | Schema-Aware RAG Context Pack | High | Medium | 2 | βœ… Completed |
4143
+ | Guided Query Builder/Fixer (Intent β†’ Safe SQL + EXPLAIN Repair) | High | Medium | 3 | βœ… Completed |
4144
+ | Drift & Migration Assistant (Schema diff + risk summary) | High | High | 4 | βœ… Completed |
4145
+ | Safety Sandbox Mode (runQuery dry-run/EXPLAIN-only) | Medium | Low | 5 | βœ… Completed |
4146
+ | Anomaly & Slow-Query Watcher | Medium | Medium | 6 | βœ… Completed |
4147
+ | Data Masking Profiles for Responses | Medium | Medium | 7 | Planned |
4148
+ | Workflow Macros (e.g., safe_export_table) | Medium | Low | 8 | Planned |
4149
+ | Agent-Facing Changelog Feed | Medium | Low | 9 | Planned |
4150
+ | Connection Profiles (dev/stage/prod with allow/deny) | High | Low | 10 | Planned |
4078
4151
 
4079
4152
  ---
4080
4153
 
package/README.md CHANGED
@@ -46,11 +46,11 @@ Add to your AI agent config (`.mcp.json`, `.cursor/mcp.json`, etc.):
46
46
  - [AI Agent Configuration](#-ai-agent-configuration)
47
47
  - [Standard JSON Config](#standard-json-configuration)
48
48
  - [OpenAI Codex (TOML)](#openai-codex-cli--vs-code-extension)
49
- - [Zed IDE](#zed-ide)
49
+ - [Zed IDE](#zed-ide)
50
50
  - [Environment Variables](#environment-variables-configuration)
51
51
  - [Local Development](#local-path-configuration)
52
52
  - [Permission System](#-permission-system)
53
- - [Available Tools (119 total)](#-available-tools)
53
+ - [Available Tools (120 total)](#-available-tools)
54
54
  - [Documentation](#-detailed-documentation)
55
55
  - [Comparison: MCP vs Manual Access](#-mysql-mcp-vs-manual-database-access)
56
56
  - [License](#-license)
@@ -63,8 +63,10 @@ Add to your AI agent config (`.mcp.json`, `.cursor/mcp.json`, etc.):
63
63
  |----------|-------------|
64
64
  | **Full MCP Support** | Works with Claude Code, Cursor, Windsurf, Zed, Cline, Kilo Code, Roo Code, Gemini CLI, OpenAI Codex, and any MCP-compatible AI agent |
65
65
  | **Security First** | Parameterized queries, SQL injection protection, permission-based access control |
66
- | **119 Powerful Tools** | Complete database operations including CRUD, DDL, transactions, stored procedures, backup/restore, migrations |
67
- | **πŸ†• Category Filtering** | 22 documentation categories for intuitive, fine-grained access control (backward compatible with 10 legacy categories) |
66
+ | **121 Powerful Tools** | Complete database operations including CRUD, DDL, transactions, stored procedures, backup/restore, migrations |
67
+ | **Adaptive Presets** | Built-in ReadOnly/Analyst/DBA Lite permission bundles with override merging |
68
+ | **Schema-Aware RAG Pack** | Compact schema snapshots (tables, PK/FK, row estimates) tailored for embeddings-friendly prompts |
69
+ | **Category Filtering** | 22 documentation categories for intuitive, fine-grained access control (backward compatible with 10 legacy categories) |
68
70
  | **Transaction Support** | Full ACID transaction management (BEGIN, COMMIT, ROLLBACK) |
69
71
  | **Schema Migrations** | Version control for database schema with up/down migrations |
70
72
  | **Dual Mode** | Run as MCP server OR as REST API |
@@ -329,6 +331,8 @@ Zed IDE uses a different structure in `~/.config/zed/settings.json`:
329
331
 
330
332
  Alternative approach using environment variables instead of connection string:
331
333
 
334
+ **Option 1: Permissions Only (Simple)**
335
+
332
336
  ```json
333
337
  {
334
338
  "mcpServers": {
@@ -348,6 +352,53 @@ Alternative approach using environment variables instead of connection string:
348
352
  }
349
353
  ```
350
354
 
355
+ **Option 2: Permissions + Categories (Recommended)**
356
+
357
+ ```json
358
+ {
359
+ "mcpServers": {
360
+ "mysql": {
361
+ "command": "npx",
362
+ "args": ["-y", "@berthojoris/mysql-mcp"],
363
+ "env": {
364
+ "DB_HOST": "localhost",
365
+ "DB_PORT": "3306",
366
+ "DB_USER": "root",
367
+ "DB_PASSWORD": "your_password",
368
+ "DB_NAME": "your_database",
369
+ "MCP_PERMISSIONS": "list,read,utility",
370
+ "MCP_CATEGORIES": "database_discovery,performance_monitoring"
371
+ }
372
+ }
373
+ }
374
+ }
375
+ ```
376
+
377
+ **Option 3: Adaptive Preset (Merges with Overrides)**
378
+
379
+ ```json
380
+ {
381
+ "mcpServers": {
382
+ "mysql": {
383
+ "command": "npx",
384
+ "args": ["-y", "@berthojoris/mysql-mcp"],
385
+ "env": {
386
+ "DB_HOST": "localhost",
387
+ "DB_PORT": "3306",
388
+ "DB_USER": "root",
389
+ "DB_PASSWORD": "your_password",
390
+ "DB_NAME": "your_database",
391
+ "MCP_PRESET": "readonly",
392
+ "MCP_PERMISSIONS": "list,read,utility",
393
+ "MCP_CATEGORIES": "performance_monitoring"
394
+ }
395
+ }
396
+ }
397
+ }
398
+ ```
399
+
400
+ Add `MCP_PRESET` for the base bundle and optionally layer on `MCP_PERMISSIONS` / `MCP_CATEGORIES` for project-specific overrides.
401
+
351
402
  ---
352
403
 
353
404
  ### Local Path Configuration
@@ -422,7 +473,7 @@ Control database access with a **dual-layer filtering system** that provides bot
422
473
 
423
474
  **Filtering Logic**: `Tool enabled = (Has Permission) AND (Has Category OR No categories specified)`
424
475
 
425
- ### πŸ†• Documentation Categories (Recommended)
476
+ ### Documentation Categories (Recommended)
426
477
 
427
478
  Use these categories for fine-grained control that matches the tool organization:
428
479
 
@@ -450,6 +501,7 @@ Use these categories for fine-grained control that matches the tool organization
450
501
  | `import_export` | 5 | Import/export JSON, CSV, SQL |
451
502
  | `data_migration` | 5 | Copy, move, clone, sync table data |
452
503
  | `schema_migrations` | 9 | Version control for database schema |
504
+ | `analysis` | 3 | AI context optimization and data analysis |
453
505
 
454
506
  ### Legacy Categories (Backward Compatible)
455
507
 
@@ -479,7 +531,7 @@ Use these categories for fine-grained control that matches the tool organization
479
531
  | **Application Backend** | `database_discovery,crud_operations,bulk_operations,custom_queries,transaction_management` | Full app support |
480
532
  | **Development & Testing** | `database_discovery,crud_operations,bulk_operations,custom_queries,schema_management,utilities,transaction_management` | Development access |
481
533
  | **DBA & DevOps** | `database_discovery,schema_management,table_maintenance,backup_restore,schema_migrations,performance_monitoring` | Admin tasks |
482
- | **Full Access** | *(leave empty)* | All 119 tools enabled |
534
+ | **Full Access** | *(leave empty)* | All 120 tools enabled |
483
535
 
484
536
  #### Using Legacy Categories (Backward Compatible)
485
537
 
@@ -492,6 +544,24 @@ Use these categories for fine-grained control that matches the tool organization
492
544
  | **Development** | `list,read,create,update,delete,execute,ddl,transaction,utility` | Full access |
493
545
  | **DBA Tasks** | `list,ddl,utility` | Schema management only |
494
546
 
547
+ ### Adaptive Permission Presets (ReadOnly/Analyst/DBA Lite)
548
+
549
+ Use presets to bootstrap safe defaults. They **merge** with any explicit permissions/categories you pass via CLI args or env vars.
550
+
551
+ | Preset | Permissions | Categories | Ideal for |
552
+ |--------|-------------|------------|-----------|
553
+ | `readonly` | `list,read,utility` | `database_discovery,crud_operations,custom_queries,utilities,import_export,performance_monitoring,analysis` | Safe read-only data access + exports |
554
+ | `analyst` | `list,read,utility` | `database_discovery,crud_operations,custom_queries,utilities,import_export,performance_monitoring,analysis,query_optimization,cache_management,server_management` | Analytics with plan insights and cache/perf visibility |
555
+ | `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, migrations, and maintenance |
556
+
557
+ **Usage**
558
+
559
+ - CLI: `mcp-mysql mysql://user:pass@host:3306/db --preset readonly`
560
+ - CLI with overrides: `mcp-mysql mysql://... --preset analyst "list,read,utility" "performance_monitoring"`
561
+ - Env: `MCP_PRESET=analyst` (or `MCP_PERMISSION_PRESET=analyst`) plus optional `MCP_PERMISSIONS` / `MCP_CATEGORIES` to extend
562
+
563
+ If an unknown preset is requested without overrides, the server falls back to a safe read-only baseline instead of enabling everything.
564
+
495
565
  ### Per-Project Configuration
496
566
 
497
567
  #### Single-Layer: Permissions Only (Backward Compatible)
@@ -582,11 +652,11 @@ Use both 2nd argument (permissions) and 3rd argument (categories):
582
652
 
583
653
  ## Available Tools
584
654
 
585
- The MCP server provides **119 powerful tools** organized into categories:
655
+ The MCP server provides **120 powerful tools** organized into categories:
586
656
 
587
657
  ### Quick Reference
588
658
 
589
- **119 Tools Available** - Organized into 22 categories
659
+ **121 Tools Available** - Organized into 22 categories
590
660
 
591
661
  | Category | Count | Key Tools |
592
662
  |----------|-------|-----------|
@@ -606,12 +676,13 @@ The MCP server provides **119 powerful tools** organized into categories:
606
676
  | Server Management | 9 | `show_process_list`, `explain_query` |
607
677
  | Performance Monitoring | 10 | `get_performance_metrics`, `get_database_health_check` |
608
678
  | Cache | 5 | `get_cache_stats`, `clear_cache` |
609
- | Query Optimization | 2 | `analyze_query`, `get_optimization_hints` |
679
+ | Query Optimization | 3 | `analyze_query`, `get_optimization_hints`, `repair_query` |
610
680
  | Backup & Restore | 5 | `backup_database`, `restore_from_sql` |
611
681
  | Import/Export | 5 | `export_table_to_json`, `import_from_csv` |
612
682
  | Data Migration | 5 | `copy_table_data`, `sync_table_data` |
613
683
  | Schema Migrations | 9 | `create_migration`, `apply_migrations` |
614
684
  | Utilities | 4 | `test_connection`, `export_table_to_csv` |
685
+ | Analysis | 4 | `get_column_statistics`, `get_database_summary`, `get_schema_erd`, `get_schema_rag_context` |
615
686
 
616
687
  > **πŸ“– For detailed tool descriptions, parameters, and examples, see [DOCUMENTATIONS.md](DOCUMENTATIONS.md#πŸ”§-complete-tools-reference)**
617
688
 
package/bin/mcp-mysql.js CHANGED
@@ -10,16 +10,55 @@ const path = require("path");
10
10
  const { spawn } = require("child_process");
11
11
  require("dotenv").config();
12
12
 
13
- // Get MySQL connection string, permissions, and optional categories from command line arguments
14
- const mysqlUrl = process.argv[2];
15
- const permissions = process.argv[3]; // Optional: comma-separated list of permissions (legacy categories)
16
- const categories = process.argv[4]; // Optional: comma-separated list of documentation categories
13
+ // Get MySQL connection string, permissions, categories, and optional preset
14
+ const args = process.argv.slice(2);
15
+ const mysqlUrl = args.shift();
16
+
17
+ let permissions;
18
+ let categories;
19
+ let preset;
20
+
21
+ for (let i = 0; i < args.length; i++) {
22
+ const arg = args[i];
23
+ const normalized = (arg || "").toLowerCase();
24
+
25
+ if (normalized === "--preset") {
26
+ preset = args[i + 1];
27
+ i++;
28
+ continue;
29
+ }
30
+
31
+ if (normalized.startsWith("--preset=")) {
32
+ preset = arg.split("=")[1];
33
+ continue;
34
+ }
35
+
36
+ if (normalized.startsWith("preset:")) {
37
+ preset = arg.split(":")[1];
38
+ continue;
39
+ }
40
+
41
+ if (["readonly", "analyst", "dba-lite", "dba_lite", "dba lite"].includes(normalized)) {
42
+ preset = arg;
43
+ continue;
44
+ }
45
+
46
+ if (permissions === undefined) {
47
+ permissions = arg;
48
+ continue;
49
+ }
50
+
51
+ if (categories === undefined) {
52
+ categories = arg;
53
+ continue;
54
+ }
55
+ }
17
56
 
18
57
  if (!mysqlUrl) {
19
58
  console.error("Error: MySQL connection URL is required");
20
- console.error(
21
- "Usage: mcp-mysql mysql://user:password@host:port/dbname [permissions] [categories]",
22
- );
59
+ console.error(
60
+ "Usage: mcp-mysql mysql://user:password@host:port/dbname [permissions] [categories] [--preset <name>]",
61
+ );
23
62
  console.error("");
24
63
  console.error("Examples:");
25
64
  console.error(" # All tools enabled (no filtering)");
@@ -33,9 +72,17 @@ if (!mysqlUrl) {
33
72
  console.error(
34
73
  " # Dual-layer: Permissions + Categories (fine-grained control)",
35
74
  );
36
- console.error(
37
- ' mcp-mysql mysql://root:pass@localhost:3306/mydb "list,read,utility" "database_discovery,performance_monitoring"',
38
- );
75
+ console.error(
76
+ ' mcp-mysql mysql://root:pass@localhost:3306/mydb "list,read,utility" "database_discovery,performance_monitoring"',
77
+ );
78
+ console.error("");
79
+ console.error(" # Adaptive presets (auto-merge with overrides)");
80
+ console.error(
81
+ ' mcp-mysql mysql://root:pass@localhost:3306/mydb --preset readonly',
82
+ );
83
+ console.error(
84
+ ' mcp-mysql mysql://root:pass@localhost:3306/mydb --preset analyst "performance_monitoring"',
85
+ );
39
86
  console.error("");
40
87
  console.error("Permissions (Layer 1 - Broad Control):");
41
88
  console.error(
@@ -58,20 +105,26 @@ if (!mysqlUrl) {
58
105
  console.error(
59
106
  " performance_monitoring, cache_management, query_optimization,",
60
107
  );
61
- console.error(
62
- " backup_restore, import_export, data_migration, schema_migrations",
63
- );
64
- console.error("");
65
- console.error("Filtering Logic:");
108
+ console.error(
109
+ " backup_restore, import_export, data_migration, schema_migrations",
110
+ );
111
+ console.error("");
112
+ console.error("Filtering Logic:");
66
113
  console.error(
67
114
  " - If only permissions: All tools within those permissions enabled",
68
115
  );
69
- console.error(
70
- " - If permissions + categories: Only tools matching BOTH layers enabled",
71
- );
72
- console.error(" - If nothing specified: All 119 tools enabled");
73
- process.exit(1);
74
- }
116
+ console.error(
117
+ " - If permissions + categories: Only tools matching BOTH layers enabled",
118
+ );
119
+ console.error(" - If nothing specified: All 119 tools enabled");
120
+ console.error("");
121
+ console.error("Presets:");
122
+ console.error(" readonly, analyst, dba-lite");
123
+ console.error(
124
+ " Presets merge with provided permissions/categories so you can add project-specific overrides.",
125
+ );
126
+ process.exit(1);
127
+ }
75
128
 
76
129
  // Parse the MySQL URL to extract connection details
77
130
  let connectionConfig;
@@ -115,24 +168,39 @@ const dbMessage = database
115
168
  ? `${connectionConfig.host}:${connectionConfig.port}/${database}`
116
169
  : `${connectionConfig.host}:${connectionConfig.port} (no specific database selected)`;
117
170
 
118
- // Set permissions/categories as environment variables if provided
119
- if (permissions) {
120
- process.env.MCP_PERMISSIONS = permissions;
121
- console.error(`Permissions (Layer 1): ${permissions}`);
122
- }
123
-
124
- if (categories) {
125
- process.env.MCP_CATEGORIES = categories;
126
- console.error(`Categories (Layer 2): ${categories}`);
127
- }
128
-
129
- if (!permissions && !categories) {
130
- console.error("Access Control: All tools enabled (no filtering)");
131
- } else if (permissions && !categories) {
132
- console.error("Filtering Mode: Permission-based only");
133
- } else if (permissions && categories) {
134
- console.error("Filtering Mode: Dual-layer (Permissions + Categories)");
135
- }
171
+ // Set permissions/categories/preset as environment variables if provided
172
+ if (permissions) {
173
+ process.env.MCP_PERMISSIONS = permissions;
174
+ console.error(`Permissions (Layer 1): ${permissions}`);
175
+ }
176
+
177
+ if (categories) {
178
+ process.env.MCP_CATEGORIES = categories;
179
+ console.error(`Categories (Layer 2): ${categories}`);
180
+ }
181
+
182
+ if (preset) {
183
+ process.env.MCP_PRESET = preset;
184
+ console.error(`Permission preset: ${preset}`);
185
+ }
186
+
187
+ if (!permissions && !categories && !preset) {
188
+ console.error("Access Control: All tools enabled (no filtering)");
189
+ } else if (preset && !permissions && !categories) {
190
+ console.error("Filtering Mode: Preset-based (auto permissions + categories)");
191
+ } else if (permissions && categories) {
192
+ console.error(
193
+ `Filtering Mode: Dual-layer (Permissions + Categories${preset ? ", preset merged" : ""})`,
194
+ );
195
+ } else if (permissions && !categories) {
196
+ console.error(
197
+ `Filtering Mode: Permission-based only${preset ? " (preset merged)" : ""}`,
198
+ );
199
+ } else if (!permissions && categories) {
200
+ console.error(
201
+ `Filtering Mode: Category-only${preset ? " (preset merged)" : ""}`,
202
+ );
203
+ }
136
204
 
137
205
  // Log to stderr (not stdout, which is used for MCP protocol)
138
206
  console.error(`Starting MySQL MCP server with connection to ${dbMessage}`);