@berthojoris/mcp-mysql-server 1.4.6 → 1.4.12
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 +132 -0
- package/README.md +439 -0
- package/dist/db/connection.d.ts +3 -0
- package/dist/db/connection.js +20 -0
- package/dist/db/queryLogger.d.ts +60 -0
- package/dist/db/queryLogger.js +189 -0
- package/dist/index.d.ts +19 -0
- package/dist/mcp-server.js +24 -1
- package/dist/tools/crudTools.d.ts +4 -0
- package/dist/tools/crudTools.js +18 -9
- package/dist/tools/dataExportTools.d.ts +2 -0
- package/dist/tools/dataExportTools.js +6 -3
- package/dist/tools/databaseTools.d.ts +3 -0
- package/dist/tools/databaseTools.js +14 -7
- package/dist/tools/ddlTools.d.ts +4 -0
- package/dist/tools/ddlTools.js +18 -8
- package/dist/tools/queryTools.d.ts +2 -0
- package/dist/tools/queryTools.js +4 -0
- package/dist/tools/storedProcedureTools.d.ts +2 -0
- package/dist/tools/storedProcedureTools.js +10 -5
- package/dist/tools/transactionTools.d.ts +1 -0
- package/dist/tools/transactionTools.js +4 -2
- package/dist/tools/utilityTools.d.ts +1 -0
- package/dist/tools/utilityTools.js +4 -2
- package/package.json +1 -1
package/dist/tools/ddlTools.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ export declare class DdlTools {
|
|
|
23
23
|
status: string;
|
|
24
24
|
data?: any;
|
|
25
25
|
error?: string;
|
|
26
|
+
queryLog?: string;
|
|
26
27
|
}>;
|
|
27
28
|
/**
|
|
28
29
|
* Alter an existing table
|
|
@@ -44,6 +45,7 @@ export declare class DdlTools {
|
|
|
44
45
|
status: string;
|
|
45
46
|
data?: any;
|
|
46
47
|
error?: string;
|
|
48
|
+
queryLog?: string;
|
|
47
49
|
}>;
|
|
48
50
|
/**
|
|
49
51
|
* Drop a table
|
|
@@ -55,6 +57,7 @@ export declare class DdlTools {
|
|
|
55
57
|
status: string;
|
|
56
58
|
data?: any;
|
|
57
59
|
error?: string;
|
|
60
|
+
queryLog?: string;
|
|
58
61
|
}>;
|
|
59
62
|
/**
|
|
60
63
|
* Execute raw DDL SQL
|
|
@@ -65,5 +68,6 @@ export declare class DdlTools {
|
|
|
65
68
|
status: string;
|
|
66
69
|
data?: any;
|
|
67
70
|
error?: string;
|
|
71
|
+
queryLog?: string;
|
|
68
72
|
}>;
|
|
69
73
|
}
|
package/dist/tools/ddlTools.js
CHANGED
|
@@ -37,12 +37,14 @@ class DdlTools {
|
|
|
37
37
|
// Execute the query
|
|
38
38
|
await this.db.query(query);
|
|
39
39
|
// Create indexes if specified
|
|
40
|
+
let queryCount = 1;
|
|
40
41
|
if (indexes && indexes.length > 0) {
|
|
41
42
|
for (const index of indexes) {
|
|
42
43
|
const indexType = index.unique ? 'UNIQUE INDEX' : 'INDEX';
|
|
43
44
|
const indexColumns = index.columns.map(c => `\`${c}\``).join(', ');
|
|
44
45
|
const indexQuery = `CREATE ${indexType} \`${index.name}\` ON \`${table_name}\` (${indexColumns})`;
|
|
45
46
|
await this.db.query(indexQuery);
|
|
47
|
+
queryCount++;
|
|
46
48
|
}
|
|
47
49
|
}
|
|
48
50
|
return {
|
|
@@ -50,13 +52,15 @@ class DdlTools {
|
|
|
50
52
|
data: {
|
|
51
53
|
message: `Table '${table_name}' created successfully`,
|
|
52
54
|
table_name
|
|
53
|
-
}
|
|
55
|
+
},
|
|
56
|
+
queryLog: this.db.getFormattedQueryLogs(queryCount)
|
|
54
57
|
};
|
|
55
58
|
}
|
|
56
59
|
catch (error) {
|
|
57
60
|
return {
|
|
58
61
|
status: 'error',
|
|
59
|
-
error: error.message
|
|
62
|
+
error: error.message,
|
|
63
|
+
queryLog: this.db.getFormattedQueryLogs(10)
|
|
60
64
|
};
|
|
61
65
|
}
|
|
62
66
|
}
|
|
@@ -126,13 +130,15 @@ class DdlTools {
|
|
|
126
130
|
message: `Table '${table_name}' altered successfully`,
|
|
127
131
|
table_name,
|
|
128
132
|
operations_count: operations.length
|
|
129
|
-
}
|
|
133
|
+
},
|
|
134
|
+
queryLog: this.db.getFormattedQueryLogs(operations.length)
|
|
130
135
|
};
|
|
131
136
|
}
|
|
132
137
|
catch (error) {
|
|
133
138
|
return {
|
|
134
139
|
status: 'error',
|
|
135
|
-
error: error.message
|
|
140
|
+
error: error.message,
|
|
141
|
+
queryLog: this.db.getFormattedQueryLogs(10)
|
|
136
142
|
};
|
|
137
143
|
}
|
|
138
144
|
}
|
|
@@ -150,13 +156,15 @@ class DdlTools {
|
|
|
150
156
|
data: {
|
|
151
157
|
message: `Table '${table_name}' dropped successfully`,
|
|
152
158
|
table_name
|
|
153
|
-
}
|
|
159
|
+
},
|
|
160
|
+
queryLog: this.db.getFormattedQueryLogs(1)
|
|
154
161
|
};
|
|
155
162
|
}
|
|
156
163
|
catch (error) {
|
|
157
164
|
return {
|
|
158
165
|
status: 'error',
|
|
159
|
-
error: error.message
|
|
166
|
+
error: error.message,
|
|
167
|
+
queryLog: this.db.getFormattedQueryLogs(1)
|
|
160
168
|
};
|
|
161
169
|
}
|
|
162
170
|
}
|
|
@@ -185,13 +193,15 @@ class DdlTools {
|
|
|
185
193
|
data: {
|
|
186
194
|
message: 'DDL query executed successfully',
|
|
187
195
|
affected_rows: result.affectedRows || 0
|
|
188
|
-
}
|
|
196
|
+
},
|
|
197
|
+
queryLog: this.db.getFormattedQueryLogs(1)
|
|
189
198
|
};
|
|
190
199
|
}
|
|
191
200
|
catch (error) {
|
|
192
201
|
return {
|
|
193
202
|
status: 'error',
|
|
194
|
-
error: error.message
|
|
203
|
+
error: error.message,
|
|
204
|
+
queryLog: this.db.getFormattedQueryLogs(1)
|
|
195
205
|
};
|
|
196
206
|
}
|
|
197
207
|
}
|
|
@@ -13,6 +13,7 @@ export declare class QueryTools {
|
|
|
13
13
|
status: string;
|
|
14
14
|
data?: any[];
|
|
15
15
|
error?: string;
|
|
16
|
+
queryLog?: string;
|
|
16
17
|
}>;
|
|
17
18
|
/**
|
|
18
19
|
* Execute write operations (INSERT, UPDATE, DELETE) with validation
|
|
@@ -25,5 +26,6 @@ export declare class QueryTools {
|
|
|
25
26
|
status: string;
|
|
26
27
|
data?: any;
|
|
27
28
|
error?: string;
|
|
29
|
+
queryLog?: string;
|
|
28
30
|
}>;
|
|
29
31
|
}
|
package/dist/tools/queryTools.js
CHANGED
|
@@ -55,12 +55,14 @@ class QueryTools {
|
|
|
55
55
|
return {
|
|
56
56
|
status: "success",
|
|
57
57
|
data: results,
|
|
58
|
+
queryLog: this.db.getFormattedQueryLogs(1),
|
|
58
59
|
};
|
|
59
60
|
}
|
|
60
61
|
catch (error) {
|
|
61
62
|
return {
|
|
62
63
|
status: "error",
|
|
63
64
|
error: error.message,
|
|
65
|
+
queryLog: this.db.getFormattedQueryLogs(1),
|
|
64
66
|
};
|
|
65
67
|
}
|
|
66
68
|
}
|
|
@@ -110,12 +112,14 @@ class QueryTools {
|
|
|
110
112
|
affectedRows: result.affectedRows || 0,
|
|
111
113
|
insertId: result.insertId || null,
|
|
112
114
|
},
|
|
115
|
+
queryLog: this.db.getFormattedQueryLogs(1),
|
|
113
116
|
};
|
|
114
117
|
}
|
|
115
118
|
catch (error) {
|
|
116
119
|
return {
|
|
117
120
|
status: "error",
|
|
118
121
|
error: error.message,
|
|
122
|
+
queryLog: this.db.getFormattedQueryLogs(1),
|
|
119
123
|
};
|
|
120
124
|
}
|
|
121
125
|
}
|
|
@@ -16,6 +16,7 @@ export declare class StoredProcedureTools {
|
|
|
16
16
|
status: string;
|
|
17
17
|
data?: any[];
|
|
18
18
|
error?: string;
|
|
19
|
+
queryLog?: string;
|
|
19
20
|
}>;
|
|
20
21
|
/**
|
|
21
22
|
* Get detailed information about a specific stored procedure
|
|
@@ -27,6 +28,7 @@ export declare class StoredProcedureTools {
|
|
|
27
28
|
status: string;
|
|
28
29
|
data?: any;
|
|
29
30
|
error?: string;
|
|
31
|
+
queryLog?: string;
|
|
30
32
|
}>;
|
|
31
33
|
/**
|
|
32
34
|
* Execute a stored procedure with parameters
|
|
@@ -84,13 +84,15 @@ class StoredProcedureTools {
|
|
|
84
84
|
const results = await this.db.query(query, [database]);
|
|
85
85
|
return {
|
|
86
86
|
status: 'success',
|
|
87
|
-
data: results
|
|
87
|
+
data: results,
|
|
88
|
+
queryLog: this.db.getFormattedQueryLogs(1)
|
|
88
89
|
};
|
|
89
90
|
}
|
|
90
91
|
catch (error) {
|
|
91
92
|
return {
|
|
92
93
|
status: 'error',
|
|
93
|
-
error: error.message
|
|
94
|
+
error: error.message,
|
|
95
|
+
queryLog: this.db.getFormattedQueryLogs(1)
|
|
94
96
|
};
|
|
95
97
|
}
|
|
96
98
|
}
|
|
@@ -154,7 +156,8 @@ class StoredProcedureTools {
|
|
|
154
156
|
if (procedureInfo.length === 0) {
|
|
155
157
|
return {
|
|
156
158
|
status: 'error',
|
|
157
|
-
error: `Stored procedure '${procedure_name}' not found in database '${database}'
|
|
159
|
+
error: `Stored procedure '${procedure_name}' not found in database '${database}'`,
|
|
160
|
+
queryLog: this.db.getFormattedQueryLogs(2)
|
|
158
161
|
};
|
|
159
162
|
}
|
|
160
163
|
return {
|
|
@@ -162,13 +165,15 @@ class StoredProcedureTools {
|
|
|
162
165
|
data: {
|
|
163
166
|
...procedureInfo[0],
|
|
164
167
|
parameters: parameters
|
|
165
|
-
}
|
|
168
|
+
},
|
|
169
|
+
queryLog: this.db.getFormattedQueryLogs(2)
|
|
166
170
|
};
|
|
167
171
|
}
|
|
168
172
|
catch (error) {
|
|
169
173
|
return {
|
|
170
174
|
status: 'error',
|
|
171
|
-
error: error.message
|
|
175
|
+
error: error.message,
|
|
176
|
+
queryLog: this.db.getFormattedQueryLogs(2)
|
|
172
177
|
};
|
|
173
178
|
}
|
|
174
179
|
}
|
|
@@ -116,13 +116,15 @@ class TransactionTools {
|
|
|
116
116
|
const result = await this.db.executeInTransaction(params.transactionId, params.query, params.params);
|
|
117
117
|
return {
|
|
118
118
|
status: 'success',
|
|
119
|
-
data: result
|
|
119
|
+
data: result,
|
|
120
|
+
queryLog: this.db.getFormattedQueryLogs(1)
|
|
120
121
|
};
|
|
121
122
|
}
|
|
122
123
|
catch (error) {
|
|
123
124
|
return {
|
|
124
125
|
status: 'error',
|
|
125
|
-
error: error.message
|
|
126
|
+
error: error.message,
|
|
127
|
+
queryLog: this.db.getFormattedQueryLogs(1)
|
|
126
128
|
};
|
|
127
129
|
}
|
|
128
130
|
}
|
|
@@ -107,13 +107,15 @@ class UtilityTools {
|
|
|
107
107
|
data: {
|
|
108
108
|
as_parent: parentRelationships,
|
|
109
109
|
as_child: childRelationships
|
|
110
|
-
}
|
|
110
|
+
},
|
|
111
|
+
queryLog: this.db.getFormattedQueryLogs(2)
|
|
111
112
|
};
|
|
112
113
|
}
|
|
113
114
|
catch (error) {
|
|
114
115
|
return {
|
|
115
116
|
status: 'error',
|
|
116
|
-
error: error.message
|
|
117
|
+
error: error.message,
|
|
118
|
+
queryLog: this.db.getFormattedQueryLogs(2)
|
|
117
119
|
};
|
|
118
120
|
}
|
|
119
121
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@berthojoris/mcp-mysql-server",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.12",
|
|
4
4
|
"description": "Model Context Protocol server for MySQL database integration with dynamic per-project permissions and data export capabilities",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|