@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.
@@ -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(query, paramValidation.sanitizedParams);
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.4.15",
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",