@berthojoris/mcp-mysql-server 1.10.5 → 1.12.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
@@ -2,18 +2,36 @@
2
2
 
3
3
  All notable changes to the MySQL MCP Server will be documented in this file.
4
4
 
5
- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
- and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
-
8
- ## [1.10.5] - 2025-12-02
9
-
10
- ### Changed
11
- - Removed queryLog field from all tool responses - simplified response structure
12
- - Updated source code to remove query logging output from tool responses
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [1.12.0] - 2025-12-05
9
+
10
+ ### Added
11
+ - Schema-Aware RAG Context Pack via `get_schema_rag_context`, delivering compact table/column/PK/FK snapshots with row estimates for embeddings-friendly prompts.
12
+
13
+ ### Fixed
14
+ - Exposed analysis tools (`get_database_summary`, `get_schema_erd`, `get_column_statistics`) and the new RAG context pack through MCP tool registration and routing.
15
+
16
+ ### Changed
17
+ - Updated documentation and tool counts to 120, reflecting the new analysis capability and refreshed README guidance.
18
+
19
+ ## [1.10.5] - 2025-12-02
20
+
21
+ ### Changed
22
+ - Removed queryLog field from all tool responses - simplified response structure
23
+ - Updated source code to remove query logging output from tool responses
13
24
  - Streamlined tool response format for cleaner API interaction
14
25
 
15
26
  ## [1.10.4] - 2025-12-02
16
27
 
28
+ ### Added
29
+ - **AI Context Optimization** - Added 4 new AI-centric tools:
30
+ - `get_database_summary` - High-level database overview (tables, columns, row counts) optimized for context window
31
+ - `get_schema_erd` - Generates Mermaid.js ER diagrams for visual schema representation
32
+ - `get_column_statistics` - Deep data profiling (min/max, nulls, distinct counts) for intelligent query building
33
+ - `run_query` Safe Mode - Added `dry_run` flag to preview query plans and costs without execution
34
+
17
35
  ### Fixed
18
36
  - Removed "IMPORTANT_INSTRUCTION_TO_ASSISTANT" instruction from documentation - no longer needed
19
37
  - Removed "SQL_QUERY_EXECUTED" message references from documentation - simplified response structure
@@ -467,11 +485,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
467
485
  - Direct access to `mysql`, `performance_schema`, `sys` databases
468
486
  - `USER` / `PASSWORD` manipulation
469
487
 
470
- ## [1.4.3] - 2025-01-06
471
-
472
- ### Added
473
- - Improved permission error handling with detailed messages
474
- - Enhanced documentation for permission system
488
+ ## [1.11.0] - 2025-12-05
489
+
490
+ ### Added
491
+ - Adaptive permission presets (`readonly`, `analyst`, `dba-lite`) with mergeable overrides
492
+ - CLI `--preset` flag and `MCP_PRESET`/`MCP_PERMISSION_PRESET` env support with resolved-config logging
493
+
494
+ ### Changed
495
+ - Safe fallback to read-only defaults when an unknown preset is requested without overrides
496
+ - Feature status endpoint now exposes preset-aware configuration snapshots for easier debugging
497
+
498
+ ## [1.4.3] - 2025-01-06
499
+
500
+ ### Added
501
+ - Improved permission error handling with detailed messages
502
+ - Enhanced documentation for permission system
475
503
 
476
504
  ### Fixed
477
505
  - Fixed undefined/null parameter handling in all tool calls
@@ -510,11 +538,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
510
538
 
511
539
  ---
512
540
 
513
- ## Version History Summary
514
-
515
- - **1.9.0** - Schema Versioning & Migrations (9 new tools), MCP integration for 12 AI tools
516
- - **1.8.0** - Data Migration Tools
517
- - **1.7.0** - Database Backup/Restore, Data Import/Export
541
+ ## Version History Summary
542
+
543
+ - **1.11.0** - Adaptive permission presets with CLI/env support and preset-aware logging
544
+ - **1.9.0** - Schema Versioning & Migrations (9 new tools), MCP integration for 12 AI tools
545
+ - **1.8.0** - Data Migration Tools
546
+ - **1.7.0** - Database Backup/Restore, Data Import/Export
518
547
  - **1.6.3** - Fixed missing tools in toolCategoryMap, security keyword refinement
519
548
  - **1.6.2** - Fixed security keyword false positive bug
520
549
  - **1.4.16** - Added get_table_size tool to manifest
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)
@@ -37,7 +37,7 @@ This file contains detailed documentation for all features of the MySQL MCP Serv
37
37
 
38
38
  ---
39
39
 
40
- ## 🆕 Dual-Layer Filtering System
40
+ ## Dual-Layer Filtering System
41
41
 
42
42
  Control which database operations are available to AI using a **dual-layer filtering system**:
43
43
 
@@ -71,7 +71,8 @@ schema_management,utilities,transaction_management,stored_procedures,
71
71
  views_management,triggers_management,functions_management,index_management,
72
72
  constraint_management,table_maintenance,server_management,
73
73
  performance_monitoring,cache_management,query_optimization,
74
- backup_restore,import_export,data_migration,schema_migrations
74
+ backup_restore,import_export,data_migration,schema_migrations,
75
+ analysis
75
76
  ```
76
77
 
77
78
  ### Configuration Examples
@@ -194,6 +195,24 @@ Data operations without schema changes:
194
195
 
195
196
  **Enabled**: Full data CRUD + bulk ops + transactions - NO schema changes (no `ddl` permission).
196
197
 
198
+ ### Adaptive Permission Presets (ReadOnly/Analyst/DBA Lite)
199
+
200
+ Preset bundles provide safe starting points and **merge** with any explicit permissions/categories you pass (CLI args or env vars).
201
+
202
+ | Preset | Permissions | Categories | Intended Use |
203
+ |--------|-------------|------------|--------------|
204
+ | `readonly` | `list,read,utility` | `database_discovery,crud_operations,custom_queries,utilities,import_export,performance_monitoring,analysis` | Safe read-only access, exports, and diagnostics |
205
+ | `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 |
206
+ | `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 |
207
+
208
+ **Usage**
209
+
210
+ - CLI: `mcp-mysql mysql://user:pass@host:3306/db --preset readonly`
211
+ - CLI with overrides: `mcp-mysql mysql://... --preset analyst "list,read,utility" "performance_monitoring"`
212
+ - Env: `MCP_PRESET=analyst` (or `MCP_PERMISSION_PRESET=analyst`) and optionally extend with `MCP_PERMISSIONS` / `MCP_CATEGORIES`
213
+
214
+ 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.
215
+
197
216
  ### Permissions Reference (Layer 1)
198
217
 
199
218
  | Permission | Operations Allowed | Example Tools |
@@ -222,7 +241,7 @@ The system uses both arguments to determine access:
222
241
  - **3rd argument**: Categories (Layer 2, optional) - comma-separated documentation categories
223
242
 
224
243
  **Decision logic**:
225
- 1. If no arguments: All 119 tools enabled
244
+ 1. If no arguments: All 120 tools enabled
226
245
  2. If only 2nd argument (permissions): Tools enabled if they match permission
227
246
  3. If both arguments: Tools enabled if they match BOTH permission AND category
228
247
 
@@ -267,7 +286,7 @@ Add 'bulk_operations' to the categories argument.
267
286
 
268
287
  ## 🔧 Complete Tools Reference
269
288
 
270
- This section provides a comprehensive reference of all 119 available tools organized by category.
289
+ This section provides a comprehensive reference of all 120 available tools organized by category.
271
290
 
272
291
  ### Database Discovery
273
292
 
@@ -498,6 +517,21 @@ This section provides a comprehensive reference of all 119 available tools organ
498
517
  | `reset_failed_migration` | Reset failed migration to pending | `ddl` |
499
518
  | `generate_migration_from_diff` | Generate migration from table diff | `ddl` |
500
519
 
520
+ ### AI Context & Analysis Tools
521
+
522
+ | Tool | Description | Requires |
523
+ |------|-------------|----------|
524
+ | `get_database_summary` | High-level overview (tables, columns, rows) for AI context | `list` |
525
+ | `get_schema_erd` | Generate Mermaid.js ER diagram for visualization | `list` |
526
+ | `get_schema_rag_context` | Condensed schema snapshot (tables, PK/FK, row estimates) for RAG prompts | `list` |
527
+ | `get_column_statistics` | Profile data (min, max, nulls, distinct) for analysis | `read` |
528
+
529
+ #### Schema-Aware RAG Context Pack
530
+ - Purpose-built for embeddings: returns a `context_text` block plus structured `tables` and `relationships` so agents can self-orient without pulling a full ERD.
531
+ - 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.
532
+ - Safety: respects the connected database only—cannot introspect other schemas—and notes when tables/columns are truncated.
533
+ - Output includes per-table PKs, FK targets, nullable flags, and approximate row counts from `INFORMATION_SCHEMA.TABLES` (InnoDB estimates).
534
+
501
535
  ---
502
536
 
503
537
  ## 🏗️ DDL Operations
@@ -4018,16 +4052,6 @@ MIT License - see [LICENSE](LICENSE) file for details.
4018
4052
  - ✅ **Data export/import utilities** (CSV, JSON, SQL dumps) - **COMPLETED!**
4019
4053
  - ✅ **Data migration utilities** - **COMPLETED!**
4020
4054
  - ✅ **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
4055
 
4032
4056
  ### Recommended Implementation Order
4033
4057
 
@@ -4041,19 +4065,10 @@ MIT License - see [LICENSE](LICENSE) file for details.
4041
4065
  - ✅ **Database backup and restore tools** - Essential for production data safety - **COMPLETED!**
4042
4066
  - ✅ **Data migration utilities** - Move data between databases and environments - **COMPLETED!**
4043
4067
  - ✅ **Enhanced export/import** - Support for JSON, SQL dump formats - **COMPLETED!**
4044
- - [ ] **Query history & analytics** - Track and analyze database usage patterns
4045
4068
 
4046
4069
  #### **Phase 3: Enterprise Features** 🏢
4047
- - [ ] **Audit logging and compliance** - Track all database operations for security
4048
4070
  - ✅ **Schema versioning and migrations** - Version control for database schema changes - **COMPLETED!**
4049
4071
  - ✅ **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
4072
 
4058
4073
  #### **Implementation Priority Matrix**
4059
4074
 
@@ -4073,8 +4088,21 @@ MIT License - see [LICENSE](LICENSE) file for details.
4073
4088
  | Data Migration | High | High | 12 | ✅ COMPLETED |
4074
4089
  | Schema Versioning | Medium | Medium | 13 | ✅ COMPLETED |
4075
4090
  | Performance Monitoring | High | Medium | 14 | ✅ COMPLETED |
4076
- | PostgreSQL Adapter | High | High | 15 | Pending |
4077
- | Audit Logging | Medium | Low | 16 | Pending |
4091
+
4092
+ #### **Proposed Enhancements (AI Productivity)**
4093
+
4094
+ | Feature | Impact | Effort | Priority | Status |
4095
+ |---------|--------|--------|----------|--------|
4096
+ | Adaptive Permission Presets (ReadOnly/Analyst/DBA Lite) | High | Medium | 1 | ✅ Completed |
4097
+ | Schema-Aware RAG Context Pack | High | Medium | 2 | ✅ Completed |
4098
+ | Guided Query Builder/Fixer (Intent → Safe SQL + EXPLAIN Repair) | High | Medium | 3 | Planned |
4099
+ | Drift & Migration Assistant (Schema diff + risk summary) | High | High | 4 | Planned |
4100
+ | Safety Sandbox Mode (runQuery dry-run/EXPLAIN-only) | Medium | Low | 5 | Planned |
4101
+ | Anomaly & Slow-Query Watcher | Medium | Medium | 6 | Planned |
4102
+ | Data Masking Profiles for Responses | Medium | Medium | 7 | Planned |
4103
+ | Workflow Macros (e.g., safe_export_table) | Medium | Low | 8 | Planned |
4104
+ | Agent-Facing Changelog Feed | Medium | Low | 9 | Planned |
4105
+ | Connection Profiles (dev/stage/prod with allow/deny) | High | Low | 10 | Planned |
4078
4106
 
4079
4107
  ---
4080
4108
 
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
+ | **120 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
+ **120 Tools Available** - Organized into 22 categories
590
660
 
591
661
  | Category | Count | Key Tools |
592
662
  |----------|-------|-----------|
@@ -612,6 +682,7 @@ The MCP server provides **119 powerful tools** organized into categories:
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}`);
@@ -39,7 +39,17 @@ export declare enum DocCategory {
39
39
  BACKUP_RESTORE = "backup_restore",
40
40
  IMPORT_EXPORT = "import_export",
41
41
  DATA_MIGRATION = "data_migration",
42
- SCHEMA_MIGRATIONS = "schema_migrations"
42
+ SCHEMA_MIGRATIONS = "schema_migrations",
43
+ ANALYSIS = "analysis"
44
+ }
45
+ /**
46
+ * Permission preset bundles for faster, safer configuration
47
+ */
48
+ export interface PermissionPreset {
49
+ name: string;
50
+ description: string;
51
+ permissions: ToolCategory[];
52
+ categories: DocCategory[];
43
53
  }
44
54
  /**
45
55
  * Map of tool names to their legacy categories
@@ -61,7 +71,17 @@ export declare class FeatureConfig {
61
71
  private originalPermissionsString;
62
72
  private originalCategoriesString;
63
73
  private useDualLayer;
64
- constructor(permissionsStr?: string, categoriesStr?: string);
74
+ private activePreset?;
75
+ private presetName?;
76
+ constructor(permissionsStr?: string, categoriesStr?: string, presetName?: string);
77
+ /**
78
+ * Normalize and merge preset + user-supplied configuration lists
79
+ */
80
+ private mergeConfigStrings;
81
+ /**
82
+ * Resolve a preset name to its configuration
83
+ */
84
+ private resolvePreset;
65
85
  /**
66
86
  * Parse permissions and categories for dual-layer filtering
67
87
  * Layer 1 (permissions): Broad control using legacy categories
@@ -71,7 +91,7 @@ export declare class FeatureConfig {
71
91
  /**
72
92
  * Update configuration at runtime
73
93
  */
74
- setConfig(permissionsStr: string, categoriesStr?: string): void;
94
+ setConfig(permissionsStr: string, categoriesStr?: string, presetName?: string): void;
75
95
  /**
76
96
  * Check if a specific tool is enabled
77
97
  * Dual-layer logic:
@@ -111,6 +131,24 @@ export declare class FeatureConfig {
111
131
  * Check if using dual-layer filtering mode
112
132
  */
113
133
  isUsingDualLayer(): boolean;
134
+ /**
135
+ * Get the active preset (if any)
136
+ */
137
+ getActivePreset(): PermissionPreset | undefined;
138
+ /**
139
+ * Snapshot of the resolved configuration for logging/telemetry
140
+ */
141
+ getConfigSnapshot(): {
142
+ preset?: {
143
+ name: string;
144
+ description: string;
145
+ };
146
+ permissions: string;
147
+ categories: string;
148
+ filteringMode: string;
149
+ enabledLegacy: ToolCategory[];
150
+ enabledDoc: DocCategory[];
151
+ };
114
152
  /**
115
153
  * Get filtering mode description
116
154
  */