@cano721/mysql-mcp-server 0.5.0 → 0.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/build/index.js +14 -11
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -49,6 +49,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
49
49
|
// Check if optional commands are enabled
|
|
50
50
|
const allowExplain = process.env.MYSQL_ALLOW_EXPLAIN !== 'false';
|
|
51
51
|
const allowAnalyze = process.env.MYSQL_ALLOW_ANALYZE !== 'false';
|
|
52
|
+
console.error('[Setup] Security settings:', { allowExplain, allowAnalyze });
|
|
52
53
|
// Build allowed commands description for execute_query
|
|
53
54
|
const allowedCommands = ['SELECT', 'SHOW', 'DESCRIBE'];
|
|
54
55
|
if (allowExplain) {
|
|
@@ -149,21 +150,21 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
149
150
|
// Add analyze_query tool if enabled
|
|
150
151
|
if (allowAnalyze) {
|
|
151
152
|
tools.push({
|
|
152
|
-
name: "
|
|
153
|
-
description: "Analyze
|
|
153
|
+
name: "analyze_query",
|
|
154
|
+
description: "Analyze query performance and statistics using ANALYZE",
|
|
154
155
|
inputSchema: {
|
|
155
156
|
type: "object",
|
|
156
157
|
properties: {
|
|
157
|
-
|
|
158
|
+
query: {
|
|
158
159
|
type: "string",
|
|
159
|
-
description: "
|
|
160
|
+
description: "SQL query to analyze (SELECT, UPDATE, DELETE, INSERT, REPLACE statements)"
|
|
160
161
|
},
|
|
161
162
|
database: {
|
|
162
163
|
type: "string",
|
|
163
164
|
description: "Database name (optional, uses default if not specified)"
|
|
164
165
|
}
|
|
165
166
|
},
|
|
166
|
-
required: ["
|
|
167
|
+
required: ["query"]
|
|
167
168
|
}
|
|
168
169
|
});
|
|
169
170
|
}
|
|
@@ -250,14 +251,16 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
250
251
|
}]
|
|
251
252
|
};
|
|
252
253
|
}
|
|
253
|
-
case "
|
|
254
|
-
console.error('[Tool] Executing
|
|
255
|
-
const
|
|
254
|
+
case "analyze_query": {
|
|
255
|
+
console.error('[Tool] Executing analyze_query');
|
|
256
|
+
const query = request.params.arguments?.query;
|
|
256
257
|
const database = request.params.arguments?.database;
|
|
257
|
-
if (!
|
|
258
|
-
throw new McpError(ErrorCode.InvalidParams, "
|
|
258
|
+
if (!query) {
|
|
259
|
+
throw new McpError(ErrorCode.InvalidParams, "Query is required");
|
|
259
260
|
}
|
|
260
|
-
|
|
261
|
+
// Build ANALYZE query
|
|
262
|
+
const analyzeQuery = `ANALYZE ${query}`;
|
|
263
|
+
const { rows } = await executeQuery(pool, analyzeQuery, [], database);
|
|
261
264
|
return {
|
|
262
265
|
content: [{
|
|
263
266
|
type: "text",
|