@berthojoris/mcp-mysql-server 1.4.15 → 1.5.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 +200 -18
- 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 +76 -3
- package/dist/index.js +161 -70
- package/dist/mcp-server.js +166 -5
- package/dist/optimization/queryOptimizer.d.ts +125 -0
- package/dist/optimization/queryOptimizer.js +509 -0
- package/dist/tools/queryTools.d.ts +14 -1
- package/dist/tools/queryTools.js +27 -3
- package/package.json +1 -1
package/dist/tools/queryTools.js
CHANGED
|
@@ -6,13 +6,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.QueryTools = void 0;
|
|
7
7
|
const connection_1 = __importDefault(require("../db/connection"));
|
|
8
8
|
const schemas_1 = require("../validation/schemas");
|
|
9
|
+
const queryOptimizer_1 = require("../optimization/queryOptimizer");
|
|
9
10
|
class QueryTools {
|
|
10
11
|
constructor(security) {
|
|
11
12
|
this.db = connection_1.default.getInstance();
|
|
12
13
|
this.security = security;
|
|
14
|
+
this.optimizer = queryOptimizer_1.QueryOptimizer.getInstance();
|
|
13
15
|
}
|
|
14
16
|
/**
|
|
15
|
-
* Execute a safe read-only SELECT query
|
|
17
|
+
* Execute a safe read-only SELECT query with optional optimizer hints
|
|
16
18
|
*/
|
|
17
19
|
async runQuery(queryParams) {
|
|
18
20
|
// Validate input schema
|
|
@@ -23,7 +25,7 @@ class QueryTools {
|
|
|
23
25
|
};
|
|
24
26
|
}
|
|
25
27
|
try {
|
|
26
|
-
const { query, params = [] } = queryParams;
|
|
28
|
+
const { query, params = [], hints, useCache = true } = queryParams;
|
|
27
29
|
// Check if user has execute permission to bypass dangerous keyword checks
|
|
28
30
|
const hasExecutePermission = this.security.hasExecutePermission();
|
|
29
31
|
// Validate query using security layer
|
|
@@ -50,12 +52,22 @@ class QueryTools {
|
|
|
50
52
|
error: `Parameter validation failed: ${paramValidation.error}`,
|
|
51
53
|
};
|
|
52
54
|
}
|
|
55
|
+
// Apply optimizer hints if provided
|
|
56
|
+
let finalQuery = query;
|
|
57
|
+
let optimizedQuery;
|
|
58
|
+
if (hints) {
|
|
59
|
+
finalQuery = this.optimizer.applyHints(query, hints);
|
|
60
|
+
if (finalQuery !== query) {
|
|
61
|
+
optimizedQuery = finalQuery;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
53
64
|
// Execute the query with sanitized parameters
|
|
54
|
-
const results = await this.db.query(
|
|
65
|
+
const results = await this.db.query(finalQuery, paramValidation.sanitizedParams, useCache);
|
|
55
66
|
return {
|
|
56
67
|
status: "success",
|
|
57
68
|
data: results,
|
|
58
69
|
queryLog: this.db.getFormattedQueryLogs(1),
|
|
70
|
+
optimizedQuery,
|
|
59
71
|
};
|
|
60
72
|
}
|
|
61
73
|
catch (error) {
|
|
@@ -66,6 +78,18 @@ class QueryTools {
|
|
|
66
78
|
};
|
|
67
79
|
}
|
|
68
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* Analyze a query and get optimization suggestions
|
|
83
|
+
*/
|
|
84
|
+
analyzeQuery(query) {
|
|
85
|
+
return this.optimizer.analyzeQuery(query);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Get suggested hints for a specific optimization goal
|
|
89
|
+
*/
|
|
90
|
+
getSuggestedHints(goal) {
|
|
91
|
+
return this.optimizer.getSuggestedHints(goal);
|
|
92
|
+
}
|
|
69
93
|
/**
|
|
70
94
|
* Execute write operations (INSERT, UPDATE, DELETE) with validation
|
|
71
95
|
* Note: DDL operations are blocked by the security layer for safety
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@berthojoris/mcp-mysql-server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
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",
|