@berthojoris/mcp-mysql-server 1.16.2 → 1.16.4
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 +23 -0
- package/DOCUMENTATIONS.md +86 -4
- package/README.md +33 -7
- package/dist/config/featureConfig.js +8 -0
- package/dist/index.d.ts +112 -0
- package/dist/index.js +27 -0
- package/dist/mcp-server.js +121 -0
- package/dist/tools/indexRecommendationTools.d.ts +50 -0
- package/dist/tools/indexRecommendationTools.js +451 -0
- package/dist/tools/schemaDesignTools.d.ts +67 -0
- package/dist/tools/schemaDesignTools.js +359 -0
- package/dist/tools/securityAuditTools.d.ts +39 -0
- package/dist/tools/securityAuditTools.js +319 -0
- package/manifest.json +81 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,29 @@ 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.16.4] - 2025-12-12
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- **Phase 2: AI Enhancement Tools** - 3 new tools to improve AI-assisted database engineering:
|
|
12
|
+
- `design_schema_from_requirements` - Natural-language schema design assistant that proposes tables, relationships, and DDL (non-executing)
|
|
13
|
+
- `audit_database_security` - Best-effort database security audit assistant with prioritized findings and recommendations
|
|
14
|
+
- `recommend_indexes` - Automated index recommendation system using performance_schema query digests and existing index introspection
|
|
15
|
+
|
|
16
|
+
### Documentation
|
|
17
|
+
- Updated README.md and DOCUMENTATIONS.md to include the new Phase 2 AI Enhancement tools.
|
|
18
|
+
|
|
19
|
+
## [1.16.3] - 2025-12-11
|
|
20
|
+
|
|
21
|
+
### Documentation
|
|
22
|
+
- **README.md Enhancement** - Added comprehensive AI Enhancement tools documentation
|
|
23
|
+
- Updated total tool count from 134 to 142 tools
|
|
24
|
+
- Added detailed "🤖 AI Enhancement Tools (Phase 1 - Implemented)" section
|
|
25
|
+
- Listed all 8 AI tools in Available Tools table with full names
|
|
26
|
+
- Included practical use cases for each AI tool category
|
|
27
|
+
- Tools documented: `build_query_from_intent`, `suggest_query_improvements`, `smart_search`,
|
|
28
|
+
`find_similar_columns`, `discover_data_patterns`, `generate_documentation`,
|
|
29
|
+
`generate_data_dictionary`, `generate_business_glossary`
|
|
30
|
+
|
|
8
31
|
## [1.16.2] - 2025-12-11
|
|
9
32
|
|
|
10
33
|
### Fixed
|
package/DOCUMENTATIONS.md
CHANGED
|
@@ -7,7 +7,7 @@ This file contains detailed documentation for all features of the MySQL MCP Serv
|
|
|
7
7
|
## Table of Contents
|
|
8
8
|
|
|
9
9
|
1. [Category Filtering System](#🆕-category-filtering-system) - NEW!
|
|
10
|
-
2. [🔧 Complete Tools Reference](#🔧-complete-tools-reference) - All
|
|
10
|
+
2. [🔧 Complete Tools Reference](#🔧-complete-tools-reference) - All 145 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)
|
|
@@ -240,7 +240,7 @@ The system uses both arguments to determine access:
|
|
|
240
240
|
- **3rd argument**: Categories (Layer 2, optional) - comma-separated documentation categories
|
|
241
241
|
|
|
242
242
|
**Decision logic**:
|
|
243
|
-
1. If no arguments: All
|
|
243
|
+
1. If no arguments: All 145 tools enabled
|
|
244
244
|
2. If only 2nd argument (permissions): Tools enabled if they match permission
|
|
245
245
|
3. If both arguments: Tools enabled if they match BOTH permission AND category
|
|
246
246
|
|
|
@@ -285,7 +285,7 @@ Add 'bulk_operations' to the categories argument.
|
|
|
285
285
|
|
|
286
286
|
## 🔧 Complete Tools Reference
|
|
287
287
|
|
|
288
|
-
This section provides a comprehensive reference of all
|
|
288
|
+
This section provides a comprehensive reference of all 145 available tools organized by category.
|
|
289
289
|
|
|
290
290
|
### Database Discovery
|
|
291
291
|
|
|
@@ -3005,7 +3005,7 @@ Reset Performance Schema statistics to start fresh monitoring.
|
|
|
3005
3005
|
|
|
3006
3006
|
## 🤖 AI Enhancement Tools
|
|
3007
3007
|
|
|
3008
|
-
The AI Enhancement tools provide intelligent, AI-powered features for database exploration, query generation, and
|
|
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.
|
|
3009
3009
|
|
|
3010
3010
|
### Tool Overview
|
|
3011
3011
|
|
|
@@ -3019,6 +3019,9 @@ The AI Enhancement tools provide intelligent, AI-powered features for database e
|
|
|
3019
3019
|
| `generate_documentation` | Generates comprehensive database documentation | `ai_enhancement` |
|
|
3020
3020
|
| `generate_data_dictionary` | Creates detailed data dictionaries for tables | `ai_enhancement` |
|
|
3021
3021
|
| `generate_business_glossary` | Builds business glossaries from column names | `ai_enhancement` |
|
|
3022
|
+
| `design_schema_from_requirements` | Designs a proposed schema and outputs DDL from natural language requirements | `ai_enhancement` |
|
|
3023
|
+
| `audit_database_security` | Audits MySQL security configuration and (optionally) accounts/privileges | `ai_enhancement` |
|
|
3024
|
+
| `recommend_indexes` | Suggests concrete CREATE INDEX statements from observed query patterns | `ai_enhancement` |
|
|
3022
3025
|
|
|
3023
3026
|
### Intelligent Query Assistant
|
|
3024
3027
|
|
|
@@ -3081,6 +3084,85 @@ Analyzes a SQL query and provides suggestions for optimization.
|
|
|
3081
3084
|
- `memory` - Focuses on memory usage optimization
|
|
3082
3085
|
- `readability` - Suggests formatting and clarity improvements
|
|
3083
3086
|
|
|
3087
|
+
### Schema Design
|
|
3088
|
+
|
|
3089
|
+
#### `design_schema_from_requirements`
|
|
3090
|
+
|
|
3091
|
+
Design a proposed schema (tables, columns, relationships) from business requirements and output suggested DDL. This tool **does not execute** any DDL.
|
|
3092
|
+
|
|
3093
|
+
```javascript
|
|
3094
|
+
{
|
|
3095
|
+
"tool": "design_schema_from_requirements",
|
|
3096
|
+
"arguments": {
|
|
3097
|
+
"requirements_text": "We need to manage customers and orders. A customer has many orders. Orders have total_amount and order_date.",
|
|
3098
|
+
"naming_convention": "snake_case",
|
|
3099
|
+
"include_audit_columns": true,
|
|
3100
|
+
"id_type": "BIGINT"
|
|
3101
|
+
}
|
|
3102
|
+
}
|
|
3103
|
+
|
|
3104
|
+
// With explicit entity hints to improve accuracy
|
|
3105
|
+
{
|
|
3106
|
+
"tool": "design_schema_from_requirements",
|
|
3107
|
+
"arguments": {
|
|
3108
|
+
"requirements_text": "Basic e-commerce",
|
|
3109
|
+
"entities": [
|
|
3110
|
+
{ "name": "customers", "fields": ["email", "name"] },
|
|
3111
|
+
{ "name": "orders", "fields": ["total_amount", "order_date"] }
|
|
3112
|
+
]
|
|
3113
|
+
}
|
|
3114
|
+
}
|
|
3115
|
+
```
|
|
3116
|
+
|
|
3117
|
+
**Response includes:**
|
|
3118
|
+
- Proposed tables + columns (with inferred types)
|
|
3119
|
+
- Inferred relationships (FK suggestions)
|
|
3120
|
+
- `ddl_statements` array with CREATE TABLE / CREATE INDEX suggestions
|
|
3121
|
+
|
|
3122
|
+
### Security Audit
|
|
3123
|
+
|
|
3124
|
+
#### `audit_database_security`
|
|
3125
|
+
|
|
3126
|
+
Runs a best-effort security audit using read-only inspection queries (e.g., `SHOW VARIABLES`, and optionally `mysql.user` / `INFORMATION_SCHEMA` where permitted).
|
|
3127
|
+
|
|
3128
|
+
```javascript
|
|
3129
|
+
{
|
|
3130
|
+
"tool": "audit_database_security",
|
|
3131
|
+
"arguments": {
|
|
3132
|
+
"include_user_account_checks": true,
|
|
3133
|
+
"include_privilege_checks": true
|
|
3134
|
+
}
|
|
3135
|
+
}
|
|
3136
|
+
```
|
|
3137
|
+
|
|
3138
|
+
**Response includes:**
|
|
3139
|
+
- Prioritized findings with severities and recommendations
|
|
3140
|
+
- Summary counts by severity
|
|
3141
|
+
- Notes when checks are skipped due to missing privileges
|
|
3142
|
+
|
|
3143
|
+
### Index Recommendations
|
|
3144
|
+
|
|
3145
|
+
#### `recommend_indexes`
|
|
3146
|
+
|
|
3147
|
+
Analyzes `performance_schema` digests to propose concrete indexing strategies.
|
|
3148
|
+
|
|
3149
|
+
```javascript
|
|
3150
|
+
{
|
|
3151
|
+
"tool": "recommend_indexes",
|
|
3152
|
+
"arguments": {
|
|
3153
|
+
"max_query_patterns": 25,
|
|
3154
|
+
"min_execution_count": 10,
|
|
3155
|
+
"min_avg_time_ms": 5,
|
|
3156
|
+
"max_recommendations": 20,
|
|
3157
|
+
"include_unused_index_warnings": true
|
|
3158
|
+
}
|
|
3159
|
+
}
|
|
3160
|
+
```
|
|
3161
|
+
|
|
3162
|
+
**Notes:**
|
|
3163
|
+
- Requires `performance_schema` enabled and accessible by the MySQL user.
|
|
3164
|
+
- Always validate recommendations with `EXPLAIN` and production-like testing.
|
|
3165
|
+
|
|
3084
3166
|
### Smart Data Discovery
|
|
3085
3167
|
|
|
3086
3168
|
#### `smart_search`
|
package/README.md
CHANGED
|
@@ -49,7 +49,7 @@ Add to your AI agent config (`.mcp.json`, `.cursor/mcp.json`, etc.):
|
|
|
49
49
|
- [Environment Variables](#environment-variables-configuration)
|
|
50
50
|
- [Local Development](#local-path-configuration)
|
|
51
51
|
- [Permission System](#permission-system)
|
|
52
|
-
- [Available Tools (
|
|
52
|
+
- [Available Tools (145 total)](#available-tools)
|
|
53
53
|
- [Documentation](DOCUMENTATIONS.md)
|
|
54
54
|
- [Comparison: MCP vs Manual Access](#mysql-mcp-vs-manual-database-access)
|
|
55
55
|
- [License](#license)
|
|
@@ -496,7 +496,7 @@ Use these categories for fine-grained control that matches the tool organization
|
|
|
496
496
|
| `data_migration` | 5 | Copy, move, clone, sync table data |
|
|
497
497
|
| `schema_migrations` | 9 | Version control for database schema |
|
|
498
498
|
| `analysis` | 4 | AI context optimization and data analysis |
|
|
499
|
-
| `ai_enhancement` |
|
|
499
|
+
| `ai_enhancement` | 11 | AI-powered query building, smart discovery, documentation, schema design, security audit, and index recommendations |
|
|
500
500
|
|
|
501
501
|
### Legacy Categories (Backward Compatible)
|
|
502
502
|
|
|
@@ -526,7 +526,7 @@ Use these categories for fine-grained control that matches the tool organization
|
|
|
526
526
|
| **Application Backend** | `database_discovery,crud_operations,bulk_operations,custom_queries,transaction_management` | Full app support |
|
|
527
527
|
| **Development & Testing** | `database_discovery,crud_operations,bulk_operations,custom_queries,schema_management,utilities,transaction_management` | Development access |
|
|
528
528
|
| **DBA & DevOps** | `database_discovery,schema_management,table_maintenance,backup_restore,schema_migrations,performance_monitoring` | Admin tasks |
|
|
529
|
-
| **Full Access** | *(leave empty)* | All
|
|
529
|
+
| **Full Access** | *(leave empty)* | All 145 tools enabled |
|
|
530
530
|
|
|
531
531
|
#### Using Legacy Categories (Backward Compatible)
|
|
532
532
|
|
|
@@ -647,11 +647,11 @@ Use both 2nd argument (permissions) and 3rd argument (categories):
|
|
|
647
647
|
|
|
648
648
|
## Available Tools
|
|
649
649
|
|
|
650
|
-
The MCP server provides **
|
|
650
|
+
The MCP server provides **145 powerful tools** organized into 23 categories:
|
|
651
651
|
|
|
652
652
|
### Quick Reference
|
|
653
653
|
|
|
654
|
-
**
|
|
654
|
+
**145 Tools Available** - Organized into 23 categories
|
|
655
655
|
|
|
656
656
|
| Category | Count | Key Tools |
|
|
657
657
|
|----------|-------|-----------|
|
|
@@ -678,7 +678,33 @@ The MCP server provides **134 powerful tools** organized into 23 categories:
|
|
|
678
678
|
| Schema Migrations | 9 | `create_migration`, `apply_migrations` |
|
|
679
679
|
| Utilities | 4 | `test_connection`, `export_table_to_csv` |
|
|
680
680
|
| Analysis | 4 | `get_column_statistics`, `get_database_summary`, `get_schema_erd` |
|
|
681
|
-
| **AI Enhancement** |
|
|
681
|
+
| **AI Enhancement** | 11 | `build_query_from_intent`, `suggest_query_improvements`, `smart_search`, `find_similar_columns`, `discover_data_patterns`, `generate_documentation`, `generate_data_dictionary`, `generate_business_glossary`, `design_schema_from_requirements`, `audit_database_security`, `recommend_indexes` |
|
|
682
|
+
|
|
683
|
+
### 🤖 AI Enhancement Tools (Phase 1-2 - Implemented)
|
|
684
|
+
|
|
685
|
+
The MySQL MCP server includes advanced AI-powered productivity tools:
|
|
686
|
+
|
|
687
|
+
#### **Intelligent Query Assistant**
|
|
688
|
+
- **`build_query_from_intent`** - Converts natural language to optimized SQL queries
|
|
689
|
+
- **`suggest_query_improvements`** - AI-powered query optimization suggestions
|
|
690
|
+
- *Use case: "Show me active users from last month" → Automatically generates SQL*
|
|
691
|
+
|
|
692
|
+
#### **Smart Data Discovery Agent**
|
|
693
|
+
- **`smart_search`** - Semantic search for tables, columns, and data patterns
|
|
694
|
+
- **`find_similar_columns`** - Discover columns with similar names or data patterns
|
|
695
|
+
- **`discover_data_patterns`** - Automatic identification of data patterns and relationships
|
|
696
|
+
- *Use case: Find all customer-related columns across hundreds of tables*
|
|
697
|
+
|
|
698
|
+
#### **AI-Powered Documentation Generator**
|
|
699
|
+
- **`generate_documentation`** - Automatic database documentation with business glossary
|
|
700
|
+
- **`generate_data_dictionary`** - Interactive data dictionaries with examples
|
|
701
|
+
- **`generate_business_glossary`** - Business terminology mapping to technical fields
|
|
702
|
+
- *Use case: Generate complete documentation for a new database in seconds*
|
|
703
|
+
|
|
704
|
+
#### **Schema + Security + Indexing (Phase 2)**
|
|
705
|
+
- **`design_schema_from_requirements`** - Generate proposed tables, relationships, and DDL from business requirements
|
|
706
|
+
- **`audit_database_security`** - Best-effort MySQL security audit with prioritized findings
|
|
707
|
+
- **`recommend_indexes`** - Concrete index recommendations from observed query patterns (performance_schema)
|
|
682
708
|
|
|
683
709
|
> **📖 For detailed tool descriptions, parameters, and examples, see [DOCUMENTATIONS.md](DOCUMENTATIONS.md#🔧-complete-tools-reference)**
|
|
684
710
|
|
|
@@ -696,7 +722,7 @@ For comprehensive documentation, see **[DOCUMENTATIONS.md](DOCUMENTATIONS.md)**:
|
|
|
696
722
|
- **Schema Versioning** - Version control for database schema changes
|
|
697
723
|
- **Transaction Management** - ACID transactions
|
|
698
724
|
- **Stored Procedures** - Create and execute with IN/OUT/INOUT parameters
|
|
699
|
-
-
|
|
725
|
+
- **🤖 AI Enhancement** - Natural language to SQL, smart data discovery, schema design, security audit, and index recommendations (Phase 1-2)
|
|
700
726
|
- **Query Logging** - See all SQL queries executed automatically
|
|
701
727
|
- **Security Features** - Built-in security and best practices
|
|
702
728
|
- **Bulk Operations** - High-performance batch processing
|
|
@@ -321,6 +321,10 @@ exports.toolCategoryMap = {
|
|
|
321
321
|
generateDocumentation: ToolCategory.UTILITY,
|
|
322
322
|
generateDataDictionary: ToolCategory.UTILITY,
|
|
323
323
|
generateBusinessGlossary: ToolCategory.UTILITY,
|
|
324
|
+
// Phase 2: AI Enhancement Tools
|
|
325
|
+
designSchemaFromRequirements: ToolCategory.UTILITY,
|
|
326
|
+
auditDatabaseSecurity: ToolCategory.UTILITY,
|
|
327
|
+
recommendIndexes: ToolCategory.UTILITY,
|
|
324
328
|
};
|
|
325
329
|
/**
|
|
326
330
|
* Map of tool names to their documentation categories (New Enhanced System)
|
|
@@ -483,6 +487,10 @@ exports.toolDocCategoryMap = {
|
|
|
483
487
|
generateDocumentation: DocCategory.AI_ENHANCEMENT,
|
|
484
488
|
generateDataDictionary: DocCategory.AI_ENHANCEMENT,
|
|
485
489
|
generateBusinessGlossary: DocCategory.AI_ENHANCEMENT,
|
|
490
|
+
// Phase 2: AI Enhancement
|
|
491
|
+
designSchemaFromRequirements: DocCategory.AI_ENHANCEMENT,
|
|
492
|
+
auditDatabaseSecurity: DocCategory.AI_ENHANCEMENT,
|
|
493
|
+
recommendIndexes: DocCategory.AI_ENHANCEMENT,
|
|
486
494
|
};
|
|
487
495
|
/**
|
|
488
496
|
* Mapping between legacy categories and documentation categories
|
package/dist/index.d.ts
CHANGED
|
@@ -28,6 +28,9 @@ export declare class MySQLMCP {
|
|
|
28
28
|
private intelligentQueryTools;
|
|
29
29
|
private smartDiscoveryTools;
|
|
30
30
|
private documentationGeneratorTools;
|
|
31
|
+
private schemaDesignTools;
|
|
32
|
+
private securityAuditTools;
|
|
33
|
+
private indexRecommendationTools;
|
|
31
34
|
private security;
|
|
32
35
|
private featureConfig;
|
|
33
36
|
constructor(permissionsConfig?: string, categoriesConfig?: string, presetName?: string);
|
|
@@ -1400,5 +1403,114 @@ export declare class MySQLMCP {
|
|
|
1400
1403
|
};
|
|
1401
1404
|
error?: string;
|
|
1402
1405
|
}>;
|
|
1406
|
+
designSchemaFromRequirements(params: {
|
|
1407
|
+
requirements_text: string;
|
|
1408
|
+
entities?: Array<{
|
|
1409
|
+
name: string;
|
|
1410
|
+
fields?: string[];
|
|
1411
|
+
}>;
|
|
1412
|
+
naming_convention?: "snake_case" | "camelCase";
|
|
1413
|
+
include_audit_columns?: boolean;
|
|
1414
|
+
id_type?: "BIGINT" | "UUID";
|
|
1415
|
+
engine?: string;
|
|
1416
|
+
charset?: string;
|
|
1417
|
+
collation?: string;
|
|
1418
|
+
}): Promise<{
|
|
1419
|
+
status: string;
|
|
1420
|
+
data?: {
|
|
1421
|
+
input: {
|
|
1422
|
+
requirements_text: string;
|
|
1423
|
+
inferred_entities_count: number;
|
|
1424
|
+
};
|
|
1425
|
+
tables: Array<{
|
|
1426
|
+
table_name: string;
|
|
1427
|
+
columns: Array<{
|
|
1428
|
+
name: string;
|
|
1429
|
+
type: string;
|
|
1430
|
+
nullable: boolean;
|
|
1431
|
+
primary_key?: boolean;
|
|
1432
|
+
unique?: boolean;
|
|
1433
|
+
references?: {
|
|
1434
|
+
table: string;
|
|
1435
|
+
column: string;
|
|
1436
|
+
};
|
|
1437
|
+
}>;
|
|
1438
|
+
indexes: Array<{
|
|
1439
|
+
name: string;
|
|
1440
|
+
columns: string[];
|
|
1441
|
+
unique?: boolean;
|
|
1442
|
+
}>;
|
|
1443
|
+
}>;
|
|
1444
|
+
relationships: Array<{
|
|
1445
|
+
from_table: string;
|
|
1446
|
+
from_column: string;
|
|
1447
|
+
to_table: string;
|
|
1448
|
+
to_column: string;
|
|
1449
|
+
type: "one_to_many" | "many_to_one";
|
|
1450
|
+
}>;
|
|
1451
|
+
ddl_statements: string[];
|
|
1452
|
+
notes: string[];
|
|
1453
|
+
};
|
|
1454
|
+
error?: string;
|
|
1455
|
+
}>;
|
|
1456
|
+
auditDatabaseSecurity(params?: {
|
|
1457
|
+
database?: string;
|
|
1458
|
+
include_user_account_checks?: boolean;
|
|
1459
|
+
include_privilege_checks?: boolean;
|
|
1460
|
+
}): Promise<{
|
|
1461
|
+
status: string;
|
|
1462
|
+
data?: {
|
|
1463
|
+
database: string;
|
|
1464
|
+
findings: Array<{
|
|
1465
|
+
severity: "critical" | "medium" | "info" | "low" | "high";
|
|
1466
|
+
title: string;
|
|
1467
|
+
evidence?: string;
|
|
1468
|
+
recommendation: string;
|
|
1469
|
+
}>;
|
|
1470
|
+
summary: {
|
|
1471
|
+
critical: number;
|
|
1472
|
+
high: number;
|
|
1473
|
+
medium: number;
|
|
1474
|
+
low: number;
|
|
1475
|
+
info: number;
|
|
1476
|
+
};
|
|
1477
|
+
notes: string[];
|
|
1478
|
+
};
|
|
1479
|
+
error?: string;
|
|
1480
|
+
}>;
|
|
1481
|
+
recommendIndexes(params?: {
|
|
1482
|
+
database?: string;
|
|
1483
|
+
max_query_patterns?: number;
|
|
1484
|
+
max_recommendations?: number;
|
|
1485
|
+
min_execution_count?: number;
|
|
1486
|
+
min_avg_time_ms?: number;
|
|
1487
|
+
include_unused_index_warnings?: boolean;
|
|
1488
|
+
}): Promise<{
|
|
1489
|
+
status: string;
|
|
1490
|
+
data?: {
|
|
1491
|
+
database: string;
|
|
1492
|
+
analyzed_query_patterns: number;
|
|
1493
|
+
recommendations: Array<{
|
|
1494
|
+
table_name: string;
|
|
1495
|
+
columns: string[];
|
|
1496
|
+
proposed_index_name: string;
|
|
1497
|
+
create_index_sql: string;
|
|
1498
|
+
reason: string;
|
|
1499
|
+
supporting_query_patterns: Array<{
|
|
1500
|
+
query_pattern: string;
|
|
1501
|
+
execution_count: number;
|
|
1502
|
+
avg_execution_time_ms: number;
|
|
1503
|
+
}>;
|
|
1504
|
+
}>;
|
|
1505
|
+
unused_index_warnings?: Array<{
|
|
1506
|
+
table_schema: string;
|
|
1507
|
+
table_name: string;
|
|
1508
|
+
index_name: string;
|
|
1509
|
+
note: string;
|
|
1510
|
+
}>;
|
|
1511
|
+
notes: string[];
|
|
1512
|
+
};
|
|
1513
|
+
error?: string;
|
|
1514
|
+
}>;
|
|
1403
1515
|
}
|
|
1404
1516
|
export default MySQLMCP;
|
package/dist/index.js
CHANGED
|
@@ -29,6 +29,9 @@ const macroTools_1 = require("./tools/macroTools");
|
|
|
29
29
|
const intelligentQueryTools_1 = require("./tools/intelligentQueryTools");
|
|
30
30
|
const smartDiscoveryTools_1 = require("./tools/smartDiscoveryTools");
|
|
31
31
|
const documentationGeneratorTools_1 = require("./tools/documentationGeneratorTools");
|
|
32
|
+
const schemaDesignTools_1 = require("./tools/schemaDesignTools");
|
|
33
|
+
const securityAuditTools_1 = require("./tools/securityAuditTools");
|
|
34
|
+
const indexRecommendationTools_1 = require("./tools/indexRecommendationTools");
|
|
32
35
|
const securityLayer_1 = __importDefault(require("./security/securityLayer"));
|
|
33
36
|
const connection_1 = __importDefault(require("./db/connection"));
|
|
34
37
|
const featureConfig_1 = require("./config/featureConfig");
|
|
@@ -66,6 +69,9 @@ class MySQLMCP {
|
|
|
66
69
|
this.intelligentQueryTools = new intelligentQueryTools_1.IntelligentQueryTools(this.security);
|
|
67
70
|
this.smartDiscoveryTools = new smartDiscoveryTools_1.SmartDiscoveryTools(this.security);
|
|
68
71
|
this.documentationGeneratorTools = new documentationGeneratorTools_1.DocumentationGeneratorTools(this.security);
|
|
72
|
+
this.schemaDesignTools = new schemaDesignTools_1.SchemaDesignTools(this.security);
|
|
73
|
+
this.securityAuditTools = new securityAuditTools_1.SecurityAuditTools();
|
|
74
|
+
this.indexRecommendationTools = new indexRecommendationTools_1.IndexRecommendationTools(this.security);
|
|
69
75
|
}
|
|
70
76
|
// Helper method to check if tool is enabled
|
|
71
77
|
checkToolEnabled(toolName) {
|
|
@@ -1128,6 +1134,27 @@ class MySQLMCP {
|
|
|
1128
1134
|
return { status: "error", error: check.error };
|
|
1129
1135
|
return await this.documentationGeneratorTools.generateBusinessGlossaryReport(params);
|
|
1130
1136
|
}
|
|
1137
|
+
// ==========================================
|
|
1138
|
+
// PHASE 2: AI Enhancement Tools (Schema + Security + Indexing)
|
|
1139
|
+
// ==========================================
|
|
1140
|
+
async designSchemaFromRequirements(params) {
|
|
1141
|
+
const check = this.checkToolEnabled("designSchemaFromRequirements");
|
|
1142
|
+
if (!check.enabled)
|
|
1143
|
+
return { status: "error", error: check.error };
|
|
1144
|
+
return await this.schemaDesignTools.designSchemaFromRequirements(params);
|
|
1145
|
+
}
|
|
1146
|
+
async auditDatabaseSecurity(params) {
|
|
1147
|
+
const check = this.checkToolEnabled("auditDatabaseSecurity");
|
|
1148
|
+
if (!check.enabled)
|
|
1149
|
+
return { status: "error", error: check.error };
|
|
1150
|
+
return await this.securityAuditTools.auditDatabaseSecurity(params);
|
|
1151
|
+
}
|
|
1152
|
+
async recommendIndexes(params) {
|
|
1153
|
+
const check = this.checkToolEnabled("recommendIndexes");
|
|
1154
|
+
if (!check.enabled)
|
|
1155
|
+
return { status: "error", error: check.error };
|
|
1156
|
+
return await this.indexRecommendationTools.recommendIndexes(params);
|
|
1157
|
+
}
|
|
1131
1158
|
}
|
|
1132
1159
|
exports.MySQLMCP = MySQLMCP;
|
|
1133
1160
|
exports.default = MySQLMCP;
|
package/dist/mcp-server.js
CHANGED
|
@@ -2883,6 +2883,115 @@ const TOOLS = [
|
|
|
2883
2883
|
required: ["query"],
|
|
2884
2884
|
},
|
|
2885
2885
|
},
|
|
2886
|
+
// ==========================================
|
|
2887
|
+
// PHASE 2: AI Enhancement Tools (Schema + Security + Indexing)
|
|
2888
|
+
// ==========================================
|
|
2889
|
+
{
|
|
2890
|
+
name: "design_schema_from_requirements",
|
|
2891
|
+
description: "Designs a database schema from natural language requirements. Returns a proposed schema spec and CREATE TABLE / CREATE INDEX statements (does not execute DDL).",
|
|
2892
|
+
inputSchema: {
|
|
2893
|
+
type: "object",
|
|
2894
|
+
properties: {
|
|
2895
|
+
requirements_text: {
|
|
2896
|
+
type: "string",
|
|
2897
|
+
description: "Business requirements in natural language, optionally including entity/field hints.",
|
|
2898
|
+
},
|
|
2899
|
+
entities: {
|
|
2900
|
+
type: "array",
|
|
2901
|
+
description: "Optional explicit entity hints to improve accuracy (each entity may include fields).",
|
|
2902
|
+
items: {
|
|
2903
|
+
type: "object",
|
|
2904
|
+
properties: {
|
|
2905
|
+
name: { type: "string" },
|
|
2906
|
+
fields: { type: "array", items: { type: "string" } },
|
|
2907
|
+
},
|
|
2908
|
+
required: ["name"],
|
|
2909
|
+
},
|
|
2910
|
+
},
|
|
2911
|
+
naming_convention: {
|
|
2912
|
+
type: "string",
|
|
2913
|
+
enum: ["snake_case", "camelCase"],
|
|
2914
|
+
description: "Naming convention for generated identifiers (default: snake_case).",
|
|
2915
|
+
},
|
|
2916
|
+
include_audit_columns: {
|
|
2917
|
+
type: "boolean",
|
|
2918
|
+
description: "Whether to include created_at/updated_at columns (default: true).",
|
|
2919
|
+
},
|
|
2920
|
+
id_type: {
|
|
2921
|
+
type: "string",
|
|
2922
|
+
enum: ["BIGINT", "UUID"],
|
|
2923
|
+
description: "Primary key type for id columns (default: BIGINT).",
|
|
2924
|
+
},
|
|
2925
|
+
engine: {
|
|
2926
|
+
type: "string",
|
|
2927
|
+
description: "Storage engine for CREATE TABLE (default: InnoDB).",
|
|
2928
|
+
},
|
|
2929
|
+
charset: {
|
|
2930
|
+
type: "string",
|
|
2931
|
+
description: "Default charset (default: utf8mb4).",
|
|
2932
|
+
},
|
|
2933
|
+
collation: {
|
|
2934
|
+
type: "string",
|
|
2935
|
+
description: "Default collation (default: utf8mb4_unicode_ci).",
|
|
2936
|
+
},
|
|
2937
|
+
},
|
|
2938
|
+
required: ["requirements_text"],
|
|
2939
|
+
},
|
|
2940
|
+
},
|
|
2941
|
+
{
|
|
2942
|
+
name: "audit_database_security",
|
|
2943
|
+
description: "Audits MySQL security configuration and (optionally) accounts/privileges using read-only inspection queries. Returns prioritized findings and recommendations.",
|
|
2944
|
+
inputSchema: {
|
|
2945
|
+
type: "object",
|
|
2946
|
+
properties: {
|
|
2947
|
+
database: {
|
|
2948
|
+
type: "string",
|
|
2949
|
+
description: "Optional: specific database name",
|
|
2950
|
+
},
|
|
2951
|
+
include_user_account_checks: {
|
|
2952
|
+
type: "boolean",
|
|
2953
|
+
description: "Include account checks (requires mysql.user privileges, default: true).",
|
|
2954
|
+
},
|
|
2955
|
+
include_privilege_checks: {
|
|
2956
|
+
type: "boolean",
|
|
2957
|
+
description: "Include privilege summary checks via INFORMATION_SCHEMA (default: true).",
|
|
2958
|
+
},
|
|
2959
|
+
},
|
|
2960
|
+
},
|
|
2961
|
+
},
|
|
2962
|
+
{
|
|
2963
|
+
name: "recommend_indexes",
|
|
2964
|
+
description: "Analyzes real query patterns from performance_schema digests and suggests concrete CREATE INDEX statements. Uses heuristics to avoid duplicate/redundant indexes.",
|
|
2965
|
+
inputSchema: {
|
|
2966
|
+
type: "object",
|
|
2967
|
+
properties: {
|
|
2968
|
+
database: {
|
|
2969
|
+
type: "string",
|
|
2970
|
+
description: "Optional: specific database name",
|
|
2971
|
+
},
|
|
2972
|
+
max_query_patterns: {
|
|
2973
|
+
type: "number",
|
|
2974
|
+
description: "Max query patterns to analyze from digests (default: 25, max: 200).",
|
|
2975
|
+
},
|
|
2976
|
+
max_recommendations: {
|
|
2977
|
+
type: "number",
|
|
2978
|
+
description: "Max index recommendations to return (default: 25, max: 200).",
|
|
2979
|
+
},
|
|
2980
|
+
min_execution_count: {
|
|
2981
|
+
type: "number",
|
|
2982
|
+
description: "Minimum executions for a digest to be considered (default: 5).",
|
|
2983
|
+
},
|
|
2984
|
+
min_avg_time_ms: {
|
|
2985
|
+
type: "number",
|
|
2986
|
+
description: "Minimum average execution time (ms) for a digest to be considered (default: 5).",
|
|
2987
|
+
},
|
|
2988
|
+
include_unused_index_warnings: {
|
|
2989
|
+
type: "boolean",
|
|
2990
|
+
description: "Include unused index warnings (default: false).",
|
|
2991
|
+
},
|
|
2992
|
+
},
|
|
2993
|
+
},
|
|
2994
|
+
},
|
|
2886
2995
|
// Smart Data Discovery
|
|
2887
2996
|
{
|
|
2888
2997
|
name: "smart_search",
|
|
@@ -3531,6 +3640,18 @@ server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
|
|
|
3531
3640
|
case "generate_business_glossary":
|
|
3532
3641
|
result = await mysqlMCP.generateBusinessGlossary((args || {}));
|
|
3533
3642
|
break;
|
|
3643
|
+
// ==========================================
|
|
3644
|
+
// PHASE 2: AI Enhancement Tools (Schema + Security + Indexing)
|
|
3645
|
+
// ==========================================
|
|
3646
|
+
case "design_schema_from_requirements":
|
|
3647
|
+
result = await mysqlMCP.designSchemaFromRequirements((args || {}));
|
|
3648
|
+
break;
|
|
3649
|
+
case "audit_database_security":
|
|
3650
|
+
result = await mysqlMCP.auditDatabaseSecurity((args || {}));
|
|
3651
|
+
break;
|
|
3652
|
+
case "recommend_indexes":
|
|
3653
|
+
result = await mysqlMCP.recommendIndexes((args || {}));
|
|
3654
|
+
break;
|
|
3534
3655
|
default:
|
|
3535
3656
|
throw new Error(`Unknown tool: ${name}`);
|
|
3536
3657
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { SecurityLayer } from "../security/securityLayer";
|
|
2
|
+
export declare class IndexRecommendationTools {
|
|
3
|
+
private db;
|
|
4
|
+
private security;
|
|
5
|
+
constructor(security: SecurityLayer);
|
|
6
|
+
private validateDatabaseAccess;
|
|
7
|
+
recommendIndexes(params?: {
|
|
8
|
+
database?: string;
|
|
9
|
+
max_query_patterns?: number;
|
|
10
|
+
max_recommendations?: number;
|
|
11
|
+
min_execution_count?: number;
|
|
12
|
+
min_avg_time_ms?: number;
|
|
13
|
+
include_unused_index_warnings?: boolean;
|
|
14
|
+
}): Promise<{
|
|
15
|
+
status: string;
|
|
16
|
+
data?: {
|
|
17
|
+
database: string;
|
|
18
|
+
analyzed_query_patterns: number;
|
|
19
|
+
recommendations: Array<{
|
|
20
|
+
table_name: string;
|
|
21
|
+
columns: string[];
|
|
22
|
+
proposed_index_name: string;
|
|
23
|
+
create_index_sql: string;
|
|
24
|
+
reason: string;
|
|
25
|
+
supporting_query_patterns: Array<{
|
|
26
|
+
query_pattern: string;
|
|
27
|
+
execution_count: number;
|
|
28
|
+
avg_execution_time_ms: number;
|
|
29
|
+
}>;
|
|
30
|
+
}>;
|
|
31
|
+
unused_index_warnings?: Array<{
|
|
32
|
+
table_schema: string;
|
|
33
|
+
table_name: string;
|
|
34
|
+
index_name: string;
|
|
35
|
+
note: string;
|
|
36
|
+
}>;
|
|
37
|
+
notes: string[];
|
|
38
|
+
};
|
|
39
|
+
error?: string;
|
|
40
|
+
}>;
|
|
41
|
+
private bumpCounts;
|
|
42
|
+
private pickIndexColumns;
|
|
43
|
+
private buildReasonString;
|
|
44
|
+
private makeIndexName;
|
|
45
|
+
private isCoveredByExistingIndex;
|
|
46
|
+
private getExistingIndexMap;
|
|
47
|
+
private getTopSelectDigests;
|
|
48
|
+
private getUnusedIndexes;
|
|
49
|
+
private parseQueryPattern;
|
|
50
|
+
}
|