mcp-migration-advisor 0.2.12 → 0.2.13

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.
@@ -28,11 +28,12 @@ export function analyzeDataLoss(migration) {
28
28
  }
29
29
  case "DROP_TABLE": {
30
30
  const cascade = upper.includes("CASCADE");
31
+ const dropTableName = stmt.tableName ?? "unknown";
31
32
  issues.push({
32
33
  risk: "CERTAIN",
33
34
  statement: truncate(stmt.raw),
34
35
  tableName: stmt.tableName,
35
- description: `Dropping table '${stmt.tableName}' permanently deletes all data.${cascade ? " CASCADE will also drop dependent objects." : ""}`,
36
+ description: `Dropping table '${dropTableName}' permanently deletes all data.${cascade ? " CASCADE will also drop dependent objects." : ""}`,
36
37
  mitigation: "Ensure a backup exists. Consider renaming the table first and dropping in a later migration.",
37
38
  });
38
39
  break;
@@ -85,11 +85,12 @@ function analyzeStatement(stmt) {
85
85
  break;
86
86
  }
87
87
  case "DROP_TABLE": {
88
+ const dropTableName = stmt.tableName ?? "unknown";
88
89
  risks.push({
89
90
  severity: "HIGH",
90
91
  statement: truncate(stmt.raw),
91
92
  tableName: stmt.tableName,
92
- risk: `DROP TABLE '${stmt.tableName}' is irreversible and acquires ACCESS EXCLUSIVE lock.`,
93
+ risk: `DROP TABLE '${dropTableName}' is irreversible and acquires ACCESS EXCLUSIVE lock.`,
93
94
  recommendation: "Ensure no foreign keys reference this table. Consider renaming first (expand-contract) to allow rollback.",
94
95
  });
95
96
  if (stmt.details.cascade === "true") {
package/build/index.js CHANGED
@@ -6,9 +6,12 @@
6
6
  * analyze_migration — Parse and analyze a SQL migration for risks
7
7
  * score_risk — Calculate risk score for a migration
8
8
  */
9
+ import { createRequire } from "module";
9
10
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
10
11
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
11
12
  import { z } from "zod";
13
+ const require = createRequire(import.meta.url);
14
+ const { version: packageVersion } = require("../package.json");
12
15
  import { parseMigration } from "./parsers/flyway-sql.js";
13
16
  import { parseLiquibaseXml } from "./parsers/liquibase-xml.js";
14
17
  import { parseLiquibaseYaml } from "./parsers/liquibase-yaml.js";
@@ -33,7 +36,7 @@ function formatParserWarnings(migration) {
33
36
  }
34
37
  // Handle --help
35
38
  if (process.argv.includes("--help") || process.argv.includes("-h")) {
36
- console.log(`mcp-migration-advisor v0.2.12 — MCP server for database migration risk analysis
39
+ console.log(`mcp-migration-advisor v${packageVersion} — MCP server for database migration risk analysis
37
40
 
38
41
  Usage:
39
42
  mcp-migration-advisor [options]
@@ -52,10 +55,10 @@ Tools provided:
52
55
  }
53
56
  const server = new McpServer({
54
57
  name: "mcp-migration-advisor",
55
- version: "0.2.12",
58
+ version: packageVersion,
56
59
  });
57
60
  // Tool 1: analyze_migration
58
- server.tool("analyze_migration", "Analyze a SQL migration file for lock risks, data loss potential, and unsafe patterns. Supports Flyway (V__*.sql) and plain SQL.", {
61
+ server.tool("analyze_migration", "Analyze a SQL migration file for lock risks, data loss potential, and unsafe patterns. Detects: ACCESS EXCLUSIVE locks (DROP TABLE, ADD COLUMN NOT NULL, type changes, CREATE INDEX without CONCURRENTLY), data loss operations (TRUNCATE, DELETE without WHERE, UPDATE without WHERE, DROP COLUMN), and cascade risks. Supports Flyway versioned (V__*.sql) and repeatable (R__*.sql) migrations, as well as plain SQL files.", {
59
62
  filename: z.string().describe("Migration filename (e.g., V2__add_user_email.sql)"),
60
63
  sql: z.string().describe("The SQL content of the migration file"),
61
64
  }, async ({ filename, sql }) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-migration-advisor",
3
- "version": "0.2.12",
3
+ "version": "0.2.13",
4
4
  "description": "MCP server for database migration risk analysis — Flyway and Liquibase XML/YAML/SQL support with lock detection and conflict analysis",
5
5
  "mcpName": "io.github.dmitriusan/mcp-migration-advisor",
6
6
  "main": "build/index.js",