@berthojoris/mcp-mysql-server 1.16.3 → 1.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -0
- package/DOCUMENTATIONS.md +378 -24
- package/README.md +36 -453
- package/dist/config/featureConfig.js +20 -0
- package/dist/index.d.ts +166 -0
- package/dist/index.js +68 -0
- package/dist/mcp-server.js +275 -1
- package/dist/tools/forecastingTools.d.ts +36 -0
- package/dist/tools/forecastingTools.js +256 -0
- package/dist/tools/indexRecommendationTools.d.ts +50 -0
- package/dist/tools/indexRecommendationTools.js +451 -0
- package/dist/tools/queryVisualizationTools.d.ts +22 -0
- package/dist/tools/queryVisualizationTools.js +155 -0
- package/dist/tools/schemaDesignTools.d.ts +67 -0
- package/dist/tools/schemaDesignTools.js +359 -0
- package/dist/tools/schemaPatternTools.d.ts +19 -0
- package/dist/tools/schemaPatternTools.js +253 -0
- package/dist/tools/securityAuditTools.d.ts +39 -0
- package/dist/tools/securityAuditTools.js +319 -0
- package/dist/tools/testDataTools.d.ts +26 -0
- package/dist/tools/testDataTools.js +325 -0
- package/manifest.json +189 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -28,6 +28,13 @@ 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;
|
|
34
|
+
private testDataTools;
|
|
35
|
+
private schemaPatternTools;
|
|
36
|
+
private queryVisualizationTools;
|
|
37
|
+
private forecastingTools;
|
|
31
38
|
private security;
|
|
32
39
|
private featureConfig;
|
|
33
40
|
constructor(permissionsConfig?: string, categoriesConfig?: string, presetName?: string);
|
|
@@ -1400,5 +1407,164 @@ export declare class MySQLMCP {
|
|
|
1400
1407
|
};
|
|
1401
1408
|
error?: string;
|
|
1402
1409
|
}>;
|
|
1410
|
+
designSchemaFromRequirements(params: {
|
|
1411
|
+
requirements_text: string;
|
|
1412
|
+
entities?: Array<{
|
|
1413
|
+
name: string;
|
|
1414
|
+
fields?: string[];
|
|
1415
|
+
}>;
|
|
1416
|
+
naming_convention?: "snake_case" | "camelCase";
|
|
1417
|
+
include_audit_columns?: boolean;
|
|
1418
|
+
id_type?: "BIGINT" | "UUID";
|
|
1419
|
+
engine?: string;
|
|
1420
|
+
charset?: string;
|
|
1421
|
+
collation?: string;
|
|
1422
|
+
}): Promise<{
|
|
1423
|
+
status: string;
|
|
1424
|
+
data?: {
|
|
1425
|
+
input: {
|
|
1426
|
+
requirements_text: string;
|
|
1427
|
+
inferred_entities_count: number;
|
|
1428
|
+
};
|
|
1429
|
+
tables: Array<{
|
|
1430
|
+
table_name: string;
|
|
1431
|
+
columns: Array<{
|
|
1432
|
+
name: string;
|
|
1433
|
+
type: string;
|
|
1434
|
+
nullable: boolean;
|
|
1435
|
+
primary_key?: boolean;
|
|
1436
|
+
unique?: boolean;
|
|
1437
|
+
references?: {
|
|
1438
|
+
table: string;
|
|
1439
|
+
column: string;
|
|
1440
|
+
};
|
|
1441
|
+
}>;
|
|
1442
|
+
indexes: Array<{
|
|
1443
|
+
name: string;
|
|
1444
|
+
columns: string[];
|
|
1445
|
+
unique?: boolean;
|
|
1446
|
+
}>;
|
|
1447
|
+
}>;
|
|
1448
|
+
relationships: Array<{
|
|
1449
|
+
from_table: string;
|
|
1450
|
+
from_column: string;
|
|
1451
|
+
to_table: string;
|
|
1452
|
+
to_column: string;
|
|
1453
|
+
type: "one_to_many" | "many_to_one";
|
|
1454
|
+
}>;
|
|
1455
|
+
ddl_statements: string[];
|
|
1456
|
+
notes: string[];
|
|
1457
|
+
};
|
|
1458
|
+
error?: string;
|
|
1459
|
+
}>;
|
|
1460
|
+
auditDatabaseSecurity(params?: {
|
|
1461
|
+
database?: string;
|
|
1462
|
+
include_user_account_checks?: boolean;
|
|
1463
|
+
include_privilege_checks?: boolean;
|
|
1464
|
+
}): Promise<{
|
|
1465
|
+
status: string;
|
|
1466
|
+
data?: {
|
|
1467
|
+
database: string;
|
|
1468
|
+
findings: Array<{
|
|
1469
|
+
severity: "critical" | "medium" | "info" | "low" | "high";
|
|
1470
|
+
title: string;
|
|
1471
|
+
evidence?: string;
|
|
1472
|
+
recommendation: string;
|
|
1473
|
+
}>;
|
|
1474
|
+
summary: {
|
|
1475
|
+
critical: number;
|
|
1476
|
+
high: number;
|
|
1477
|
+
medium: number;
|
|
1478
|
+
low: number;
|
|
1479
|
+
info: number;
|
|
1480
|
+
};
|
|
1481
|
+
notes: string[];
|
|
1482
|
+
};
|
|
1483
|
+
error?: string;
|
|
1484
|
+
}>;
|
|
1485
|
+
recommendIndexes(params?: {
|
|
1486
|
+
database?: string;
|
|
1487
|
+
max_query_patterns?: number;
|
|
1488
|
+
max_recommendations?: number;
|
|
1489
|
+
min_execution_count?: number;
|
|
1490
|
+
min_avg_time_ms?: number;
|
|
1491
|
+
include_unused_index_warnings?: boolean;
|
|
1492
|
+
}): Promise<{
|
|
1493
|
+
status: string;
|
|
1494
|
+
data?: {
|
|
1495
|
+
database: string;
|
|
1496
|
+
analyzed_query_patterns: number;
|
|
1497
|
+
recommendations: Array<{
|
|
1498
|
+
table_name: string;
|
|
1499
|
+
columns: string[];
|
|
1500
|
+
proposed_index_name: string;
|
|
1501
|
+
create_index_sql: string;
|
|
1502
|
+
reason: string;
|
|
1503
|
+
supporting_query_patterns: Array<{
|
|
1504
|
+
query_pattern: string;
|
|
1505
|
+
execution_count: number;
|
|
1506
|
+
avg_execution_time_ms: number;
|
|
1507
|
+
}>;
|
|
1508
|
+
}>;
|
|
1509
|
+
unused_index_warnings?: Array<{
|
|
1510
|
+
table_schema: string;
|
|
1511
|
+
table_name: string;
|
|
1512
|
+
index_name: string;
|
|
1513
|
+
note: string;
|
|
1514
|
+
}>;
|
|
1515
|
+
notes: string[];
|
|
1516
|
+
};
|
|
1517
|
+
error?: string;
|
|
1518
|
+
}>;
|
|
1519
|
+
generateTestData(params: {
|
|
1520
|
+
table_name: string;
|
|
1521
|
+
row_count: number;
|
|
1522
|
+
batch_size?: number;
|
|
1523
|
+
include_nulls?: boolean;
|
|
1524
|
+
database?: string;
|
|
1525
|
+
}): Promise<{
|
|
1526
|
+
status: string;
|
|
1527
|
+
data?: any;
|
|
1528
|
+
error?: string;
|
|
1529
|
+
}>;
|
|
1530
|
+
analyzeSchemaPatterns(params?: {
|
|
1531
|
+
scope?: "database" | "table";
|
|
1532
|
+
table_name?: string;
|
|
1533
|
+
database?: string;
|
|
1534
|
+
}): Promise<{
|
|
1535
|
+
status: string;
|
|
1536
|
+
data?: any;
|
|
1537
|
+
error?: string;
|
|
1538
|
+
}>;
|
|
1539
|
+
visualizeQuery(params: {
|
|
1540
|
+
query: string;
|
|
1541
|
+
include_explain_json?: boolean;
|
|
1542
|
+
format?: "mermaid" | "json" | "both";
|
|
1543
|
+
}): Promise<{
|
|
1544
|
+
status: string;
|
|
1545
|
+
data?: any;
|
|
1546
|
+
error?: string;
|
|
1547
|
+
}>;
|
|
1548
|
+
predictQueryPerformance(params: {
|
|
1549
|
+
query: string;
|
|
1550
|
+
row_growth_multiplier?: number;
|
|
1551
|
+
per_table_row_growth?: Record<string, number>;
|
|
1552
|
+
include_explain_json?: boolean;
|
|
1553
|
+
}): Promise<{
|
|
1554
|
+
status: string;
|
|
1555
|
+
data?: any;
|
|
1556
|
+
error?: string;
|
|
1557
|
+
}>;
|
|
1558
|
+
forecastDatabaseGrowth(params?: {
|
|
1559
|
+
horizon_days?: number;
|
|
1560
|
+
growth_rate_percent_per_day?: number;
|
|
1561
|
+
growth_rate_percent_per_month?: number;
|
|
1562
|
+
per_table_growth_rate_percent_per_day?: Record<string, number>;
|
|
1563
|
+
database?: string;
|
|
1564
|
+
}): Promise<{
|
|
1565
|
+
status: string;
|
|
1566
|
+
data?: any;
|
|
1567
|
+
error?: string;
|
|
1568
|
+
}>;
|
|
1403
1569
|
}
|
|
1404
1570
|
export default MySQLMCP;
|
package/dist/index.js
CHANGED
|
@@ -29,6 +29,13 @@ 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");
|
|
35
|
+
const testDataTools_1 = require("./tools/testDataTools");
|
|
36
|
+
const schemaPatternTools_1 = require("./tools/schemaPatternTools");
|
|
37
|
+
const queryVisualizationTools_1 = require("./tools/queryVisualizationTools");
|
|
38
|
+
const forecastingTools_1 = require("./tools/forecastingTools");
|
|
32
39
|
const securityLayer_1 = __importDefault(require("./security/securityLayer"));
|
|
33
40
|
const connection_1 = __importDefault(require("./db/connection"));
|
|
34
41
|
const featureConfig_1 = require("./config/featureConfig");
|
|
@@ -66,6 +73,13 @@ class MySQLMCP {
|
|
|
66
73
|
this.intelligentQueryTools = new intelligentQueryTools_1.IntelligentQueryTools(this.security);
|
|
67
74
|
this.smartDiscoveryTools = new smartDiscoveryTools_1.SmartDiscoveryTools(this.security);
|
|
68
75
|
this.documentationGeneratorTools = new documentationGeneratorTools_1.DocumentationGeneratorTools(this.security);
|
|
76
|
+
this.schemaDesignTools = new schemaDesignTools_1.SchemaDesignTools(this.security);
|
|
77
|
+
this.securityAuditTools = new securityAuditTools_1.SecurityAuditTools();
|
|
78
|
+
this.indexRecommendationTools = new indexRecommendationTools_1.IndexRecommendationTools(this.security);
|
|
79
|
+
this.testDataTools = new testDataTools_1.TestDataTools(this.security);
|
|
80
|
+
this.schemaPatternTools = new schemaPatternTools_1.SchemaPatternTools(this.security);
|
|
81
|
+
this.queryVisualizationTools = new queryVisualizationTools_1.QueryVisualizationTools(this.security);
|
|
82
|
+
this.forecastingTools = new forecastingTools_1.ForecastingTools(this.security);
|
|
69
83
|
}
|
|
70
84
|
// Helper method to check if tool is enabled
|
|
71
85
|
checkToolEnabled(toolName) {
|
|
@@ -1128,6 +1142,60 @@ class MySQLMCP {
|
|
|
1128
1142
|
return { status: "error", error: check.error };
|
|
1129
1143
|
return await this.documentationGeneratorTools.generateBusinessGlossaryReport(params);
|
|
1130
1144
|
}
|
|
1145
|
+
// ==========================================
|
|
1146
|
+
// PHASE 2: AI Enhancement Tools (Schema + Security + Indexing)
|
|
1147
|
+
// ==========================================
|
|
1148
|
+
async designSchemaFromRequirements(params) {
|
|
1149
|
+
const check = this.checkToolEnabled("designSchemaFromRequirements");
|
|
1150
|
+
if (!check.enabled)
|
|
1151
|
+
return { status: "error", error: check.error };
|
|
1152
|
+
return await this.schemaDesignTools.designSchemaFromRequirements(params);
|
|
1153
|
+
}
|
|
1154
|
+
async auditDatabaseSecurity(params) {
|
|
1155
|
+
const check = this.checkToolEnabled("auditDatabaseSecurity");
|
|
1156
|
+
if (!check.enabled)
|
|
1157
|
+
return { status: "error", error: check.error };
|
|
1158
|
+
return await this.securityAuditTools.auditDatabaseSecurity(params);
|
|
1159
|
+
}
|
|
1160
|
+
async recommendIndexes(params) {
|
|
1161
|
+
const check = this.checkToolEnabled("recommendIndexes");
|
|
1162
|
+
if (!check.enabled)
|
|
1163
|
+
return { status: "error", error: check.error };
|
|
1164
|
+
return await this.indexRecommendationTools.recommendIndexes(params);
|
|
1165
|
+
}
|
|
1166
|
+
// ==========================================
|
|
1167
|
+
// PHASE 3: AI Enhancement Tools (Data Gen + Patterns + Visualization + Forecasting)
|
|
1168
|
+
// ==========================================
|
|
1169
|
+
async generateTestData(params) {
|
|
1170
|
+
const check = this.checkToolEnabled("generateTestData");
|
|
1171
|
+
if (!check.enabled)
|
|
1172
|
+
return { status: "error", error: check.error };
|
|
1173
|
+
return await this.testDataTools.generateTestData(params);
|
|
1174
|
+
}
|
|
1175
|
+
async analyzeSchemaPatterns(params) {
|
|
1176
|
+
const check = this.checkToolEnabled("analyzeSchemaPatterns");
|
|
1177
|
+
if (!check.enabled)
|
|
1178
|
+
return { status: "error", error: check.error };
|
|
1179
|
+
return await this.schemaPatternTools.analyzeSchemaPatterns(params);
|
|
1180
|
+
}
|
|
1181
|
+
async visualizeQuery(params) {
|
|
1182
|
+
const check = this.checkToolEnabled("visualizeQuery");
|
|
1183
|
+
if (!check.enabled)
|
|
1184
|
+
return { status: "error", error: check.error };
|
|
1185
|
+
return await this.queryVisualizationTools.visualizeQuery(params);
|
|
1186
|
+
}
|
|
1187
|
+
async predictQueryPerformance(params) {
|
|
1188
|
+
const check = this.checkToolEnabled("predictQueryPerformance");
|
|
1189
|
+
if (!check.enabled)
|
|
1190
|
+
return { status: "error", error: check.error };
|
|
1191
|
+
return await this.forecastingTools.predictQueryPerformance(params);
|
|
1192
|
+
}
|
|
1193
|
+
async forecastDatabaseGrowth(params) {
|
|
1194
|
+
const check = this.checkToolEnabled("forecastDatabaseGrowth");
|
|
1195
|
+
if (!check.enabled)
|
|
1196
|
+
return { status: "error", error: check.error };
|
|
1197
|
+
return await this.forecastingTools.forecastDatabaseGrowth(params);
|
|
1198
|
+
}
|
|
1131
1199
|
}
|
|
1132
1200
|
exports.MySQLMCP = MySQLMCP;
|
|
1133
1201
|
exports.default = MySQLMCP;
|
package/dist/mcp-server.js
CHANGED
|
@@ -2883,6 +2883,250 @@ 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
|
+
},
|
|
2995
|
+
// ==========================================
|
|
2996
|
+
// PHASE 3: AI Enhancement Tools (Data Gen + Patterns + Visualization + Forecasting)
|
|
2997
|
+
// ==========================================
|
|
2998
|
+
{
|
|
2999
|
+
name: "generate_test_data",
|
|
3000
|
+
description: "Generates synthetic test data as SQL INSERT statements for a given table (does not execute). Attempts FK-aware value selection for referential integrity.",
|
|
3001
|
+
inputSchema: {
|
|
3002
|
+
type: "object",
|
|
3003
|
+
properties: {
|
|
3004
|
+
table_name: {
|
|
3005
|
+
type: "string",
|
|
3006
|
+
description: "Target table to generate INSERT statements for",
|
|
3007
|
+
},
|
|
3008
|
+
row_count: {
|
|
3009
|
+
type: "number",
|
|
3010
|
+
description: "Number of rows to generate (max 5000)",
|
|
3011
|
+
},
|
|
3012
|
+
batch_size: {
|
|
3013
|
+
type: "number",
|
|
3014
|
+
description: "Rows per INSERT statement (default 100, max 1000)",
|
|
3015
|
+
},
|
|
3016
|
+
include_nulls: {
|
|
3017
|
+
type: "boolean",
|
|
3018
|
+
description: "Whether generated values may include NULLs when columns are nullable (default true)",
|
|
3019
|
+
},
|
|
3020
|
+
database: {
|
|
3021
|
+
type: "string",
|
|
3022
|
+
description: "Optional: specific database name",
|
|
3023
|
+
},
|
|
3024
|
+
},
|
|
3025
|
+
required: ["table_name", "row_count"],
|
|
3026
|
+
},
|
|
3027
|
+
},
|
|
3028
|
+
{
|
|
3029
|
+
name: "analyze_schema_patterns",
|
|
3030
|
+
description: "Analyzes the schema for common patterns and anti-patterns (missing PKs, wide tables, unindexed FKs, EAV-like tables, etc.) and returns recommendations.",
|
|
3031
|
+
inputSchema: {
|
|
3032
|
+
type: "object",
|
|
3033
|
+
properties: {
|
|
3034
|
+
scope: {
|
|
3035
|
+
type: "string",
|
|
3036
|
+
enum: ["database", "table"],
|
|
3037
|
+
description: "Analysis scope (default: database unless table_name provided)",
|
|
3038
|
+
},
|
|
3039
|
+
table_name: {
|
|
3040
|
+
type: "string",
|
|
3041
|
+
description: "Optional: specific table to analyze (implies table scope)",
|
|
3042
|
+
},
|
|
3043
|
+
database: {
|
|
3044
|
+
type: "string",
|
|
3045
|
+
description: "Optional: specific database name",
|
|
3046
|
+
},
|
|
3047
|
+
},
|
|
3048
|
+
},
|
|
3049
|
+
},
|
|
3050
|
+
{
|
|
3051
|
+
name: "visualize_query",
|
|
3052
|
+
description: "Creates a visual representation of a read-only SQL query as a Mermaid flowchart, based on EXPLAIN FORMAT=JSON and lightweight SQL parsing.",
|
|
3053
|
+
inputSchema: {
|
|
3054
|
+
type: "object",
|
|
3055
|
+
properties: {
|
|
3056
|
+
query: {
|
|
3057
|
+
type: "string",
|
|
3058
|
+
description: "Read-only SQL query to visualize",
|
|
3059
|
+
},
|
|
3060
|
+
include_explain_json: {
|
|
3061
|
+
type: "boolean",
|
|
3062
|
+
description: "Include full EXPLAIN JSON in the response (default true)",
|
|
3063
|
+
},
|
|
3064
|
+
format: {
|
|
3065
|
+
type: "string",
|
|
3066
|
+
enum: ["mermaid", "json", "both"],
|
|
3067
|
+
description: "Output format (default: both)",
|
|
3068
|
+
},
|
|
3069
|
+
},
|
|
3070
|
+
required: ["query"],
|
|
3071
|
+
},
|
|
3072
|
+
},
|
|
3073
|
+
{
|
|
3074
|
+
name: "predict_query_performance",
|
|
3075
|
+
description: "Predicts how EXPLAIN-estimated scan volume/cost could change under table growth assumptions (heuristic).",
|
|
3076
|
+
inputSchema: {
|
|
3077
|
+
type: "object",
|
|
3078
|
+
properties: {
|
|
3079
|
+
query: {
|
|
3080
|
+
type: "string",
|
|
3081
|
+
description: "Read-only SQL query to analyze",
|
|
3082
|
+
},
|
|
3083
|
+
row_growth_multiplier: {
|
|
3084
|
+
type: "number",
|
|
3085
|
+
description: "Default multiplicative growth factor to apply to table row estimates (default 2)",
|
|
3086
|
+
},
|
|
3087
|
+
per_table_row_growth: {
|
|
3088
|
+
type: "object",
|
|
3089
|
+
description: "Optional per-table growth overrides: { tableName: factor }",
|
|
3090
|
+
additionalProperties: { type: "number" },
|
|
3091
|
+
},
|
|
3092
|
+
include_explain_json: {
|
|
3093
|
+
type: "boolean",
|
|
3094
|
+
description: "Include full EXPLAIN JSON in the response (default false)",
|
|
3095
|
+
},
|
|
3096
|
+
},
|
|
3097
|
+
required: ["query"],
|
|
3098
|
+
},
|
|
3099
|
+
},
|
|
3100
|
+
{
|
|
3101
|
+
name: "forecast_database_growth",
|
|
3102
|
+
description: "Forecasts database/table growth based on current INFORMATION_SCHEMA sizes and user-supplied growth rate assumptions.",
|
|
3103
|
+
inputSchema: {
|
|
3104
|
+
type: "object",
|
|
3105
|
+
properties: {
|
|
3106
|
+
horizon_days: {
|
|
3107
|
+
type: "number",
|
|
3108
|
+
description: "Forecast horizon in days (default 30, max 3650)",
|
|
3109
|
+
},
|
|
3110
|
+
growth_rate_percent_per_day: {
|
|
3111
|
+
type: "number",
|
|
3112
|
+
description: "Base daily growth rate percent applied to all tables unless overridden (e.g., 0.5)",
|
|
3113
|
+
},
|
|
3114
|
+
growth_rate_percent_per_month: {
|
|
3115
|
+
type: "number",
|
|
3116
|
+
description: "Base monthly growth rate percent (converted to daily compound rate)",
|
|
3117
|
+
},
|
|
3118
|
+
per_table_growth_rate_percent_per_day: {
|
|
3119
|
+
type: "object",
|
|
3120
|
+
description: "Optional per-table daily growth rate percent overrides: { tableName: percentPerDay }",
|
|
3121
|
+
additionalProperties: { type: "number" },
|
|
3122
|
+
},
|
|
3123
|
+
database: {
|
|
3124
|
+
type: "string",
|
|
3125
|
+
description: "Optional: specific database name",
|
|
3126
|
+
},
|
|
3127
|
+
},
|
|
3128
|
+
},
|
|
3129
|
+
},
|
|
2886
3130
|
// Smart Data Discovery
|
|
2887
3131
|
{
|
|
2888
3132
|
name: "smart_search",
|
|
@@ -3070,7 +3314,7 @@ const TOOLS = [
|
|
|
3070
3314
|
// Create the MCP server
|
|
3071
3315
|
const server = new index_js_1.Server({
|
|
3072
3316
|
name: "mysql-mcp-server",
|
|
3073
|
-
version: "1.
|
|
3317
|
+
version: "1.17.0",
|
|
3074
3318
|
}, {
|
|
3075
3319
|
capabilities: {
|
|
3076
3320
|
tools: {},
|
|
@@ -3531,6 +3775,36 @@ server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
|
|
|
3531
3775
|
case "generate_business_glossary":
|
|
3532
3776
|
result = await mysqlMCP.generateBusinessGlossary((args || {}));
|
|
3533
3777
|
break;
|
|
3778
|
+
// ==========================================
|
|
3779
|
+
// PHASE 2: AI Enhancement Tools (Schema + Security + Indexing)
|
|
3780
|
+
// ==========================================
|
|
3781
|
+
case "design_schema_from_requirements":
|
|
3782
|
+
result = await mysqlMCP.designSchemaFromRequirements((args || {}));
|
|
3783
|
+
break;
|
|
3784
|
+
case "audit_database_security":
|
|
3785
|
+
result = await mysqlMCP.auditDatabaseSecurity((args || {}));
|
|
3786
|
+
break;
|
|
3787
|
+
case "recommend_indexes":
|
|
3788
|
+
result = await mysqlMCP.recommendIndexes((args || {}));
|
|
3789
|
+
break;
|
|
3790
|
+
// ==========================================
|
|
3791
|
+
// PHASE 3: AI Enhancement Tools (Data Gen + Patterns + Visualization + Forecasting)
|
|
3792
|
+
// ==========================================
|
|
3793
|
+
case "generate_test_data":
|
|
3794
|
+
result = await mysqlMCP.generateTestData((args || {}));
|
|
3795
|
+
break;
|
|
3796
|
+
case "analyze_schema_patterns":
|
|
3797
|
+
result = await mysqlMCP.analyzeSchemaPatterns((args || {}));
|
|
3798
|
+
break;
|
|
3799
|
+
case "visualize_query":
|
|
3800
|
+
result = await mysqlMCP.visualizeQuery((args || {}));
|
|
3801
|
+
break;
|
|
3802
|
+
case "predict_query_performance":
|
|
3803
|
+
result = await mysqlMCP.predictQueryPerformance((args || {}));
|
|
3804
|
+
break;
|
|
3805
|
+
case "forecast_database_growth":
|
|
3806
|
+
result = await mysqlMCP.forecastDatabaseGrowth((args || {}));
|
|
3807
|
+
break;
|
|
3534
3808
|
default:
|
|
3535
3809
|
throw new Error(`Unknown tool: ${name}`);
|
|
3536
3810
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { SecurityLayer } from "../security/securityLayer";
|
|
2
|
+
export declare class ForecastingTools {
|
|
3
|
+
private db;
|
|
4
|
+
private security;
|
|
5
|
+
constructor(security: SecurityLayer);
|
|
6
|
+
private validateDatabaseAccess;
|
|
7
|
+
private extractExplainNodes;
|
|
8
|
+
/**
|
|
9
|
+
* Predict how query cost/scan volume might change under table growth assumptions.
|
|
10
|
+
* This is heuristic-based and uses EXPLAIN FORMAT=JSON estimates.
|
|
11
|
+
*/
|
|
12
|
+
predictQueryPerformance(params: {
|
|
13
|
+
query: string;
|
|
14
|
+
row_growth_multiplier?: number;
|
|
15
|
+
per_table_row_growth?: Record<string, number>;
|
|
16
|
+
include_explain_json?: boolean;
|
|
17
|
+
}): Promise<{
|
|
18
|
+
status: string;
|
|
19
|
+
data?: any;
|
|
20
|
+
error?: string;
|
|
21
|
+
}>;
|
|
22
|
+
/**
|
|
23
|
+
* Forecast database/table growth based on current sizes and user-supplied growth rate assumptions.
|
|
24
|
+
*/
|
|
25
|
+
forecastDatabaseGrowth(params?: {
|
|
26
|
+
horizon_days?: number;
|
|
27
|
+
growth_rate_percent_per_day?: number;
|
|
28
|
+
growth_rate_percent_per_month?: number;
|
|
29
|
+
per_table_growth_rate_percent_per_day?: Record<string, number>;
|
|
30
|
+
database?: string;
|
|
31
|
+
}): Promise<{
|
|
32
|
+
status: string;
|
|
33
|
+
data?: any;
|
|
34
|
+
error?: string;
|
|
35
|
+
}>;
|
|
36
|
+
}
|