mcp-db-analyzer 0.2.11 → 0.2.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.
@@ -194,7 +194,14 @@ async function analyzeMysqlConnections() {
194
194
  }
195
195
  lines.push("");
196
196
  }
197
- if (longQueries.rows.length === 0) {
197
+ if (longQueries.rows.length > 0) {
198
+ lines.push("### Recommendations\n");
199
+ lines.push("- Set `max_execution_time` (per-session) or `innodb_lock_wait_timeout` to limit runaway queries");
200
+ lines.push("- Investigate long-running queries with `EXPLAIN` and optimize or add indexes");
201
+ lines.push("- Use `KILL <id>` to terminate a blocking query if needed");
202
+ lines.push("");
203
+ }
204
+ else {
198
205
  lines.push("### No connection issues detected.\n");
199
206
  }
200
207
  return lines.join("\n");
@@ -41,10 +41,23 @@ async function explainQuerySqlite(sql) {
41
41
  if (result.rows.length === 0) {
42
42
  return "Could not parse query plan.";
43
43
  }
44
+ // Build a depth map from the parent chain. SQLite's id field is a node
45
+ // identifier (can be 2, 4, 10...), not a depth — depth must be computed
46
+ // by following parent references.
47
+ const depthMap = new Map();
48
+ for (const row of result.rows) {
49
+ if (row.parent === 0 || row.parent === row.id) {
50
+ depthMap.set(row.id, 0);
51
+ }
52
+ else {
53
+ depthMap.set(row.id, (depthMap.get(row.parent) ?? 0) + 1);
54
+ }
55
+ }
44
56
  const lines = ["## Query Plan Analysis (SQLite)\n"];
45
57
  lines.push("```");
46
58
  for (const row of result.rows) {
47
- const indent = " ".repeat(Math.max(0, row.id));
59
+ const depth = depthMap.get(row.id) ?? 0;
60
+ const indent = " ".repeat(depth);
48
61
  lines.push(`${indent}${row.detail}`);
49
62
  }
50
63
  lines.push("```\n");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-db-analyzer",
3
- "version": "0.2.11",
3
+ "version": "0.2.12",
4
4
  "description": "MCP server for PostgreSQL, MySQL, and SQLite schema analysis, index optimization, and query plan inspection",
5
5
  "mcpName": "io.github.dmitriusan/mcp-db-analyzer",
6
6
  "author": "Dmytro Lisnichenko",