mcp-db-analyzer 0.2.3 → 0.2.4

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.
@@ -3,6 +3,9 @@ import { queryUnsafe, getDriverType } from "../db.js";
3
3
  * Run EXPLAIN on a query and return a formatted analysis.
4
4
  */
5
5
  export async function explainQuery(sql, analyze = false) {
6
+ if (!sql || !sql.trim()) {
7
+ return "**Error**: SQL query cannot be empty.";
8
+ }
6
9
  // Safety: in ANALYZE mode, only allow pure SELECT statements.
7
10
  // EXPLAIN ANALYZE actually executes the query, so we must reject anything
8
11
  // that could modify data — including CTEs with write operations.
@@ -84,7 +84,7 @@ async function analyzeSqliteRelationships() {
84
84
  // Get FK info per table
85
85
  const fks = [];
86
86
  for (const table of tablesResult.rows) {
87
- const fkInfo = await query(`PRAGMA foreign_key_list('${table.name}')`);
87
+ const fkInfo = await query(`PRAGMA foreign_key_list("${table.name.replace(/"/g, '""')}")`);
88
88
  for (const fk of fkInfo.rows) {
89
89
  fks.push({
90
90
  source_table: table.name,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-db-analyzer",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "MCP server for PostgreSQL, MySQL, and SQLite schema analysis, index optimization, and query plan inspection",
5
5
  "author": "Dmytro Lisnichenko",
6
6
  "type": "module",