mcp-db-analyzer 0.2.7 → 0.2.8

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.
@@ -172,7 +172,8 @@ async function analyzeMysqlConnections() {
172
172
  lines.push("| ID | User | Duration (s) | State | Query |");
173
173
  lines.push("|-----|------|-------------|-------|-------|");
174
174
  for (const row of longQueries.rows) {
175
- lines.push(`| ${row.id} | ${row.user} | ${row.time} | ${row.state} | ${row.info} |`);
175
+ const info = row.info ? row.info.replace(/\|/g, "\\|") : "-";
176
+ lines.push(`| ${row.id} | ${row.user} | ${row.time} | ${row.state} | ${info} |`);
176
177
  }
177
178
  lines.push("");
178
179
  }
@@ -11,6 +11,9 @@ export function createSqliteAdapter() {
11
11
  }
12
12
  db = new Database(dbPath, { readonly: true });
13
13
  db.pragma("journal_mode = WAL");
14
+ // Enforce read-only at the SQL engine level, not just at the file level.
15
+ // This prevents any write attempt from succeeding even if the OS permits it.
16
+ db.pragma("query_only = ON");
14
17
  }
15
18
  return db;
16
19
  }
package/build/errors.js CHANGED
@@ -4,7 +4,11 @@
4
4
  */
5
5
  export function formatToolError(context, err) {
6
6
  const msg = err instanceof Error ? err.message : String(err);
7
- const sanitized = msg.replace(/\/\/[^@]+@/g, "//****:****@");
7
+ // Sanitize URL-style credentials (postgresql://user:pass@host) and
8
+ // key-value style passwords (password=secret) used by libpq and JDBC.
9
+ const sanitized = msg
10
+ .replace(/\/\/[^@]+@/g, "//****:****@")
11
+ .replace(/\bpassword\s*=\s*\S+/gi, "password=****");
8
12
  const isConnectionError = /ECONNREFUSED|ENOTFOUND|ETIMEDOUT|EHOSTUNREACH|getaddrinfo|connect ECONNRESET|password authentication failed|Access denied|no pg_hba\.conf|connection refused|Connection lost|SQLITE_CANTOPEN/i.test(msg);
9
13
  if (isConnectionError) {
10
14
  return `Error ${context}: ${sanitized}\n\nThis looks like a database connection issue. Check your configuration:\n- Set DATABASE_URL environment variable with a valid connection string\n- Or use driver-specific variables (PGHOST, MYSQL_HOST, SQLITE_PATH)\n- Ensure the database server is running and accessible`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-db-analyzer",
3
- "version": "0.2.7",
3
+ "version": "0.2.8",
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",