@berthojoris/mcp-mysql-server 1.4.15 → 1.6.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/DOCUMENTATIONS.md +664 -22
- package/README.md +102 -5
- package/dist/cache/queryCache.d.ts +126 -0
- package/dist/cache/queryCache.js +337 -0
- package/dist/config/featureConfig.js +82 -71
- package/dist/db/connection.d.ts +21 -2
- package/dist/db/connection.js +73 -7
- package/dist/db/queryLogger.d.ts +3 -2
- package/dist/db/queryLogger.js +64 -43
- package/dist/index.d.ts +477 -3
- package/dist/index.js +472 -70
- package/dist/mcp-server.js +1352 -124
- package/dist/optimization/queryOptimizer.d.ts +125 -0
- package/dist/optimization/queryOptimizer.js +509 -0
- package/dist/tools/constraintTools.d.ts +108 -0
- package/dist/tools/constraintTools.js +405 -0
- package/dist/tools/functionTools.d.ts +93 -0
- package/dist/tools/functionTools.js +351 -0
- package/dist/tools/indexTools.d.ts +81 -0
- package/dist/tools/indexTools.js +345 -0
- package/dist/tools/maintenanceTools.d.ts +111 -0
- package/dist/tools/maintenanceTools.js +371 -0
- package/dist/tools/processTools.d.ts +106 -0
- package/dist/tools/processTools.js +305 -0
- package/dist/tools/queryTools.d.ts +14 -1
- package/dist/tools/queryTools.js +27 -3
- package/dist/tools/triggerTools.d.ts +76 -0
- package/dist/tools/triggerTools.js +294 -0
- package/dist/tools/viewTools.d.ts +91 -0
- package/dist/tools/viewTools.js +330 -0
- package/package.json +1 -1
package/dist/mcp-server.js
CHANGED
|
@@ -316,7 +316,7 @@ const TOOLS = [
|
|
|
316
316
|
},
|
|
317
317
|
{
|
|
318
318
|
name: "run_query",
|
|
319
|
-
description: "Runs a read-only SQL SELECT query with optional parameters. Only SELECT statements are allowed.",
|
|
319
|
+
description: "Runs a read-only SQL SELECT query with optional parameters, optimizer hints, and caching support. Only SELECT statements are allowed.",
|
|
320
320
|
inputSchema: {
|
|
321
321
|
type: "object",
|
|
322
322
|
properties: {
|
|
@@ -329,6 +329,50 @@ const TOOLS = [
|
|
|
329
329
|
description: "Optional array of parameters for parameterized queries",
|
|
330
330
|
items: {},
|
|
331
331
|
},
|
|
332
|
+
hints: {
|
|
333
|
+
type: "object",
|
|
334
|
+
description: "Optional MySQL optimizer hints to apply to the query",
|
|
335
|
+
properties: {
|
|
336
|
+
maxExecutionTime: {
|
|
337
|
+
type: "number",
|
|
338
|
+
description: "Maximum execution time in milliseconds",
|
|
339
|
+
},
|
|
340
|
+
forceIndex: {
|
|
341
|
+
oneOf: [
|
|
342
|
+
{ type: "string" },
|
|
343
|
+
{ type: "array", items: { type: "string" } },
|
|
344
|
+
],
|
|
345
|
+
description: "Force usage of specific index(es)",
|
|
346
|
+
},
|
|
347
|
+
ignoreIndex: {
|
|
348
|
+
oneOf: [
|
|
349
|
+
{ type: "string" },
|
|
350
|
+
{ type: "array", items: { type: "string" } },
|
|
351
|
+
],
|
|
352
|
+
description: "Ignore specific index(es)",
|
|
353
|
+
},
|
|
354
|
+
straightJoin: {
|
|
355
|
+
type: "boolean",
|
|
356
|
+
description: "Use STRAIGHT_JOIN to force join order",
|
|
357
|
+
},
|
|
358
|
+
noCache: {
|
|
359
|
+
type: "boolean",
|
|
360
|
+
description: "Disable query cache for this query",
|
|
361
|
+
},
|
|
362
|
+
sqlBigResult: {
|
|
363
|
+
type: "boolean",
|
|
364
|
+
description: "Optimize for large result sets",
|
|
365
|
+
},
|
|
366
|
+
sqlSmallResult: {
|
|
367
|
+
type: "boolean",
|
|
368
|
+
description: "Optimize for small result sets",
|
|
369
|
+
},
|
|
370
|
+
},
|
|
371
|
+
},
|
|
372
|
+
useCache: {
|
|
373
|
+
type: "boolean",
|
|
374
|
+
description: "Whether to use query result caching (default: true)",
|
|
375
|
+
},
|
|
332
376
|
},
|
|
333
377
|
required: ["query"],
|
|
334
378
|
},
|
|
@@ -806,126 +850,1310 @@ const TOOLS = [
|
|
|
806
850
|
required: ["query"],
|
|
807
851
|
},
|
|
808
852
|
},
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
853
|
+
// Cache Management Tools
|
|
854
|
+
{
|
|
855
|
+
name: "get_cache_stats",
|
|
856
|
+
description: "Get query cache statistics including hit rate, size, and configuration.",
|
|
857
|
+
inputSchema: {
|
|
858
|
+
type: "object",
|
|
859
|
+
properties: {},
|
|
860
|
+
},
|
|
817
861
|
},
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
}
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
862
|
+
{
|
|
863
|
+
name: "get_cache_config",
|
|
864
|
+
description: "Get current cache configuration settings.",
|
|
865
|
+
inputSchema: {
|
|
866
|
+
type: "object",
|
|
867
|
+
properties: {},
|
|
868
|
+
},
|
|
869
|
+
},
|
|
870
|
+
{
|
|
871
|
+
name: "configure_cache",
|
|
872
|
+
description: "Configure cache settings including TTL, max size, and enable/disable.",
|
|
873
|
+
inputSchema: {
|
|
874
|
+
type: "object",
|
|
875
|
+
properties: {
|
|
876
|
+
enabled: {
|
|
877
|
+
type: "boolean",
|
|
878
|
+
description: "Enable or disable the query cache",
|
|
879
|
+
},
|
|
880
|
+
ttlMs: {
|
|
881
|
+
type: "number",
|
|
882
|
+
description: "Cache time-to-live in milliseconds (default: 60000)",
|
|
883
|
+
},
|
|
884
|
+
maxSize: {
|
|
885
|
+
type: "number",
|
|
886
|
+
description: "Maximum number of cached entries (default: 100)",
|
|
887
|
+
},
|
|
888
|
+
maxMemoryMB: {
|
|
889
|
+
type: "number",
|
|
890
|
+
description: "Maximum memory usage in MB (default: 50)",
|
|
891
|
+
},
|
|
892
|
+
},
|
|
893
|
+
},
|
|
894
|
+
},
|
|
895
|
+
{
|
|
896
|
+
name: "clear_cache",
|
|
897
|
+
description: "Clear all entries from the query cache.",
|
|
898
|
+
inputSchema: {
|
|
899
|
+
type: "object",
|
|
900
|
+
properties: {},
|
|
901
|
+
},
|
|
902
|
+
},
|
|
903
|
+
{
|
|
904
|
+
name: "invalidate_table_cache",
|
|
905
|
+
description: "Invalidate all cached queries related to a specific table.",
|
|
906
|
+
inputSchema: {
|
|
907
|
+
type: "object",
|
|
908
|
+
properties: {
|
|
909
|
+
table_name: {
|
|
910
|
+
type: "string",
|
|
911
|
+
description: "Name of the table to invalidate cache for",
|
|
912
|
+
},
|
|
913
|
+
},
|
|
914
|
+
required: ["table_name"],
|
|
915
|
+
},
|
|
916
|
+
},
|
|
917
|
+
// Query Optimization Tools
|
|
918
|
+
{
|
|
919
|
+
name: "analyze_query",
|
|
920
|
+
description: "Analyze a SQL query and get optimization suggestions including recommended indexes and hints.",
|
|
921
|
+
inputSchema: {
|
|
922
|
+
type: "object",
|
|
923
|
+
properties: {
|
|
924
|
+
query: {
|
|
925
|
+
type: "string",
|
|
926
|
+
description: "SQL query to analyze",
|
|
927
|
+
},
|
|
928
|
+
},
|
|
929
|
+
required: ["query"],
|
|
930
|
+
},
|
|
931
|
+
},
|
|
932
|
+
{
|
|
933
|
+
name: "get_optimization_hints",
|
|
934
|
+
description: "Get suggested MySQL optimizer hints for a specific optimization goal (SPEED, MEMORY, or STABILITY).",
|
|
935
|
+
inputSchema: {
|
|
936
|
+
type: "object",
|
|
937
|
+
properties: {
|
|
938
|
+
goal: {
|
|
939
|
+
type: "string",
|
|
940
|
+
enum: ["SPEED", "MEMORY", "STABILITY"],
|
|
941
|
+
description: "Optimization goal: SPEED for faster queries, MEMORY for lower memory usage, STABILITY for consistent performance",
|
|
942
|
+
},
|
|
943
|
+
},
|
|
944
|
+
required: ["goal"],
|
|
945
|
+
},
|
|
946
|
+
},
|
|
947
|
+
// View Tools
|
|
948
|
+
{
|
|
949
|
+
name: "list_views",
|
|
950
|
+
description: "Lists all views in the connected database.",
|
|
951
|
+
inputSchema: {
|
|
952
|
+
type: "object",
|
|
953
|
+
properties: {
|
|
954
|
+
database: {
|
|
955
|
+
type: "string",
|
|
956
|
+
description: "Optional: specific database name",
|
|
957
|
+
},
|
|
958
|
+
},
|
|
959
|
+
},
|
|
960
|
+
},
|
|
961
|
+
{
|
|
962
|
+
name: "get_view_info",
|
|
963
|
+
description: "Gets detailed information about a specific view including columns and definition.",
|
|
964
|
+
inputSchema: {
|
|
965
|
+
type: "object",
|
|
966
|
+
properties: {
|
|
967
|
+
view_name: { type: "string", description: "Name of the view" },
|
|
968
|
+
database: {
|
|
969
|
+
type: "string",
|
|
970
|
+
description: "Optional: specific database name",
|
|
971
|
+
},
|
|
972
|
+
},
|
|
973
|
+
required: ["view_name"],
|
|
974
|
+
},
|
|
975
|
+
},
|
|
976
|
+
{
|
|
977
|
+
name: "create_view",
|
|
978
|
+
description: "Creates a new view with the specified SELECT definition. Requires 'ddl' permission.",
|
|
979
|
+
inputSchema: {
|
|
980
|
+
type: "object",
|
|
981
|
+
properties: {
|
|
982
|
+
view_name: {
|
|
983
|
+
type: "string",
|
|
984
|
+
description: "Name of the view to create",
|
|
985
|
+
},
|
|
986
|
+
definition: {
|
|
987
|
+
type: "string",
|
|
988
|
+
description: "SELECT statement that defines the view",
|
|
989
|
+
},
|
|
990
|
+
or_replace: {
|
|
991
|
+
type: "boolean",
|
|
992
|
+
description: "If true, replaces existing view",
|
|
993
|
+
},
|
|
994
|
+
algorithm: {
|
|
995
|
+
type: "string",
|
|
996
|
+
enum: ["UNDEFINED", "MERGE", "TEMPTABLE"],
|
|
997
|
+
description: "View algorithm",
|
|
998
|
+
},
|
|
999
|
+
security: {
|
|
1000
|
+
type: "string",
|
|
1001
|
+
enum: ["DEFINER", "INVOKER"],
|
|
1002
|
+
description: "Security context",
|
|
1003
|
+
},
|
|
1004
|
+
check_option: {
|
|
1005
|
+
type: "string",
|
|
1006
|
+
enum: ["CASCADED", "LOCAL"],
|
|
1007
|
+
description: "Check option for updatable views",
|
|
1008
|
+
},
|
|
1009
|
+
database: {
|
|
1010
|
+
type: "string",
|
|
1011
|
+
description: "Optional: specific database name",
|
|
1012
|
+
},
|
|
1013
|
+
},
|
|
1014
|
+
required: ["view_name", "definition"],
|
|
1015
|
+
},
|
|
1016
|
+
},
|
|
1017
|
+
{
|
|
1018
|
+
name: "alter_view",
|
|
1019
|
+
description: "Alters an existing view definition. Requires 'ddl' permission.",
|
|
1020
|
+
inputSchema: {
|
|
1021
|
+
type: "object",
|
|
1022
|
+
properties: {
|
|
1023
|
+
view_name: { type: "string", description: "Name of the view to alter" },
|
|
1024
|
+
definition: {
|
|
1025
|
+
type: "string",
|
|
1026
|
+
description: "New SELECT statement that defines the view",
|
|
1027
|
+
},
|
|
1028
|
+
algorithm: {
|
|
1029
|
+
type: "string",
|
|
1030
|
+
enum: ["UNDEFINED", "MERGE", "TEMPTABLE"],
|
|
1031
|
+
description: "View algorithm",
|
|
1032
|
+
},
|
|
1033
|
+
security: {
|
|
1034
|
+
type: "string",
|
|
1035
|
+
enum: ["DEFINER", "INVOKER"],
|
|
1036
|
+
description: "Security context",
|
|
1037
|
+
},
|
|
1038
|
+
check_option: {
|
|
1039
|
+
type: "string",
|
|
1040
|
+
enum: ["CASCADED", "LOCAL"],
|
|
1041
|
+
description: "Check option",
|
|
1042
|
+
},
|
|
1043
|
+
database: {
|
|
1044
|
+
type: "string",
|
|
1045
|
+
description: "Optional: specific database name",
|
|
1046
|
+
},
|
|
1047
|
+
},
|
|
1048
|
+
required: ["view_name", "definition"],
|
|
1049
|
+
},
|
|
1050
|
+
},
|
|
1051
|
+
{
|
|
1052
|
+
name: "drop_view",
|
|
1053
|
+
description: "Drops a view. Requires 'ddl' permission. WARNING: This is irreversible!",
|
|
1054
|
+
inputSchema: {
|
|
1055
|
+
type: "object",
|
|
1056
|
+
properties: {
|
|
1057
|
+
view_name: { type: "string", description: "Name of the view to drop" },
|
|
1058
|
+
if_exists: {
|
|
1059
|
+
type: "boolean",
|
|
1060
|
+
description: "If true, will not error if view does not exist",
|
|
1061
|
+
},
|
|
1062
|
+
database: {
|
|
1063
|
+
type: "string",
|
|
1064
|
+
description: "Optional: specific database name",
|
|
1065
|
+
},
|
|
1066
|
+
},
|
|
1067
|
+
required: ["view_name"],
|
|
1068
|
+
},
|
|
1069
|
+
},
|
|
1070
|
+
{
|
|
1071
|
+
name: "show_create_view",
|
|
1072
|
+
description: "Shows the CREATE statement for a view.",
|
|
1073
|
+
inputSchema: {
|
|
1074
|
+
type: "object",
|
|
1075
|
+
properties: {
|
|
1076
|
+
view_name: { type: "string", description: "Name of the view" },
|
|
1077
|
+
database: {
|
|
1078
|
+
type: "string",
|
|
1079
|
+
description: "Optional: specific database name",
|
|
1080
|
+
},
|
|
1081
|
+
},
|
|
1082
|
+
required: ["view_name"],
|
|
1083
|
+
},
|
|
1084
|
+
},
|
|
1085
|
+
// Trigger Tools
|
|
1086
|
+
{
|
|
1087
|
+
name: "list_triggers",
|
|
1088
|
+
description: "Lists all triggers in the database, optionally filtered by table.",
|
|
1089
|
+
inputSchema: {
|
|
1090
|
+
type: "object",
|
|
1091
|
+
properties: {
|
|
1092
|
+
database: {
|
|
1093
|
+
type: "string",
|
|
1094
|
+
description: "Optional: specific database name",
|
|
1095
|
+
},
|
|
1096
|
+
table_name: {
|
|
1097
|
+
type: "string",
|
|
1098
|
+
description: "Optional: filter triggers for specific table",
|
|
1099
|
+
},
|
|
1100
|
+
},
|
|
1101
|
+
},
|
|
1102
|
+
},
|
|
1103
|
+
{
|
|
1104
|
+
name: "get_trigger_info",
|
|
1105
|
+
description: "Gets detailed information about a specific trigger.",
|
|
1106
|
+
inputSchema: {
|
|
1107
|
+
type: "object",
|
|
1108
|
+
properties: {
|
|
1109
|
+
trigger_name: { type: "string", description: "Name of the trigger" },
|
|
1110
|
+
database: {
|
|
1111
|
+
type: "string",
|
|
1112
|
+
description: "Optional: specific database name",
|
|
1113
|
+
},
|
|
1114
|
+
},
|
|
1115
|
+
required: ["trigger_name"],
|
|
1116
|
+
},
|
|
1117
|
+
},
|
|
1118
|
+
{
|
|
1119
|
+
name: "create_trigger",
|
|
1120
|
+
description: "Creates a new trigger on a table. Requires 'ddl' permission.",
|
|
1121
|
+
inputSchema: {
|
|
1122
|
+
type: "object",
|
|
1123
|
+
properties: {
|
|
1124
|
+
trigger_name: { type: "string", description: "Name of the trigger" },
|
|
1125
|
+
table_name: {
|
|
1126
|
+
type: "string",
|
|
1127
|
+
description: "Table the trigger is associated with",
|
|
1128
|
+
},
|
|
1129
|
+
timing: {
|
|
1130
|
+
type: "string",
|
|
1131
|
+
enum: ["BEFORE", "AFTER"],
|
|
1132
|
+
description: "When the trigger fires",
|
|
1133
|
+
},
|
|
1134
|
+
event: {
|
|
1135
|
+
type: "string",
|
|
1136
|
+
enum: ["INSERT", "UPDATE", "DELETE"],
|
|
1137
|
+
description: "Event that fires the trigger",
|
|
1138
|
+
},
|
|
1139
|
+
body: { type: "string", description: "SQL statements to execute" },
|
|
1140
|
+
definer: {
|
|
1141
|
+
type: "string",
|
|
1142
|
+
description: "Optional: user who owns the trigger",
|
|
1143
|
+
},
|
|
1144
|
+
database: {
|
|
1145
|
+
type: "string",
|
|
1146
|
+
description: "Optional: specific database name",
|
|
1147
|
+
},
|
|
1148
|
+
},
|
|
1149
|
+
required: ["trigger_name", "table_name", "timing", "event", "body"],
|
|
1150
|
+
},
|
|
1151
|
+
},
|
|
1152
|
+
{
|
|
1153
|
+
name: "drop_trigger",
|
|
1154
|
+
description: "Drops a trigger. Requires 'ddl' permission. WARNING: This is irreversible!",
|
|
1155
|
+
inputSchema: {
|
|
1156
|
+
type: "object",
|
|
1157
|
+
properties: {
|
|
1158
|
+
trigger_name: {
|
|
1159
|
+
type: "string",
|
|
1160
|
+
description: "Name of the trigger to drop",
|
|
1161
|
+
},
|
|
1162
|
+
if_exists: {
|
|
1163
|
+
type: "boolean",
|
|
1164
|
+
description: "If true, will not error if trigger does not exist",
|
|
1165
|
+
},
|
|
1166
|
+
database: {
|
|
1167
|
+
type: "string",
|
|
1168
|
+
description: "Optional: specific database name",
|
|
1169
|
+
},
|
|
1170
|
+
},
|
|
1171
|
+
required: ["trigger_name"],
|
|
1172
|
+
},
|
|
1173
|
+
},
|
|
1174
|
+
{
|
|
1175
|
+
name: "show_create_trigger",
|
|
1176
|
+
description: "Shows the CREATE statement for a trigger.",
|
|
1177
|
+
inputSchema: {
|
|
1178
|
+
type: "object",
|
|
1179
|
+
properties: {
|
|
1180
|
+
trigger_name: { type: "string", description: "Name of the trigger" },
|
|
1181
|
+
database: {
|
|
1182
|
+
type: "string",
|
|
1183
|
+
description: "Optional: specific database name",
|
|
1184
|
+
},
|
|
1185
|
+
},
|
|
1186
|
+
required: ["trigger_name"],
|
|
1187
|
+
},
|
|
1188
|
+
},
|
|
1189
|
+
// Function Tools
|
|
1190
|
+
{
|
|
1191
|
+
name: "list_functions",
|
|
1192
|
+
description: "Lists all user-defined functions in the database.",
|
|
1193
|
+
inputSchema: {
|
|
1194
|
+
type: "object",
|
|
1195
|
+
properties: {
|
|
1196
|
+
database: {
|
|
1197
|
+
type: "string",
|
|
1198
|
+
description: "Optional: specific database name",
|
|
1199
|
+
},
|
|
1200
|
+
},
|
|
1201
|
+
},
|
|
1202
|
+
},
|
|
1203
|
+
{
|
|
1204
|
+
name: "get_function_info",
|
|
1205
|
+
description: "Gets detailed information about a specific function including parameters.",
|
|
1206
|
+
inputSchema: {
|
|
1207
|
+
type: "object",
|
|
1208
|
+
properties: {
|
|
1209
|
+
function_name: { type: "string", description: "Name of the function" },
|
|
1210
|
+
database: {
|
|
1211
|
+
type: "string",
|
|
1212
|
+
description: "Optional: specific database name",
|
|
1213
|
+
},
|
|
1214
|
+
},
|
|
1215
|
+
required: ["function_name"],
|
|
1216
|
+
},
|
|
1217
|
+
},
|
|
1218
|
+
{
|
|
1219
|
+
name: "create_function",
|
|
1220
|
+
description: "Creates a new user-defined function. Requires 'ddl' permission.",
|
|
1221
|
+
inputSchema: {
|
|
1222
|
+
type: "object",
|
|
1223
|
+
properties: {
|
|
1224
|
+
function_name: { type: "string", description: "Name of the function" },
|
|
1225
|
+
parameters: {
|
|
1226
|
+
type: "array",
|
|
1227
|
+
description: "Array of parameter definitions",
|
|
1228
|
+
items: {
|
|
1229
|
+
type: "object",
|
|
1230
|
+
properties: {
|
|
1231
|
+
name: { type: "string" },
|
|
1232
|
+
data_type: { type: "string" },
|
|
1233
|
+
},
|
|
1234
|
+
required: ["name", "data_type"],
|
|
1235
|
+
},
|
|
1236
|
+
},
|
|
1237
|
+
returns: { type: "string", description: "Return data type" },
|
|
1238
|
+
body: { type: "string", description: "Function body (SQL statements)" },
|
|
1239
|
+
deterministic: {
|
|
1240
|
+
type: "boolean",
|
|
1241
|
+
description: "Whether function always returns same result for same input",
|
|
1242
|
+
},
|
|
1243
|
+
data_access: {
|
|
1244
|
+
type: "string",
|
|
1245
|
+
enum: [
|
|
1246
|
+
"CONTAINS SQL",
|
|
1247
|
+
"NO SQL",
|
|
1248
|
+
"READS SQL DATA",
|
|
1249
|
+
"MODIFIES SQL DATA",
|
|
1250
|
+
],
|
|
1251
|
+
},
|
|
1252
|
+
security: { type: "string", enum: ["DEFINER", "INVOKER"] },
|
|
1253
|
+
comment: { type: "string", description: "Optional comment" },
|
|
1254
|
+
database: {
|
|
1255
|
+
type: "string",
|
|
1256
|
+
description: "Optional: specific database name",
|
|
1257
|
+
},
|
|
1258
|
+
},
|
|
1259
|
+
required: ["function_name", "returns", "body"],
|
|
1260
|
+
},
|
|
1261
|
+
},
|
|
1262
|
+
{
|
|
1263
|
+
name: "drop_function",
|
|
1264
|
+
description: "Drops a user-defined function. Requires 'ddl' permission.",
|
|
1265
|
+
inputSchema: {
|
|
1266
|
+
type: "object",
|
|
1267
|
+
properties: {
|
|
1268
|
+
function_name: {
|
|
1269
|
+
type: "string",
|
|
1270
|
+
description: "Name of the function to drop",
|
|
1271
|
+
},
|
|
1272
|
+
if_exists: {
|
|
1273
|
+
type: "boolean",
|
|
1274
|
+
description: "If true, will not error if function does not exist",
|
|
1275
|
+
},
|
|
1276
|
+
database: {
|
|
1277
|
+
type: "string",
|
|
1278
|
+
description: "Optional: specific database name",
|
|
1279
|
+
},
|
|
1280
|
+
},
|
|
1281
|
+
required: ["function_name"],
|
|
1282
|
+
},
|
|
1283
|
+
},
|
|
1284
|
+
{
|
|
1285
|
+
name: "show_create_function",
|
|
1286
|
+
description: "Shows the CREATE statement for a function.",
|
|
1287
|
+
inputSchema: {
|
|
1288
|
+
type: "object",
|
|
1289
|
+
properties: {
|
|
1290
|
+
function_name: { type: "string", description: "Name of the function" },
|
|
1291
|
+
database: {
|
|
1292
|
+
type: "string",
|
|
1293
|
+
description: "Optional: specific database name",
|
|
1294
|
+
},
|
|
1295
|
+
},
|
|
1296
|
+
required: ["function_name"],
|
|
1297
|
+
},
|
|
1298
|
+
},
|
|
1299
|
+
{
|
|
1300
|
+
name: "execute_function",
|
|
1301
|
+
description: "Executes a user-defined function and returns its result.",
|
|
1302
|
+
inputSchema: {
|
|
1303
|
+
type: "object",
|
|
1304
|
+
properties: {
|
|
1305
|
+
function_name: {
|
|
1306
|
+
type: "string",
|
|
1307
|
+
description: "Name of the function to execute",
|
|
1308
|
+
},
|
|
1309
|
+
parameters: {
|
|
1310
|
+
type: "array",
|
|
1311
|
+
description: "Array of parameter values",
|
|
1312
|
+
items: {},
|
|
1313
|
+
},
|
|
1314
|
+
database: {
|
|
1315
|
+
type: "string",
|
|
1316
|
+
description: "Optional: specific database name",
|
|
1317
|
+
},
|
|
1318
|
+
},
|
|
1319
|
+
required: ["function_name"],
|
|
1320
|
+
},
|
|
1321
|
+
},
|
|
1322
|
+
// Index Tools
|
|
1323
|
+
{
|
|
1324
|
+
name: "list_indexes",
|
|
1325
|
+
description: "Lists all indexes for a specific table.",
|
|
1326
|
+
inputSchema: {
|
|
1327
|
+
type: "object",
|
|
1328
|
+
properties: {
|
|
1329
|
+
table_name: { type: "string", description: "Name of the table" },
|
|
1330
|
+
database: {
|
|
1331
|
+
type: "string",
|
|
1332
|
+
description: "Optional: specific database name",
|
|
1333
|
+
},
|
|
1334
|
+
},
|
|
1335
|
+
required: ["table_name"],
|
|
1336
|
+
},
|
|
1337
|
+
},
|
|
1338
|
+
{
|
|
1339
|
+
name: "get_index_info",
|
|
1340
|
+
description: "Gets detailed information about a specific index.",
|
|
1341
|
+
inputSchema: {
|
|
1342
|
+
type: "object",
|
|
1343
|
+
properties: {
|
|
1344
|
+
table_name: { type: "string", description: "Name of the table" },
|
|
1345
|
+
index_name: { type: "string", description: "Name of the index" },
|
|
1346
|
+
database: {
|
|
1347
|
+
type: "string",
|
|
1348
|
+
description: "Optional: specific database name",
|
|
1349
|
+
},
|
|
1350
|
+
},
|
|
1351
|
+
required: ["table_name", "index_name"],
|
|
1352
|
+
},
|
|
1353
|
+
},
|
|
1354
|
+
{
|
|
1355
|
+
name: "create_index",
|
|
1356
|
+
description: "Creates a new index on a table. Requires 'ddl' permission.",
|
|
1357
|
+
inputSchema: {
|
|
1358
|
+
type: "object",
|
|
1359
|
+
properties: {
|
|
1360
|
+
table_name: { type: "string", description: "Name of the table" },
|
|
1361
|
+
index_name: { type: "string", description: "Name of the index" },
|
|
1362
|
+
columns: {
|
|
1363
|
+
type: "array",
|
|
1364
|
+
description: "Columns to index (string or object with column, length, order)",
|
|
1365
|
+
items: {},
|
|
1366
|
+
},
|
|
1367
|
+
unique: { type: "boolean", description: "Whether index is unique" },
|
|
1368
|
+
index_type: {
|
|
1369
|
+
type: "string",
|
|
1370
|
+
enum: ["BTREE", "HASH", "FULLTEXT", "SPATIAL"],
|
|
1371
|
+
description: "Index type",
|
|
1372
|
+
},
|
|
1373
|
+
comment: { type: "string", description: "Optional comment" },
|
|
1374
|
+
database: {
|
|
1375
|
+
type: "string",
|
|
1376
|
+
description: "Optional: specific database name",
|
|
1377
|
+
},
|
|
1378
|
+
},
|
|
1379
|
+
required: ["table_name", "index_name", "columns"],
|
|
1380
|
+
},
|
|
1381
|
+
},
|
|
1382
|
+
{
|
|
1383
|
+
name: "drop_index",
|
|
1384
|
+
description: "Drops an index from a table. Requires 'ddl' permission.",
|
|
1385
|
+
inputSchema: {
|
|
1386
|
+
type: "object",
|
|
1387
|
+
properties: {
|
|
1388
|
+
table_name: { type: "string", description: "Name of the table" },
|
|
1389
|
+
index_name: {
|
|
1390
|
+
type: "string",
|
|
1391
|
+
description: "Name of the index to drop",
|
|
1392
|
+
},
|
|
1393
|
+
database: {
|
|
1394
|
+
type: "string",
|
|
1395
|
+
description: "Optional: specific database name",
|
|
1396
|
+
},
|
|
1397
|
+
},
|
|
1398
|
+
required: ["table_name", "index_name"],
|
|
1399
|
+
},
|
|
1400
|
+
},
|
|
1401
|
+
{
|
|
1402
|
+
name: "analyze_index",
|
|
1403
|
+
description: "Analyzes a table to update index statistics.",
|
|
1404
|
+
inputSchema: {
|
|
1405
|
+
type: "object",
|
|
1406
|
+
properties: {
|
|
1407
|
+
table_name: {
|
|
1408
|
+
type: "string",
|
|
1409
|
+
description: "Name of the table to analyze",
|
|
1410
|
+
},
|
|
1411
|
+
database: {
|
|
1412
|
+
type: "string",
|
|
1413
|
+
description: "Optional: specific database name",
|
|
1414
|
+
},
|
|
1415
|
+
},
|
|
1416
|
+
required: ["table_name"],
|
|
1417
|
+
},
|
|
1418
|
+
},
|
|
1419
|
+
// Constraint Tools
|
|
1420
|
+
{
|
|
1421
|
+
name: "list_foreign_keys",
|
|
1422
|
+
description: "Lists all foreign key constraints for a table.",
|
|
1423
|
+
inputSchema: {
|
|
1424
|
+
type: "object",
|
|
1425
|
+
properties: {
|
|
1426
|
+
table_name: { type: "string", description: "Name of the table" },
|
|
1427
|
+
database: {
|
|
1428
|
+
type: "string",
|
|
1429
|
+
description: "Optional: specific database name",
|
|
1430
|
+
},
|
|
1431
|
+
},
|
|
1432
|
+
required: ["table_name"],
|
|
1433
|
+
},
|
|
1434
|
+
},
|
|
1435
|
+
{
|
|
1436
|
+
name: "list_constraints",
|
|
1437
|
+
description: "Lists all constraints (PRIMARY KEY, FOREIGN KEY, UNIQUE, CHECK) for a table.",
|
|
1438
|
+
inputSchema: {
|
|
1439
|
+
type: "object",
|
|
1440
|
+
properties: {
|
|
1441
|
+
table_name: { type: "string", description: "Name of the table" },
|
|
1442
|
+
database: {
|
|
1443
|
+
type: "string",
|
|
1444
|
+
description: "Optional: specific database name",
|
|
1445
|
+
},
|
|
1446
|
+
},
|
|
1447
|
+
required: ["table_name"],
|
|
1448
|
+
},
|
|
1449
|
+
},
|
|
1450
|
+
{
|
|
1451
|
+
name: "add_foreign_key",
|
|
1452
|
+
description: "Adds a foreign key constraint to a table. Requires 'ddl' permission.",
|
|
1453
|
+
inputSchema: {
|
|
1454
|
+
type: "object",
|
|
1455
|
+
properties: {
|
|
1456
|
+
table_name: { type: "string", description: "Name of the table" },
|
|
1457
|
+
constraint_name: {
|
|
1458
|
+
type: "string",
|
|
1459
|
+
description: "Name of the constraint",
|
|
1460
|
+
},
|
|
1461
|
+
columns: {
|
|
1462
|
+
type: "array",
|
|
1463
|
+
items: { type: "string" },
|
|
1464
|
+
description: "Columns in the foreign key",
|
|
1465
|
+
},
|
|
1466
|
+
referenced_table: {
|
|
1467
|
+
type: "string",
|
|
1468
|
+
description: "Referenced table name",
|
|
1469
|
+
},
|
|
1470
|
+
referenced_columns: {
|
|
1471
|
+
type: "array",
|
|
1472
|
+
items: { type: "string" },
|
|
1473
|
+
description: "Referenced columns",
|
|
1474
|
+
},
|
|
1475
|
+
on_delete: {
|
|
1476
|
+
type: "string",
|
|
1477
|
+
enum: ["CASCADE", "SET NULL", "RESTRICT", "NO ACTION", "SET DEFAULT"],
|
|
1478
|
+
},
|
|
1479
|
+
on_update: {
|
|
1480
|
+
type: "string",
|
|
1481
|
+
enum: ["CASCADE", "SET NULL", "RESTRICT", "NO ACTION", "SET DEFAULT"],
|
|
1482
|
+
},
|
|
1483
|
+
database: {
|
|
1484
|
+
type: "string",
|
|
1485
|
+
description: "Optional: specific database name",
|
|
1486
|
+
},
|
|
1487
|
+
},
|
|
1488
|
+
required: [
|
|
1489
|
+
"table_name",
|
|
1490
|
+
"constraint_name",
|
|
1491
|
+
"columns",
|
|
1492
|
+
"referenced_table",
|
|
1493
|
+
"referenced_columns",
|
|
1494
|
+
],
|
|
1495
|
+
},
|
|
1496
|
+
},
|
|
1497
|
+
{
|
|
1498
|
+
name: "drop_foreign_key",
|
|
1499
|
+
description: "Drops a foreign key constraint. Requires 'ddl' permission.",
|
|
1500
|
+
inputSchema: {
|
|
1501
|
+
type: "object",
|
|
1502
|
+
properties: {
|
|
1503
|
+
table_name: { type: "string", description: "Name of the table" },
|
|
1504
|
+
constraint_name: {
|
|
1505
|
+
type: "string",
|
|
1506
|
+
description: "Name of the constraint to drop",
|
|
1507
|
+
},
|
|
1508
|
+
database: {
|
|
1509
|
+
type: "string",
|
|
1510
|
+
description: "Optional: specific database name",
|
|
1511
|
+
},
|
|
1512
|
+
},
|
|
1513
|
+
required: ["table_name", "constraint_name"],
|
|
1514
|
+
},
|
|
1515
|
+
},
|
|
1516
|
+
{
|
|
1517
|
+
name: "add_unique_constraint",
|
|
1518
|
+
description: "Adds a unique constraint to a table. Requires 'ddl' permission.",
|
|
1519
|
+
inputSchema: {
|
|
1520
|
+
type: "object",
|
|
1521
|
+
properties: {
|
|
1522
|
+
table_name: { type: "string", description: "Name of the table" },
|
|
1523
|
+
constraint_name: {
|
|
1524
|
+
type: "string",
|
|
1525
|
+
description: "Name of the constraint",
|
|
1526
|
+
},
|
|
1527
|
+
columns: {
|
|
1528
|
+
type: "array",
|
|
1529
|
+
items: { type: "string" },
|
|
1530
|
+
description: "Columns in the unique constraint",
|
|
1531
|
+
},
|
|
1532
|
+
database: {
|
|
1533
|
+
type: "string",
|
|
1534
|
+
description: "Optional: specific database name",
|
|
1535
|
+
},
|
|
1536
|
+
},
|
|
1537
|
+
required: ["table_name", "constraint_name", "columns"],
|
|
1538
|
+
},
|
|
1539
|
+
},
|
|
1540
|
+
{
|
|
1541
|
+
name: "drop_constraint",
|
|
1542
|
+
description: "Drops a UNIQUE or CHECK constraint. Requires 'ddl' permission.",
|
|
1543
|
+
inputSchema: {
|
|
1544
|
+
type: "object",
|
|
1545
|
+
properties: {
|
|
1546
|
+
table_name: { type: "string", description: "Name of the table" },
|
|
1547
|
+
constraint_name: {
|
|
1548
|
+
type: "string",
|
|
1549
|
+
description: "Name of the constraint",
|
|
1550
|
+
},
|
|
1551
|
+
constraint_type: {
|
|
1552
|
+
type: "string",
|
|
1553
|
+
enum: ["UNIQUE", "CHECK"],
|
|
1554
|
+
description: "Type of constraint",
|
|
1555
|
+
},
|
|
1556
|
+
database: {
|
|
1557
|
+
type: "string",
|
|
1558
|
+
description: "Optional: specific database name",
|
|
1559
|
+
},
|
|
1560
|
+
},
|
|
1561
|
+
required: ["table_name", "constraint_name", "constraint_type"],
|
|
1562
|
+
},
|
|
1563
|
+
},
|
|
1564
|
+
{
|
|
1565
|
+
name: "add_check_constraint",
|
|
1566
|
+
description: "Adds a CHECK constraint to a table (MySQL 8.0.16+). Requires 'ddl' permission.",
|
|
1567
|
+
inputSchema: {
|
|
1568
|
+
type: "object",
|
|
1569
|
+
properties: {
|
|
1570
|
+
table_name: { type: "string", description: "Name of the table" },
|
|
1571
|
+
constraint_name: {
|
|
1572
|
+
type: "string",
|
|
1573
|
+
description: "Name of the constraint",
|
|
1574
|
+
},
|
|
1575
|
+
expression: {
|
|
1576
|
+
type: "string",
|
|
1577
|
+
description: "Check expression (e.g., 'age >= 18')",
|
|
1578
|
+
},
|
|
1579
|
+
enforced: {
|
|
1580
|
+
type: "boolean",
|
|
1581
|
+
description: "Whether constraint is enforced (default: true)",
|
|
1582
|
+
},
|
|
1583
|
+
database: {
|
|
1584
|
+
type: "string",
|
|
1585
|
+
description: "Optional: specific database name",
|
|
1586
|
+
},
|
|
1587
|
+
},
|
|
1588
|
+
required: ["table_name", "constraint_name", "expression"],
|
|
1589
|
+
},
|
|
1590
|
+
},
|
|
1591
|
+
// Table Maintenance Tools
|
|
1592
|
+
{
|
|
1593
|
+
name: "analyze_table",
|
|
1594
|
+
description: "Analyzes a table to update index statistics for the query optimizer.",
|
|
1595
|
+
inputSchema: {
|
|
1596
|
+
type: "object",
|
|
1597
|
+
properties: {
|
|
1598
|
+
table_name: {
|
|
1599
|
+
type: "string",
|
|
1600
|
+
description: "Name of the table to analyze",
|
|
1601
|
+
},
|
|
1602
|
+
database: {
|
|
1603
|
+
type: "string",
|
|
1604
|
+
description: "Optional: specific database name",
|
|
1605
|
+
},
|
|
1606
|
+
},
|
|
1607
|
+
required: ["table_name"],
|
|
1608
|
+
},
|
|
1609
|
+
},
|
|
1610
|
+
{
|
|
1611
|
+
name: "optimize_table",
|
|
1612
|
+
description: "Optimizes a table to reclaim unused space and defragment data.",
|
|
1613
|
+
inputSchema: {
|
|
1614
|
+
type: "object",
|
|
1615
|
+
properties: {
|
|
1616
|
+
table_name: {
|
|
1617
|
+
type: "string",
|
|
1618
|
+
description: "Name of the table to optimize",
|
|
1619
|
+
},
|
|
1620
|
+
database: {
|
|
1621
|
+
type: "string",
|
|
1622
|
+
description: "Optional: specific database name",
|
|
1623
|
+
},
|
|
1624
|
+
},
|
|
1625
|
+
required: ["table_name"],
|
|
1626
|
+
},
|
|
1627
|
+
},
|
|
1628
|
+
{
|
|
1629
|
+
name: "check_table",
|
|
1630
|
+
description: "Checks a table for errors.",
|
|
1631
|
+
inputSchema: {
|
|
1632
|
+
type: "object",
|
|
1633
|
+
properties: {
|
|
1634
|
+
table_name: {
|
|
1635
|
+
type: "string",
|
|
1636
|
+
description: "Name of the table to check",
|
|
1637
|
+
},
|
|
1638
|
+
check_type: {
|
|
1639
|
+
type: "string",
|
|
1640
|
+
enum: ["QUICK", "FAST", "MEDIUM", "EXTENDED", "CHANGED"],
|
|
1641
|
+
description: "Type of check",
|
|
1642
|
+
},
|
|
1643
|
+
database: {
|
|
1644
|
+
type: "string",
|
|
1645
|
+
description: "Optional: specific database name",
|
|
1646
|
+
},
|
|
1647
|
+
},
|
|
1648
|
+
required: ["table_name"],
|
|
1649
|
+
},
|
|
1650
|
+
},
|
|
1651
|
+
{
|
|
1652
|
+
name: "repair_table",
|
|
1653
|
+
description: "Repairs a corrupted table (MyISAM, ARCHIVE, CSV only).",
|
|
1654
|
+
inputSchema: {
|
|
1655
|
+
type: "object",
|
|
1656
|
+
properties: {
|
|
1657
|
+
table_name: {
|
|
1658
|
+
type: "string",
|
|
1659
|
+
description: "Name of the table to repair",
|
|
1660
|
+
},
|
|
1661
|
+
quick: { type: "boolean", description: "Quick repair" },
|
|
1662
|
+
extended: { type: "boolean", description: "Extended repair" },
|
|
1663
|
+
use_frm: { type: "boolean", description: "Use .frm file to repair" },
|
|
1664
|
+
database: {
|
|
1665
|
+
type: "string",
|
|
1666
|
+
description: "Optional: specific database name",
|
|
1667
|
+
},
|
|
1668
|
+
},
|
|
1669
|
+
required: ["table_name"],
|
|
1670
|
+
},
|
|
1671
|
+
},
|
|
1672
|
+
{
|
|
1673
|
+
name: "truncate_table",
|
|
1674
|
+
description: "Truncates a table (removes all rows quickly). Requires 'ddl' permission. WARNING: This is irreversible!",
|
|
1675
|
+
inputSchema: {
|
|
1676
|
+
type: "object",
|
|
1677
|
+
properties: {
|
|
1678
|
+
table_name: {
|
|
1679
|
+
type: "string",
|
|
1680
|
+
description: "Name of the table to truncate",
|
|
1681
|
+
},
|
|
1682
|
+
database: {
|
|
1683
|
+
type: "string",
|
|
1684
|
+
description: "Optional: specific database name",
|
|
1685
|
+
},
|
|
1686
|
+
},
|
|
1687
|
+
required: ["table_name"],
|
|
1688
|
+
},
|
|
1689
|
+
},
|
|
1690
|
+
{
|
|
1691
|
+
name: "get_table_status",
|
|
1692
|
+
description: "Gets detailed status and statistics for one or all tables.",
|
|
1693
|
+
inputSchema: {
|
|
1694
|
+
type: "object",
|
|
1695
|
+
properties: {
|
|
1696
|
+
table_name: {
|
|
1697
|
+
type: "string",
|
|
1698
|
+
description: "Optional: specific table name (omit for all tables)",
|
|
1699
|
+
},
|
|
1700
|
+
database: {
|
|
1701
|
+
type: "string",
|
|
1702
|
+
description: "Optional: specific database name",
|
|
1703
|
+
},
|
|
1704
|
+
},
|
|
1705
|
+
},
|
|
1706
|
+
},
|
|
1707
|
+
{
|
|
1708
|
+
name: "flush_table",
|
|
1709
|
+
description: "Flushes table(s) - closes and reopens them.",
|
|
1710
|
+
inputSchema: {
|
|
1711
|
+
type: "object",
|
|
1712
|
+
properties: {
|
|
1713
|
+
table_name: {
|
|
1714
|
+
type: "string",
|
|
1715
|
+
description: "Optional: specific table (omit for all tables)",
|
|
1716
|
+
},
|
|
1717
|
+
with_read_lock: {
|
|
1718
|
+
type: "boolean",
|
|
1719
|
+
description: "Acquire read lock after flushing",
|
|
1720
|
+
},
|
|
1721
|
+
database: {
|
|
1722
|
+
type: "string",
|
|
1723
|
+
description: "Optional: specific database name",
|
|
1724
|
+
},
|
|
1725
|
+
},
|
|
1726
|
+
},
|
|
1727
|
+
},
|
|
1728
|
+
{
|
|
1729
|
+
name: "get_table_size",
|
|
1730
|
+
description: "Gets size information for one or all tables including data and index sizes.",
|
|
1731
|
+
inputSchema: {
|
|
1732
|
+
type: "object",
|
|
1733
|
+
properties: {
|
|
1734
|
+
table_name: {
|
|
1735
|
+
type: "string",
|
|
1736
|
+
description: "Optional: specific table name (omit for all tables)",
|
|
1737
|
+
},
|
|
1738
|
+
database: {
|
|
1739
|
+
type: "string",
|
|
1740
|
+
description: "Optional: specific database name",
|
|
1741
|
+
},
|
|
1742
|
+
},
|
|
1743
|
+
},
|
|
1744
|
+
},
|
|
1745
|
+
// Process Management Tools
|
|
1746
|
+
{
|
|
1747
|
+
name: "show_process_list",
|
|
1748
|
+
description: "Shows all running MySQL processes/connections.",
|
|
1749
|
+
inputSchema: {
|
|
1750
|
+
type: "object",
|
|
1751
|
+
properties: {
|
|
1752
|
+
full: { type: "boolean", description: "Show full query text" },
|
|
1753
|
+
},
|
|
1754
|
+
},
|
|
1755
|
+
},
|
|
1756
|
+
{
|
|
1757
|
+
name: "kill_process",
|
|
1758
|
+
description: "Kills a MySQL process/connection by ID.",
|
|
1759
|
+
inputSchema: {
|
|
1760
|
+
type: "object",
|
|
1761
|
+
properties: {
|
|
1762
|
+
process_id: { type: "number", description: "Process ID to kill" },
|
|
1763
|
+
type: {
|
|
1764
|
+
type: "string",
|
|
1765
|
+
enum: ["CONNECTION", "QUERY"],
|
|
1766
|
+
description: "Kill connection or just query",
|
|
1767
|
+
},
|
|
1768
|
+
},
|
|
1769
|
+
required: ["process_id"],
|
|
1770
|
+
},
|
|
1771
|
+
},
|
|
1772
|
+
{
|
|
1773
|
+
name: "show_status",
|
|
1774
|
+
description: "Shows MySQL server status variables.",
|
|
1775
|
+
inputSchema: {
|
|
1776
|
+
type: "object",
|
|
1777
|
+
properties: {
|
|
1778
|
+
like: {
|
|
1779
|
+
type: "string",
|
|
1780
|
+
description: "Optional: filter pattern (e.g., 'Thread%')",
|
|
1781
|
+
},
|
|
1782
|
+
global: {
|
|
1783
|
+
type: "boolean",
|
|
1784
|
+
description: "Show global status instead of session",
|
|
1785
|
+
},
|
|
1786
|
+
},
|
|
1787
|
+
},
|
|
1788
|
+
},
|
|
1789
|
+
{
|
|
1790
|
+
name: "show_variables",
|
|
1791
|
+
description: "Shows MySQL server configuration variables.",
|
|
1792
|
+
inputSchema: {
|
|
1793
|
+
type: "object",
|
|
1794
|
+
properties: {
|
|
1795
|
+
like: {
|
|
1796
|
+
type: "string",
|
|
1797
|
+
description: "Optional: filter pattern (e.g., 'max_%')",
|
|
1798
|
+
},
|
|
1799
|
+
global: {
|
|
1800
|
+
type: "boolean",
|
|
1801
|
+
description: "Show global variables instead of session",
|
|
1802
|
+
},
|
|
1803
|
+
},
|
|
1804
|
+
},
|
|
1805
|
+
},
|
|
1806
|
+
{
|
|
1807
|
+
name: "explain_query",
|
|
1808
|
+
description: "Shows the execution plan for a query (EXPLAIN).",
|
|
1809
|
+
inputSchema: {
|
|
1810
|
+
type: "object",
|
|
1811
|
+
properties: {
|
|
1812
|
+
query: { type: "string", description: "SQL query to explain" },
|
|
1813
|
+
format: {
|
|
1814
|
+
type: "string",
|
|
1815
|
+
enum: ["TRADITIONAL", "JSON", "TREE"],
|
|
1816
|
+
description: "Output format",
|
|
1817
|
+
},
|
|
1818
|
+
analyze: {
|
|
1819
|
+
type: "boolean",
|
|
1820
|
+
description: "Actually execute the query and show real statistics",
|
|
1821
|
+
},
|
|
1822
|
+
},
|
|
1823
|
+
required: ["query"],
|
|
1824
|
+
},
|
|
1825
|
+
},
|
|
1826
|
+
{
|
|
1827
|
+
name: "show_engine_status",
|
|
1828
|
+
description: "Shows storage engine status (InnoDB by default).",
|
|
1829
|
+
inputSchema: {
|
|
1830
|
+
type: "object",
|
|
1831
|
+
properties: {
|
|
1832
|
+
engine: {
|
|
1833
|
+
type: "string",
|
|
1834
|
+
description: "Engine name (INNODB, PERFORMANCE_SCHEMA, etc.)",
|
|
1835
|
+
},
|
|
1836
|
+
},
|
|
1837
|
+
},
|
|
1838
|
+
},
|
|
1839
|
+
{
|
|
1840
|
+
name: "get_server_info",
|
|
1841
|
+
description: "Gets comprehensive MySQL server information including version, uptime, and statistics.",
|
|
1842
|
+
inputSchema: {
|
|
1843
|
+
type: "object",
|
|
1844
|
+
properties: {},
|
|
1845
|
+
},
|
|
1846
|
+
},
|
|
1847
|
+
{
|
|
1848
|
+
name: "show_binary_logs",
|
|
1849
|
+
description: "Shows binary log files on the server.",
|
|
1850
|
+
inputSchema: {
|
|
1851
|
+
type: "object",
|
|
1852
|
+
properties: {},
|
|
1853
|
+
},
|
|
1854
|
+
},
|
|
1855
|
+
{
|
|
1856
|
+
name: "show_replication_status",
|
|
1857
|
+
description: "Shows replication status (master or replica).",
|
|
1858
|
+
inputSchema: {
|
|
1859
|
+
type: "object",
|
|
1860
|
+
properties: {
|
|
1861
|
+
type: {
|
|
1862
|
+
type: "string",
|
|
1863
|
+
enum: ["MASTER", "REPLICA", "SLAVE"],
|
|
1864
|
+
description: "Which status to show",
|
|
1865
|
+
},
|
|
1866
|
+
},
|
|
1867
|
+
},
|
|
1868
|
+
},
|
|
1869
|
+
];
|
|
1870
|
+
// Create the MCP server
|
|
1871
|
+
const server = new index_js_1.Server({
|
|
1872
|
+
name: "mysql-mcp-server",
|
|
1873
|
+
version: "1.4.4",
|
|
1874
|
+
}, {
|
|
1875
|
+
capabilities: {
|
|
1876
|
+
tools: {},
|
|
1877
|
+
},
|
|
1878
|
+
});
|
|
1879
|
+
// Handle list tools request
|
|
1880
|
+
server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => {
|
|
1881
|
+
return {
|
|
1882
|
+
tools: TOOLS,
|
|
1883
|
+
};
|
|
1884
|
+
});
|
|
1885
|
+
// Handle tool call requests
|
|
1886
|
+
server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
|
|
1887
|
+
const { name, arguments: args } = request.params;
|
|
1888
|
+
try {
|
|
1889
|
+
let result;
|
|
1890
|
+
switch (name) {
|
|
1891
|
+
case "list_databases":
|
|
1892
|
+
result = await mysqlMCP.listDatabases();
|
|
1893
|
+
break;
|
|
1894
|
+
case "list_tables":
|
|
1895
|
+
result = await mysqlMCP.listTables((args || {}));
|
|
1896
|
+
break;
|
|
1897
|
+
case "read_table_schema":
|
|
1898
|
+
result = await mysqlMCP.readTableSchema((args || {}));
|
|
1899
|
+
break;
|
|
1900
|
+
case "create_record":
|
|
1901
|
+
result = await mysqlMCP.createRecord((args || {}));
|
|
1902
|
+
break;
|
|
1903
|
+
case "read_records":
|
|
1904
|
+
result = await mysqlMCP.readRecords((args || {}));
|
|
1905
|
+
break;
|
|
1906
|
+
case "update_record":
|
|
1907
|
+
result = await mysqlMCP.updateRecord((args || {}));
|
|
1908
|
+
break;
|
|
1909
|
+
case "delete_record":
|
|
1910
|
+
result = await mysqlMCP.deleteRecord((args || {}));
|
|
1911
|
+
break;
|
|
1912
|
+
case "bulk_insert":
|
|
1913
|
+
result = await mysqlMCP.bulkInsert((args || {}));
|
|
1914
|
+
break;
|
|
1915
|
+
case "bulk_update":
|
|
1916
|
+
result = await mysqlMCP.bulkUpdate((args || {}));
|
|
1917
|
+
break;
|
|
1918
|
+
case "bulk_delete":
|
|
1919
|
+
result = await mysqlMCP.bulkDelete((args || {}));
|
|
1920
|
+
break;
|
|
1921
|
+
case "run_query":
|
|
1922
|
+
result = await mysqlMCP.runQuery((args || {}));
|
|
1923
|
+
break;
|
|
1924
|
+
case "execute_sql":
|
|
1925
|
+
result = await mysqlMCP.executeSql((args || {}));
|
|
1926
|
+
break;
|
|
1927
|
+
case "create_table":
|
|
1928
|
+
result = await mysqlMCP.createTable(args || {});
|
|
1929
|
+
break;
|
|
1930
|
+
case "alter_table":
|
|
1931
|
+
result = await mysqlMCP.alterTable(args || {});
|
|
1932
|
+
break;
|
|
1933
|
+
case "drop_table":
|
|
1934
|
+
result = await mysqlMCP.dropTable(args || {});
|
|
1935
|
+
break;
|
|
1936
|
+
case "execute_ddl":
|
|
1937
|
+
result = await mysqlMCP.executeDdl((args || {}));
|
|
1938
|
+
break;
|
|
1939
|
+
case "describe_connection":
|
|
1940
|
+
result = await mysqlMCP.describeConnection();
|
|
1941
|
+
break;
|
|
1942
|
+
case "test_connection":
|
|
1943
|
+
result = await mysqlMCP.testConnection();
|
|
1944
|
+
break;
|
|
1945
|
+
case "get_table_relationships":
|
|
1946
|
+
result = await mysqlMCP.getTableRelationships((args || {}));
|
|
1947
|
+
break;
|
|
1948
|
+
// Transaction Tools
|
|
1949
|
+
case "begin_transaction":
|
|
1950
|
+
result = await mysqlMCP.beginTransaction((args || {}));
|
|
1951
|
+
break;
|
|
1952
|
+
case "commit_transaction":
|
|
1953
|
+
result = await mysqlMCP.commitTransaction((args || {}));
|
|
1954
|
+
break;
|
|
1955
|
+
case "rollback_transaction":
|
|
1956
|
+
result = await mysqlMCP.rollbackTransaction((args || {}));
|
|
1957
|
+
break;
|
|
1958
|
+
case "get_transaction_status":
|
|
1959
|
+
result = await mysqlMCP.getTransactionStatus();
|
|
1960
|
+
break;
|
|
1961
|
+
case "execute_in_transaction":
|
|
1962
|
+
result = await mysqlMCP.executeInTransaction((args || {}));
|
|
1963
|
+
break;
|
|
1964
|
+
// Stored Procedure Tools
|
|
1965
|
+
case "list_stored_procedures":
|
|
1966
|
+
result = await mysqlMCP.listStoredProcedures((args || {}));
|
|
1967
|
+
break;
|
|
1968
|
+
case "get_stored_procedure_info":
|
|
1969
|
+
result = await mysqlMCP.getStoredProcedureInfo((args || {}));
|
|
1970
|
+
break;
|
|
1971
|
+
case "execute_stored_procedure":
|
|
1972
|
+
result = await mysqlMCP.executeStoredProcedure((args || {}));
|
|
1973
|
+
break;
|
|
1974
|
+
case "create_stored_procedure":
|
|
1975
|
+
result = await mysqlMCP.createStoredProcedure((args || {}));
|
|
1976
|
+
break;
|
|
1977
|
+
case "drop_stored_procedure":
|
|
1978
|
+
result = await mysqlMCP.dropStoredProcedure((args || {}));
|
|
1979
|
+
break;
|
|
1980
|
+
case "show_create_procedure":
|
|
1981
|
+
result = await mysqlMCP.showCreateProcedure((args || {}));
|
|
1982
|
+
break;
|
|
1983
|
+
// Data Export Tools
|
|
1984
|
+
case "export_table_to_csv":
|
|
1985
|
+
result = await mysqlMCP.exportTableToCSV((args || {}));
|
|
1986
|
+
break;
|
|
1987
|
+
case "export_query_to_csv":
|
|
1988
|
+
result = await mysqlMCP.exportQueryToCSV((args || {}));
|
|
1989
|
+
break;
|
|
1990
|
+
// Cache Management Tools
|
|
1991
|
+
case "get_cache_stats":
|
|
1992
|
+
result = mysqlMCP.getCacheStats();
|
|
1993
|
+
break;
|
|
1994
|
+
case "get_cache_config":
|
|
1995
|
+
result = mysqlMCP.getCacheConfig();
|
|
1996
|
+
break;
|
|
1997
|
+
case "configure_cache":
|
|
1998
|
+
result = mysqlMCP.configureCacheSettings((args || {}));
|
|
1999
|
+
break;
|
|
2000
|
+
case "clear_cache":
|
|
2001
|
+
result = mysqlMCP.clearCache();
|
|
2002
|
+
break;
|
|
2003
|
+
case "invalidate_table_cache":
|
|
2004
|
+
result = mysqlMCP.invalidateCacheForTable((args || {}));
|
|
2005
|
+
break;
|
|
2006
|
+
// Query Optimization Tools
|
|
2007
|
+
case "analyze_query":
|
|
2008
|
+
result = mysqlMCP.analyzeQuery((args || {}));
|
|
2009
|
+
break;
|
|
2010
|
+
case "get_optimization_hints":
|
|
2011
|
+
result = mysqlMCP.getOptimizationHints((args || {}));
|
|
2012
|
+
break;
|
|
2013
|
+
// View Tools
|
|
2014
|
+
case "list_views":
|
|
2015
|
+
result = await mysqlMCP.listViews((args || {}));
|
|
2016
|
+
break;
|
|
2017
|
+
case "get_view_info":
|
|
2018
|
+
result = await mysqlMCP.getViewInfo((args || {}));
|
|
2019
|
+
break;
|
|
2020
|
+
case "create_view":
|
|
2021
|
+
result = await mysqlMCP.createView((args || {}));
|
|
2022
|
+
break;
|
|
2023
|
+
case "alter_view":
|
|
2024
|
+
result = await mysqlMCP.alterView((args || {}));
|
|
2025
|
+
break;
|
|
2026
|
+
case "drop_view":
|
|
2027
|
+
result = await mysqlMCP.dropView((args || {}));
|
|
2028
|
+
break;
|
|
2029
|
+
case "show_create_view":
|
|
2030
|
+
result = await mysqlMCP.showCreateView((args || {}));
|
|
2031
|
+
break;
|
|
2032
|
+
// Trigger Tools
|
|
2033
|
+
case "list_triggers":
|
|
2034
|
+
result = await mysqlMCP.listTriggers((args || {}));
|
|
2035
|
+
break;
|
|
2036
|
+
case "get_trigger_info":
|
|
2037
|
+
result = await mysqlMCP.getTriggerInfo((args || {}));
|
|
2038
|
+
break;
|
|
2039
|
+
case "create_trigger":
|
|
2040
|
+
result = await mysqlMCP.createTrigger((args || {}));
|
|
2041
|
+
break;
|
|
2042
|
+
case "drop_trigger":
|
|
2043
|
+
result = await mysqlMCP.dropTrigger((args || {}));
|
|
2044
|
+
break;
|
|
2045
|
+
case "show_create_trigger":
|
|
2046
|
+
result = await mysqlMCP.showCreateTrigger((args || {}));
|
|
2047
|
+
break;
|
|
2048
|
+
// Function Tools
|
|
2049
|
+
case "list_functions":
|
|
2050
|
+
result = await mysqlMCP.listFunctions((args || {}));
|
|
2051
|
+
break;
|
|
2052
|
+
case "get_function_info":
|
|
2053
|
+
result = await mysqlMCP.getFunctionInfo((args || {}));
|
|
2054
|
+
break;
|
|
2055
|
+
case "create_function":
|
|
2056
|
+
result = await mysqlMCP.createFunction((args || {}));
|
|
2057
|
+
break;
|
|
2058
|
+
case "drop_function":
|
|
2059
|
+
result = await mysqlMCP.dropFunction((args || {}));
|
|
2060
|
+
break;
|
|
2061
|
+
case "show_create_function":
|
|
2062
|
+
result = await mysqlMCP.showCreateFunction((args || {}));
|
|
2063
|
+
break;
|
|
2064
|
+
case "execute_function":
|
|
2065
|
+
result = await mysqlMCP.executeFunction((args || {}));
|
|
2066
|
+
break;
|
|
2067
|
+
// Index Tools
|
|
2068
|
+
case "list_indexes":
|
|
2069
|
+
result = await mysqlMCP.listIndexes((args || {}));
|
|
2070
|
+
break;
|
|
2071
|
+
case "get_index_info":
|
|
2072
|
+
result = await mysqlMCP.getIndexInfo((args || {}));
|
|
2073
|
+
break;
|
|
2074
|
+
case "create_index":
|
|
2075
|
+
result = await mysqlMCP.createIndex((args || {}));
|
|
2076
|
+
break;
|
|
2077
|
+
case "drop_index":
|
|
2078
|
+
result = await mysqlMCP.dropIndex((args || {}));
|
|
2079
|
+
break;
|
|
2080
|
+
case "analyze_index":
|
|
2081
|
+
result = await mysqlMCP.analyzeIndex((args || {}));
|
|
2082
|
+
break;
|
|
2083
|
+
// Constraint Tools
|
|
2084
|
+
case "list_foreign_keys":
|
|
2085
|
+
result = await mysqlMCP.listForeignKeys((args || {}));
|
|
2086
|
+
break;
|
|
2087
|
+
case "list_constraints":
|
|
2088
|
+
result = await mysqlMCP.listConstraints((args || {}));
|
|
2089
|
+
break;
|
|
2090
|
+
case "add_foreign_key":
|
|
2091
|
+
result = await mysqlMCP.addForeignKey((args || {}));
|
|
2092
|
+
break;
|
|
2093
|
+
case "drop_foreign_key":
|
|
2094
|
+
result = await mysqlMCP.dropForeignKey((args || {}));
|
|
2095
|
+
break;
|
|
2096
|
+
case "add_unique_constraint":
|
|
2097
|
+
result = await mysqlMCP.addUniqueConstraint((args || {}));
|
|
2098
|
+
break;
|
|
2099
|
+
case "drop_constraint":
|
|
2100
|
+
result = await mysqlMCP.dropConstraint((args || {}));
|
|
2101
|
+
break;
|
|
2102
|
+
case "add_check_constraint":
|
|
2103
|
+
result = await mysqlMCP.addCheckConstraint((args || {}));
|
|
2104
|
+
break;
|
|
2105
|
+
// Table Maintenance Tools
|
|
2106
|
+
case "analyze_table":
|
|
2107
|
+
result = await mysqlMCP.analyzeTable((args || {}));
|
|
2108
|
+
break;
|
|
2109
|
+
case "optimize_table":
|
|
2110
|
+
result = await mysqlMCP.optimizeTable((args || {}));
|
|
2111
|
+
break;
|
|
2112
|
+
case "check_table":
|
|
2113
|
+
result = await mysqlMCP.checkTable((args || {}));
|
|
2114
|
+
break;
|
|
2115
|
+
case "repair_table":
|
|
2116
|
+
result = await mysqlMCP.repairTable((args || {}));
|
|
2117
|
+
break;
|
|
2118
|
+
case "truncate_table":
|
|
2119
|
+
result = await mysqlMCP.truncateTable((args || {}));
|
|
2120
|
+
break;
|
|
2121
|
+
case "get_table_status":
|
|
2122
|
+
result = await mysqlMCP.getTableStatus((args || {}));
|
|
2123
|
+
break;
|
|
2124
|
+
case "flush_table":
|
|
2125
|
+
result = await mysqlMCP.flushTable((args || {}));
|
|
2126
|
+
break;
|
|
2127
|
+
case "get_table_size":
|
|
2128
|
+
result = await mysqlMCP.getTableSize((args || {}));
|
|
2129
|
+
break;
|
|
2130
|
+
// Process Management Tools
|
|
2131
|
+
case "show_process_list":
|
|
2132
|
+
result = await mysqlMCP.showProcessList((args || {}));
|
|
2133
|
+
break;
|
|
2134
|
+
case "kill_process":
|
|
2135
|
+
result = await mysqlMCP.killProcess((args || {}));
|
|
2136
|
+
break;
|
|
2137
|
+
case "show_status":
|
|
2138
|
+
result = await mysqlMCP.showStatus((args || {}));
|
|
2139
|
+
break;
|
|
2140
|
+
case "show_variables":
|
|
2141
|
+
result = await mysqlMCP.showVariables((args || {}));
|
|
2142
|
+
break;
|
|
2143
|
+
case "explain_query":
|
|
2144
|
+
result = await mysqlMCP.explainQuery((args || {}));
|
|
2145
|
+
break;
|
|
2146
|
+
case "show_engine_status":
|
|
2147
|
+
result = await mysqlMCP.showEngineStatus((args || {}));
|
|
2148
|
+
break;
|
|
2149
|
+
case "get_server_info":
|
|
2150
|
+
result = await mysqlMCP.getServerInfo();
|
|
2151
|
+
break;
|
|
2152
|
+
case "show_binary_logs":
|
|
2153
|
+
result = await mysqlMCP.showBinaryLogs();
|
|
2154
|
+
break;
|
|
2155
|
+
case "show_replication_status":
|
|
2156
|
+
result = await mysqlMCP.showReplicationStatus((args || {}));
|
|
929
2157
|
break;
|
|
930
2158
|
default:
|
|
931
2159
|
throw new Error(`Unknown tool: ${name}`);
|
|
@@ -933,8 +2161,8 @@ server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
|
|
|
933
2161
|
// Handle the result based on status
|
|
934
2162
|
if (result.status === "error") {
|
|
935
2163
|
// Include query log in error response if available
|
|
936
|
-
let errorText = `Error: ${result.error}`;
|
|
937
|
-
if (
|
|
2164
|
+
let errorText = `Error: ${"error" in result ? result.error : "Unknown error"}`;
|
|
2165
|
+
if ("queryLog" in result && result.queryLog) {
|
|
938
2166
|
errorText += `\n\n${result.queryLog}`;
|
|
939
2167
|
}
|
|
940
2168
|
return {
|
|
@@ -975,11 +2203,11 @@ server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
|
|
|
975
2203
|
}
|
|
976
2204
|
// NEW APPROACH: Wrap the data with SQL query as part of the response structure
|
|
977
2205
|
// This forces the LLM to see and describe the SQL query as part of the data
|
|
978
|
-
if (
|
|
2206
|
+
if ("queryLog" in result && result.queryLog) {
|
|
979
2207
|
const wrappedResponse = {
|
|
980
2208
|
"⚠️ IMPORTANT_INSTRUCTION_TO_ASSISTANT": "ALWAYS display the SQL query execution details below to the user in your response. This is critical information that users need to see.",
|
|
981
2209
|
"⚠️ SQL_QUERY_EXECUTED": result.queryLog,
|
|
982
|
-
"📊 RESULTS": responseData
|
|
2210
|
+
"📊 RESULTS": responseData,
|
|
983
2211
|
};
|
|
984
2212
|
return {
|
|
985
2213
|
content: [
|