@berthojoris/mcp-mysql-server 1.6.3 → 1.8.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 +551 -28
- package/README.md +36 -117
- package/dist/config/featureConfig.js +30 -0
- package/dist/index.d.ts +185 -0
- package/dist/index.js +113 -0
- package/dist/mcp-server.js +551 -0
- package/dist/tools/backupRestoreTools.d.ts +91 -0
- package/dist/tools/backupRestoreTools.js +584 -0
- package/dist/tools/dataExportTools.d.ts +91 -2
- package/dist/tools/dataExportTools.js +726 -66
- package/dist/tools/migrationTools.d.ts +96 -0
- package/dist/tools/migrationTools.js +546 -0
- package/package.json +2 -2
package/dist/mcp-server.js
CHANGED
|
@@ -1866,6 +1866,508 @@ const TOOLS = [
|
|
|
1866
1866
|
},
|
|
1867
1867
|
},
|
|
1868
1868
|
},
|
|
1869
|
+
// Backup and Restore Tools
|
|
1870
|
+
{
|
|
1871
|
+
name: "backup_table",
|
|
1872
|
+
description: "Backup a single table to SQL dump format including structure and optionally data.",
|
|
1873
|
+
inputSchema: {
|
|
1874
|
+
type: "object",
|
|
1875
|
+
properties: {
|
|
1876
|
+
table_name: {
|
|
1877
|
+
type: "string",
|
|
1878
|
+
description: "Name of the table to backup",
|
|
1879
|
+
},
|
|
1880
|
+
include_data: {
|
|
1881
|
+
type: "boolean",
|
|
1882
|
+
description: "Include table data in the backup (default: true)",
|
|
1883
|
+
},
|
|
1884
|
+
include_drop: {
|
|
1885
|
+
type: "boolean",
|
|
1886
|
+
description: "Include DROP TABLE IF EXISTS statement (default: true)",
|
|
1887
|
+
},
|
|
1888
|
+
database: {
|
|
1889
|
+
type: "string",
|
|
1890
|
+
description: "Optional: specific database name",
|
|
1891
|
+
},
|
|
1892
|
+
},
|
|
1893
|
+
required: ["table_name"],
|
|
1894
|
+
},
|
|
1895
|
+
},
|
|
1896
|
+
{
|
|
1897
|
+
name: "backup_database",
|
|
1898
|
+
description: "Backup entire database or selected tables to SQL dump format.",
|
|
1899
|
+
inputSchema: {
|
|
1900
|
+
type: "object",
|
|
1901
|
+
properties: {
|
|
1902
|
+
include_data: {
|
|
1903
|
+
type: "boolean",
|
|
1904
|
+
description: "Include table data in the backup (default: true)",
|
|
1905
|
+
},
|
|
1906
|
+
include_drop: {
|
|
1907
|
+
type: "boolean",
|
|
1908
|
+
description: "Include DROP TABLE IF EXISTS statements (default: true)",
|
|
1909
|
+
},
|
|
1910
|
+
tables: {
|
|
1911
|
+
type: "array",
|
|
1912
|
+
items: { type: "string" },
|
|
1913
|
+
description: "Optional: specific tables to backup (default: all tables)",
|
|
1914
|
+
},
|
|
1915
|
+
database: {
|
|
1916
|
+
type: "string",
|
|
1917
|
+
description: "Optional: specific database name",
|
|
1918
|
+
},
|
|
1919
|
+
},
|
|
1920
|
+
},
|
|
1921
|
+
},
|
|
1922
|
+
{
|
|
1923
|
+
name: "restore_from_sql",
|
|
1924
|
+
description: "Restore database from SQL dump content. Executes SQL statements from the provided dump. Requires 'ddl' permission.",
|
|
1925
|
+
inputSchema: {
|
|
1926
|
+
type: "object",
|
|
1927
|
+
properties: {
|
|
1928
|
+
sql_dump: {
|
|
1929
|
+
type: "string",
|
|
1930
|
+
description: "SQL dump content to restore",
|
|
1931
|
+
},
|
|
1932
|
+
stop_on_error: {
|
|
1933
|
+
type: "boolean",
|
|
1934
|
+
description: "Stop execution on first error (default: true)",
|
|
1935
|
+
},
|
|
1936
|
+
database: {
|
|
1937
|
+
type: "string",
|
|
1938
|
+
description: "Optional: specific database name",
|
|
1939
|
+
},
|
|
1940
|
+
},
|
|
1941
|
+
required: ["sql_dump"],
|
|
1942
|
+
},
|
|
1943
|
+
},
|
|
1944
|
+
{
|
|
1945
|
+
name: "get_create_table_statement",
|
|
1946
|
+
description: "Get the CREATE TABLE statement for a specific table.",
|
|
1947
|
+
inputSchema: {
|
|
1948
|
+
type: "object",
|
|
1949
|
+
properties: {
|
|
1950
|
+
table_name: {
|
|
1951
|
+
type: "string",
|
|
1952
|
+
description: "Name of the table",
|
|
1953
|
+
},
|
|
1954
|
+
database: {
|
|
1955
|
+
type: "string",
|
|
1956
|
+
description: "Optional: specific database name",
|
|
1957
|
+
},
|
|
1958
|
+
},
|
|
1959
|
+
required: ["table_name"],
|
|
1960
|
+
},
|
|
1961
|
+
},
|
|
1962
|
+
{
|
|
1963
|
+
name: "get_database_schema",
|
|
1964
|
+
description: "Get complete database schema including tables, views, procedures, functions, and triggers.",
|
|
1965
|
+
inputSchema: {
|
|
1966
|
+
type: "object",
|
|
1967
|
+
properties: {
|
|
1968
|
+
database: {
|
|
1969
|
+
type: "string",
|
|
1970
|
+
description: "Optional: specific database name",
|
|
1971
|
+
},
|
|
1972
|
+
include_views: {
|
|
1973
|
+
type: "boolean",
|
|
1974
|
+
description: "Include views in schema (default: true)",
|
|
1975
|
+
},
|
|
1976
|
+
include_procedures: {
|
|
1977
|
+
type: "boolean",
|
|
1978
|
+
description: "Include stored procedures in schema (default: true)",
|
|
1979
|
+
},
|
|
1980
|
+
include_functions: {
|
|
1981
|
+
type: "boolean",
|
|
1982
|
+
description: "Include functions in schema (default: true)",
|
|
1983
|
+
},
|
|
1984
|
+
include_triggers: {
|
|
1985
|
+
type: "boolean",
|
|
1986
|
+
description: "Include triggers in schema (default: true)",
|
|
1987
|
+
},
|
|
1988
|
+
},
|
|
1989
|
+
},
|
|
1990
|
+
},
|
|
1991
|
+
// Extended Data Export Tools (JSON, SQL)
|
|
1992
|
+
{
|
|
1993
|
+
name: "export_table_to_json",
|
|
1994
|
+
description: "Export table data to JSON format with optional filtering, pagination, and sorting.",
|
|
1995
|
+
inputSchema: {
|
|
1996
|
+
type: "object",
|
|
1997
|
+
properties: {
|
|
1998
|
+
table_name: {
|
|
1999
|
+
type: "string",
|
|
2000
|
+
description: "Name of the table to export",
|
|
2001
|
+
},
|
|
2002
|
+
filters: {
|
|
2003
|
+
type: "array",
|
|
2004
|
+
description: "Array of filter conditions",
|
|
2005
|
+
items: {
|
|
2006
|
+
type: "object",
|
|
2007
|
+
properties: {
|
|
2008
|
+
field: { type: "string" },
|
|
2009
|
+
operator: {
|
|
2010
|
+
type: "string",
|
|
2011
|
+
enum: ["eq", "neq", "gt", "gte", "lt", "lte", "like", "in"],
|
|
2012
|
+
},
|
|
2013
|
+
value: {},
|
|
2014
|
+
},
|
|
2015
|
+
required: ["field", "operator", "value"],
|
|
2016
|
+
},
|
|
2017
|
+
},
|
|
2018
|
+
pagination: {
|
|
2019
|
+
type: "object",
|
|
2020
|
+
properties: {
|
|
2021
|
+
page: { type: "number" },
|
|
2022
|
+
limit: { type: "number" },
|
|
2023
|
+
},
|
|
2024
|
+
},
|
|
2025
|
+
sorting: {
|
|
2026
|
+
type: "object",
|
|
2027
|
+
properties: {
|
|
2028
|
+
field: { type: "string" },
|
|
2029
|
+
direction: { type: "string", enum: ["asc", "desc"] },
|
|
2030
|
+
},
|
|
2031
|
+
},
|
|
2032
|
+
pretty: {
|
|
2033
|
+
type: "boolean",
|
|
2034
|
+
description: "Pretty print JSON output (default: true)",
|
|
2035
|
+
},
|
|
2036
|
+
database: {
|
|
2037
|
+
type: "string",
|
|
2038
|
+
description: "Optional: specific database name",
|
|
2039
|
+
},
|
|
2040
|
+
},
|
|
2041
|
+
required: ["table_name"],
|
|
2042
|
+
},
|
|
2043
|
+
},
|
|
2044
|
+
{
|
|
2045
|
+
name: "export_query_to_json",
|
|
2046
|
+
description: "Export the results of a SELECT query to JSON format.",
|
|
2047
|
+
inputSchema: {
|
|
2048
|
+
type: "object",
|
|
2049
|
+
properties: {
|
|
2050
|
+
query: {
|
|
2051
|
+
type: "string",
|
|
2052
|
+
description: "SQL SELECT query to execute and export",
|
|
2053
|
+
},
|
|
2054
|
+
params: {
|
|
2055
|
+
type: "array",
|
|
2056
|
+
description: "Optional array of parameters for parameterized queries",
|
|
2057
|
+
items: {},
|
|
2058
|
+
},
|
|
2059
|
+
pretty: {
|
|
2060
|
+
type: "boolean",
|
|
2061
|
+
description: "Pretty print JSON output (default: true)",
|
|
2062
|
+
},
|
|
2063
|
+
},
|
|
2064
|
+
required: ["query"],
|
|
2065
|
+
},
|
|
2066
|
+
},
|
|
2067
|
+
{
|
|
2068
|
+
name: "export_table_to_sql",
|
|
2069
|
+
description: "Export table data to SQL INSERT statements with optional CREATE TABLE.",
|
|
2070
|
+
inputSchema: {
|
|
2071
|
+
type: "object",
|
|
2072
|
+
properties: {
|
|
2073
|
+
table_name: {
|
|
2074
|
+
type: "string",
|
|
2075
|
+
description: "Name of the table to export",
|
|
2076
|
+
},
|
|
2077
|
+
filters: {
|
|
2078
|
+
type: "array",
|
|
2079
|
+
description: "Array of filter conditions",
|
|
2080
|
+
items: {
|
|
2081
|
+
type: "object",
|
|
2082
|
+
properties: {
|
|
2083
|
+
field: { type: "string" },
|
|
2084
|
+
operator: {
|
|
2085
|
+
type: "string",
|
|
2086
|
+
enum: ["eq", "neq", "gt", "gte", "lt", "lte", "like", "in"],
|
|
2087
|
+
},
|
|
2088
|
+
value: {},
|
|
2089
|
+
},
|
|
2090
|
+
required: ["field", "operator", "value"],
|
|
2091
|
+
},
|
|
2092
|
+
},
|
|
2093
|
+
include_create_table: {
|
|
2094
|
+
type: "boolean",
|
|
2095
|
+
description: "Include CREATE TABLE statement (default: false)",
|
|
2096
|
+
},
|
|
2097
|
+
batch_size: {
|
|
2098
|
+
type: "number",
|
|
2099
|
+
description: "Number of rows per INSERT statement (default: 100)",
|
|
2100
|
+
},
|
|
2101
|
+
database: {
|
|
2102
|
+
type: "string",
|
|
2103
|
+
description: "Optional: specific database name",
|
|
2104
|
+
},
|
|
2105
|
+
},
|
|
2106
|
+
required: ["table_name"],
|
|
2107
|
+
},
|
|
2108
|
+
},
|
|
2109
|
+
// Data Import Tools
|
|
2110
|
+
{
|
|
2111
|
+
name: "import_from_csv",
|
|
2112
|
+
description: "Import data from CSV string into a table. Requires 'create' permission.",
|
|
2113
|
+
inputSchema: {
|
|
2114
|
+
type: "object",
|
|
2115
|
+
properties: {
|
|
2116
|
+
table_name: {
|
|
2117
|
+
type: "string",
|
|
2118
|
+
description: "Name of the table to import into",
|
|
2119
|
+
},
|
|
2120
|
+
csv_data: {
|
|
2121
|
+
type: "string",
|
|
2122
|
+
description: "CSV data as a string",
|
|
2123
|
+
},
|
|
2124
|
+
has_headers: {
|
|
2125
|
+
type: "boolean",
|
|
2126
|
+
description: "CSV has header row (default: true)",
|
|
2127
|
+
},
|
|
2128
|
+
column_mapping: {
|
|
2129
|
+
type: "object",
|
|
2130
|
+
description: "Optional: map CSV columns to table columns {csv_col: table_col}",
|
|
2131
|
+
additionalProperties: { type: "string" },
|
|
2132
|
+
},
|
|
2133
|
+
skip_errors: {
|
|
2134
|
+
type: "boolean",
|
|
2135
|
+
description: "Continue on row errors (default: false)",
|
|
2136
|
+
},
|
|
2137
|
+
batch_size: {
|
|
2138
|
+
type: "number",
|
|
2139
|
+
description: "Number of rows per batch insert (default: 100)",
|
|
2140
|
+
},
|
|
2141
|
+
database: {
|
|
2142
|
+
type: "string",
|
|
2143
|
+
description: "Optional: specific database name",
|
|
2144
|
+
},
|
|
2145
|
+
},
|
|
2146
|
+
required: ["table_name", "csv_data"],
|
|
2147
|
+
},
|
|
2148
|
+
},
|
|
2149
|
+
{
|
|
2150
|
+
name: "import_from_json",
|
|
2151
|
+
description: "Import data from JSON array string into a table. Requires 'create' permission.",
|
|
2152
|
+
inputSchema: {
|
|
2153
|
+
type: "object",
|
|
2154
|
+
properties: {
|
|
2155
|
+
table_name: {
|
|
2156
|
+
type: "string",
|
|
2157
|
+
description: "Name of the table to import into",
|
|
2158
|
+
},
|
|
2159
|
+
json_data: {
|
|
2160
|
+
type: "string",
|
|
2161
|
+
description: "JSON array of objects as a string",
|
|
2162
|
+
},
|
|
2163
|
+
column_mapping: {
|
|
2164
|
+
type: "object",
|
|
2165
|
+
description: "Optional: map JSON keys to table columns {json_key: table_col}",
|
|
2166
|
+
additionalProperties: { type: "string" },
|
|
2167
|
+
},
|
|
2168
|
+
skip_errors: {
|
|
2169
|
+
type: "boolean",
|
|
2170
|
+
description: "Continue on row errors (default: false)",
|
|
2171
|
+
},
|
|
2172
|
+
batch_size: {
|
|
2173
|
+
type: "number",
|
|
2174
|
+
description: "Number of rows per batch insert (default: 100)",
|
|
2175
|
+
},
|
|
2176
|
+
database: {
|
|
2177
|
+
type: "string",
|
|
2178
|
+
description: "Optional: specific database name",
|
|
2179
|
+
},
|
|
2180
|
+
},
|
|
2181
|
+
required: ["table_name", "json_data"],
|
|
2182
|
+
},
|
|
2183
|
+
},
|
|
2184
|
+
// Data Migration Tools
|
|
2185
|
+
{
|
|
2186
|
+
name: "copy_table_data",
|
|
2187
|
+
description: "Copy data from one table to another with optional column mapping and filtering. Requires 'create' permission.",
|
|
2188
|
+
inputSchema: {
|
|
2189
|
+
type: "object",
|
|
2190
|
+
properties: {
|
|
2191
|
+
source_table: {
|
|
2192
|
+
type: "string",
|
|
2193
|
+
description: "Name of the source table to copy from",
|
|
2194
|
+
},
|
|
2195
|
+
target_table: {
|
|
2196
|
+
type: "string",
|
|
2197
|
+
description: "Name of the target table to copy to",
|
|
2198
|
+
},
|
|
2199
|
+
column_mapping: {
|
|
2200
|
+
type: "object",
|
|
2201
|
+
description: "Optional: map source columns to target columns {source_col: target_col}",
|
|
2202
|
+
additionalProperties: { type: "string" },
|
|
2203
|
+
},
|
|
2204
|
+
filters: {
|
|
2205
|
+
type: "array",
|
|
2206
|
+
description: "Optional: array of filter conditions for source data",
|
|
2207
|
+
items: {
|
|
2208
|
+
type: "object",
|
|
2209
|
+
properties: {
|
|
2210
|
+
field: { type: "string" },
|
|
2211
|
+
operator: {
|
|
2212
|
+
type: "string",
|
|
2213
|
+
enum: ["eq", "neq", "gt", "gte", "lt", "lte", "like", "in"],
|
|
2214
|
+
},
|
|
2215
|
+
value: {},
|
|
2216
|
+
},
|
|
2217
|
+
required: ["field", "operator", "value"],
|
|
2218
|
+
},
|
|
2219
|
+
},
|
|
2220
|
+
batch_size: {
|
|
2221
|
+
type: "number",
|
|
2222
|
+
description: "Number of rows per batch insert (default: 1000)",
|
|
2223
|
+
},
|
|
2224
|
+
database: {
|
|
2225
|
+
type: "string",
|
|
2226
|
+
description: "Optional: specific database name",
|
|
2227
|
+
},
|
|
2228
|
+
},
|
|
2229
|
+
required: ["source_table", "target_table"],
|
|
2230
|
+
},
|
|
2231
|
+
},
|
|
2232
|
+
{
|
|
2233
|
+
name: "move_table_data",
|
|
2234
|
+
description: "Move data from one table to another (copy then delete from source). Requires 'create' and 'delete' permissions.",
|
|
2235
|
+
inputSchema: {
|
|
2236
|
+
type: "object",
|
|
2237
|
+
properties: {
|
|
2238
|
+
source_table: {
|
|
2239
|
+
type: "string",
|
|
2240
|
+
description: "Name of the source table to move from",
|
|
2241
|
+
},
|
|
2242
|
+
target_table: {
|
|
2243
|
+
type: "string",
|
|
2244
|
+
description: "Name of the target table to move to",
|
|
2245
|
+
},
|
|
2246
|
+
column_mapping: {
|
|
2247
|
+
type: "object",
|
|
2248
|
+
description: "Optional: map source columns to target columns {source_col: target_col}",
|
|
2249
|
+
additionalProperties: { type: "string" },
|
|
2250
|
+
},
|
|
2251
|
+
filters: {
|
|
2252
|
+
type: "array",
|
|
2253
|
+
description: "Optional: array of filter conditions for source data",
|
|
2254
|
+
items: {
|
|
2255
|
+
type: "object",
|
|
2256
|
+
properties: {
|
|
2257
|
+
field: { type: "string" },
|
|
2258
|
+
operator: {
|
|
2259
|
+
type: "string",
|
|
2260
|
+
enum: ["eq", "neq", "gt", "gte", "lt", "lte", "like", "in"],
|
|
2261
|
+
},
|
|
2262
|
+
value: {},
|
|
2263
|
+
},
|
|
2264
|
+
required: ["field", "operator", "value"],
|
|
2265
|
+
},
|
|
2266
|
+
},
|
|
2267
|
+
batch_size: {
|
|
2268
|
+
type: "number",
|
|
2269
|
+
description: "Number of rows per batch (default: 1000)",
|
|
2270
|
+
},
|
|
2271
|
+
database: {
|
|
2272
|
+
type: "string",
|
|
2273
|
+
description: "Optional: specific database name",
|
|
2274
|
+
},
|
|
2275
|
+
},
|
|
2276
|
+
required: ["source_table", "target_table"],
|
|
2277
|
+
},
|
|
2278
|
+
},
|
|
2279
|
+
{
|
|
2280
|
+
name: "clone_table",
|
|
2281
|
+
description: "Clone a table structure with optional data. Requires 'ddl' permission.",
|
|
2282
|
+
inputSchema: {
|
|
2283
|
+
type: "object",
|
|
2284
|
+
properties: {
|
|
2285
|
+
source_table: {
|
|
2286
|
+
type: "string",
|
|
2287
|
+
description: "Name of the source table to clone",
|
|
2288
|
+
},
|
|
2289
|
+
new_table_name: {
|
|
2290
|
+
type: "string",
|
|
2291
|
+
description: "Name of the new table to create",
|
|
2292
|
+
},
|
|
2293
|
+
include_data: {
|
|
2294
|
+
type: "boolean",
|
|
2295
|
+
description: "Include table data in the clone (default: false)",
|
|
2296
|
+
},
|
|
2297
|
+
include_indexes: {
|
|
2298
|
+
type: "boolean",
|
|
2299
|
+
description: "Include indexes in the clone (default: true)",
|
|
2300
|
+
},
|
|
2301
|
+
database: {
|
|
2302
|
+
type: "string",
|
|
2303
|
+
description: "Optional: specific database name",
|
|
2304
|
+
},
|
|
2305
|
+
},
|
|
2306
|
+
required: ["source_table", "new_table_name"],
|
|
2307
|
+
},
|
|
2308
|
+
},
|
|
2309
|
+
{
|
|
2310
|
+
name: "compare_table_structure",
|
|
2311
|
+
description: "Compare the structure of two tables and identify differences in columns, types, and indexes.",
|
|
2312
|
+
inputSchema: {
|
|
2313
|
+
type: "object",
|
|
2314
|
+
properties: {
|
|
2315
|
+
table1: {
|
|
2316
|
+
type: "string",
|
|
2317
|
+
description: "Name of the first table",
|
|
2318
|
+
},
|
|
2319
|
+
table2: {
|
|
2320
|
+
type: "string",
|
|
2321
|
+
description: "Name of the second table",
|
|
2322
|
+
},
|
|
2323
|
+
database: {
|
|
2324
|
+
type: "string",
|
|
2325
|
+
description: "Optional: specific database name",
|
|
2326
|
+
},
|
|
2327
|
+
},
|
|
2328
|
+
required: ["table1", "table2"],
|
|
2329
|
+
},
|
|
2330
|
+
},
|
|
2331
|
+
{
|
|
2332
|
+
name: "sync_table_data",
|
|
2333
|
+
description: "Synchronize data between two tables based on a key column. Supports insert-only, update-only, or upsert modes.",
|
|
2334
|
+
inputSchema: {
|
|
2335
|
+
type: "object",
|
|
2336
|
+
properties: {
|
|
2337
|
+
source_table: {
|
|
2338
|
+
type: "string",
|
|
2339
|
+
description: "Name of the source table",
|
|
2340
|
+
},
|
|
2341
|
+
target_table: {
|
|
2342
|
+
type: "string",
|
|
2343
|
+
description: "Name of the target table",
|
|
2344
|
+
},
|
|
2345
|
+
key_column: {
|
|
2346
|
+
type: "string",
|
|
2347
|
+
description: "Primary key or unique column to match records",
|
|
2348
|
+
},
|
|
2349
|
+
columns_to_sync: {
|
|
2350
|
+
type: "array",
|
|
2351
|
+
items: { type: "string" },
|
|
2352
|
+
description: "Optional: specific columns to sync (default: all columns)",
|
|
2353
|
+
},
|
|
2354
|
+
sync_mode: {
|
|
2355
|
+
type: "string",
|
|
2356
|
+
enum: ["insert_only", "update_only", "upsert"],
|
|
2357
|
+
description: "Sync mode: insert_only (new records), update_only (existing), upsert (both). Default: upsert",
|
|
2358
|
+
},
|
|
2359
|
+
batch_size: {
|
|
2360
|
+
type: "number",
|
|
2361
|
+
description: "Number of rows per batch (default: 1000)",
|
|
2362
|
+
},
|
|
2363
|
+
database: {
|
|
2364
|
+
type: "string",
|
|
2365
|
+
description: "Optional: specific database name",
|
|
2366
|
+
},
|
|
2367
|
+
},
|
|
2368
|
+
required: ["source_table", "target_table", "key_column"],
|
|
2369
|
+
},
|
|
2370
|
+
},
|
|
1869
2371
|
];
|
|
1870
2372
|
// Create the MCP server
|
|
1871
2373
|
const server = new index_js_1.Server({
|
|
@@ -2155,6 +2657,55 @@ server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
|
|
|
2155
2657
|
case "show_replication_status":
|
|
2156
2658
|
result = await mysqlMCP.showReplicationStatus((args || {}));
|
|
2157
2659
|
break;
|
|
2660
|
+
// Backup and Restore Tools
|
|
2661
|
+
case "backup_table":
|
|
2662
|
+
result = await mysqlMCP.backupTable((args || {}));
|
|
2663
|
+
break;
|
|
2664
|
+
case "backup_database":
|
|
2665
|
+
result = await mysqlMCP.backupDatabase((args || {}));
|
|
2666
|
+
break;
|
|
2667
|
+
case "restore_from_sql":
|
|
2668
|
+
result = await mysqlMCP.restoreFromSql((args || {}));
|
|
2669
|
+
break;
|
|
2670
|
+
case "get_create_table_statement":
|
|
2671
|
+
result = await mysqlMCP.getCreateTableStatement((args || {}));
|
|
2672
|
+
break;
|
|
2673
|
+
case "get_database_schema":
|
|
2674
|
+
result = await mysqlMCP.getDatabaseSchema((args || {}));
|
|
2675
|
+
break;
|
|
2676
|
+
// Extended Data Export Tools
|
|
2677
|
+
case "export_table_to_json":
|
|
2678
|
+
result = await mysqlMCP.exportTableToJSON((args || {}));
|
|
2679
|
+
break;
|
|
2680
|
+
case "export_query_to_json":
|
|
2681
|
+
result = await mysqlMCP.exportQueryToJSON((args || {}));
|
|
2682
|
+
break;
|
|
2683
|
+
case "export_table_to_sql":
|
|
2684
|
+
result = await mysqlMCP.exportTableToSql((args || {}));
|
|
2685
|
+
break;
|
|
2686
|
+
// Data Import Tools
|
|
2687
|
+
case "import_from_csv":
|
|
2688
|
+
result = await mysqlMCP.importFromCSV((args || {}));
|
|
2689
|
+
break;
|
|
2690
|
+
case "import_from_json":
|
|
2691
|
+
result = await mysqlMCP.importFromJSON((args || {}));
|
|
2692
|
+
break;
|
|
2693
|
+
// Data Migration Tools
|
|
2694
|
+
case "copy_table_data":
|
|
2695
|
+
result = await mysqlMCP.copyTableData((args || {}));
|
|
2696
|
+
break;
|
|
2697
|
+
case "move_table_data":
|
|
2698
|
+
result = await mysqlMCP.moveTableData((args || {}));
|
|
2699
|
+
break;
|
|
2700
|
+
case "clone_table":
|
|
2701
|
+
result = await mysqlMCP.cloneTable((args || {}));
|
|
2702
|
+
break;
|
|
2703
|
+
case "compare_table_structure":
|
|
2704
|
+
result = await mysqlMCP.compareTableStructure((args || {}));
|
|
2705
|
+
break;
|
|
2706
|
+
case "sync_table_data":
|
|
2707
|
+
result = await mysqlMCP.syncTableData((args || {}));
|
|
2708
|
+
break;
|
|
2158
2709
|
default:
|
|
2159
2710
|
throw new Error(`Unknown tool: ${name}`);
|
|
2160
2711
|
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import SecurityLayer from '../security/securityLayer';
|
|
2
|
+
/**
|
|
3
|
+
* Backup and Restore Tools for MySQL MCP Server
|
|
4
|
+
* Provides database backup (SQL dump generation) and restore functionality
|
|
5
|
+
*/
|
|
6
|
+
export declare class BackupRestoreTools {
|
|
7
|
+
private db;
|
|
8
|
+
private security;
|
|
9
|
+
constructor(security: SecurityLayer);
|
|
10
|
+
/**
|
|
11
|
+
* Validate database access
|
|
12
|
+
*/
|
|
13
|
+
private validateDatabaseAccess;
|
|
14
|
+
/**
|
|
15
|
+
* Escape string value for SQL
|
|
16
|
+
*/
|
|
17
|
+
private escapeValue;
|
|
18
|
+
/**
|
|
19
|
+
* Get CREATE TABLE statement for a table
|
|
20
|
+
*/
|
|
21
|
+
getCreateTableStatement(params: {
|
|
22
|
+
table_name: string;
|
|
23
|
+
database?: string;
|
|
24
|
+
}): Promise<{
|
|
25
|
+
status: string;
|
|
26
|
+
data?: any;
|
|
27
|
+
error?: string;
|
|
28
|
+
queryLog?: string;
|
|
29
|
+
}>;
|
|
30
|
+
/**
|
|
31
|
+
* Backup a single table to SQL dump format
|
|
32
|
+
*/
|
|
33
|
+
backupTable(params: {
|
|
34
|
+
table_name: string;
|
|
35
|
+
include_data?: boolean;
|
|
36
|
+
include_drop?: boolean;
|
|
37
|
+
database?: string;
|
|
38
|
+
}): Promise<{
|
|
39
|
+
status: string;
|
|
40
|
+
data?: any;
|
|
41
|
+
error?: string;
|
|
42
|
+
queryLog?: string;
|
|
43
|
+
}>;
|
|
44
|
+
/**
|
|
45
|
+
* Backup entire database schema and optionally data
|
|
46
|
+
*/
|
|
47
|
+
backupDatabase(params: {
|
|
48
|
+
include_data?: boolean;
|
|
49
|
+
include_drop?: boolean;
|
|
50
|
+
tables?: string[];
|
|
51
|
+
database?: string;
|
|
52
|
+
}): Promise<{
|
|
53
|
+
status: string;
|
|
54
|
+
data?: any;
|
|
55
|
+
error?: string;
|
|
56
|
+
queryLog?: string;
|
|
57
|
+
}>;
|
|
58
|
+
/**
|
|
59
|
+
* Restore database from SQL dump
|
|
60
|
+
* Executes SQL statements from the provided SQL dump string
|
|
61
|
+
*/
|
|
62
|
+
restoreFromSql(params: {
|
|
63
|
+
sql_dump: string;
|
|
64
|
+
stop_on_error?: boolean;
|
|
65
|
+
database?: string;
|
|
66
|
+
}): Promise<{
|
|
67
|
+
status: string;
|
|
68
|
+
data?: any;
|
|
69
|
+
error?: string;
|
|
70
|
+
queryLog?: string;
|
|
71
|
+
}>;
|
|
72
|
+
/**
|
|
73
|
+
* Parse SQL dump into individual statements
|
|
74
|
+
*/
|
|
75
|
+
private parseSqlStatements;
|
|
76
|
+
/**
|
|
77
|
+
* Get database schema overview (all CREATE statements)
|
|
78
|
+
*/
|
|
79
|
+
getDatabaseSchema(params: {
|
|
80
|
+
database?: string;
|
|
81
|
+
include_views?: boolean;
|
|
82
|
+
include_procedures?: boolean;
|
|
83
|
+
include_functions?: boolean;
|
|
84
|
+
include_triggers?: boolean;
|
|
85
|
+
}): Promise<{
|
|
86
|
+
status: string;
|
|
87
|
+
data?: any;
|
|
88
|
+
error?: string;
|
|
89
|
+
queryLog?: string;
|
|
90
|
+
}>;
|
|
91
|
+
}
|