mcp-migration-advisor 0.2.4 → 0.2.5
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/README.md +7 -0
- package/build/analyzers/data-loss.js +0 -10
- package/build/index.js +17 -12
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -153,6 +153,13 @@ Returns a conflict report with severity levels, affected tables/columns, and whe
|
|
|
153
153
|
- **No execution**: The advisor analyzes but never executes migrations. All recommendations are advisory.
|
|
154
154
|
- **Database-specific DDL**: Parser targets PostgreSQL/MySQL DDL syntax. Oracle PL/SQL or SQL Server T-SQL may not be fully recognized.
|
|
155
155
|
|
|
156
|
+
## Part of the MCP Java Backend Suite
|
|
157
|
+
|
|
158
|
+
- [mcp-db-analyzer](https://www.npmjs.com/package/mcp-db-analyzer) — PostgreSQL/MySQL/SQLite schema analysis
|
|
159
|
+
- [mcp-spring-boot-actuator](https://www.npmjs.com/package/mcp-spring-boot-actuator) — Spring Boot health, metrics, and bean analysis
|
|
160
|
+
- [mcp-jvm-diagnostics](https://www.npmjs.com/package/mcp-jvm-diagnostics) — Thread dump and GC log analysis
|
|
161
|
+
- [mcp-redis-diagnostics](https://www.npmjs.com/package/mcp-redis-diagnostics) — Redis memory, slowlog, and client diagnostics
|
|
162
|
+
|
|
156
163
|
## License
|
|
157
164
|
|
|
158
165
|
MIT
|
|
@@ -8,16 +8,6 @@
|
|
|
8
8
|
* - Table drops
|
|
9
9
|
* - CASCADE operations
|
|
10
10
|
*/
|
|
11
|
-
// Types that lose precision when converted
|
|
12
|
-
const NARROWING_CONVERSIONS = {
|
|
13
|
-
"BIGINT": ["INTEGER", "SMALLINT", "TINYINT"],
|
|
14
|
-
"INTEGER": ["SMALLINT", "TINYINT"],
|
|
15
|
-
"DOUBLE PRECISION": ["REAL", "FLOAT4", "NUMERIC"],
|
|
16
|
-
"TEXT": ["VARCHAR", "CHAR"],
|
|
17
|
-
"VARCHAR": ["CHAR"],
|
|
18
|
-
"TIMESTAMP": ["DATE", "TIME"],
|
|
19
|
-
"TIMESTAMPTZ": ["DATE", "TIME", "TIMESTAMP"],
|
|
20
|
-
};
|
|
21
11
|
/**
|
|
22
12
|
* Analyze a migration for data loss risks.
|
|
23
13
|
*/
|
package/build/index.js
CHANGED
|
@@ -33,7 +33,7 @@ function formatParserWarnings(migration) {
|
|
|
33
33
|
}
|
|
34
34
|
// Handle --help
|
|
35
35
|
if (process.argv.includes("--help") || process.argv.includes("-h")) {
|
|
36
|
-
console.log(`mcp-migration-advisor v0.2.
|
|
36
|
+
console.log(`mcp-migration-advisor v0.2.5 — MCP server for database migration risk analysis
|
|
37
37
|
|
|
38
38
|
Usage:
|
|
39
39
|
mcp-migration-advisor [options]
|
|
@@ -52,7 +52,7 @@ Tools provided:
|
|
|
52
52
|
}
|
|
53
53
|
const server = new McpServer({
|
|
54
54
|
name: "mcp-migration-advisor",
|
|
55
|
-
version: "0.2.
|
|
55
|
+
version: "0.2.5",
|
|
56
56
|
});
|
|
57
57
|
// Tool 1: analyze_migration
|
|
58
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.", {
|
|
@@ -202,29 +202,34 @@ server.tool("score_risk", "Calculate the overall risk score (0-100) for a SQL mi
|
|
|
202
202
|
const highCount = lockRisks.filter(r => r.severity === "HIGH").length;
|
|
203
203
|
const dataLossCertain = dataLossIssues.filter(i => i.risk === "CERTAIN").length;
|
|
204
204
|
const dataLossLikely = dataLossIssues.filter(i => i.risk === "LIKELY").length;
|
|
205
|
+
const dataLossPossible = dataLossIssues.filter(i => i.risk === "POSSIBLE").length;
|
|
206
|
+
// Combine lock risk score with data loss severity for a complete picture
|
|
207
|
+
const dataLossScore = Math.min(100, dataLossCertain * 25 + dataLossLikely * 15 + dataLossPossible * 5);
|
|
208
|
+
const combinedScore = Math.min(100, riskScore + dataLossScore);
|
|
205
209
|
let verdict;
|
|
206
|
-
if (
|
|
210
|
+
if (combinedScore >= 60 || dataLossCertain > 0) {
|
|
207
211
|
verdict = "HIGH RISK — requires careful review and testing before deployment";
|
|
208
212
|
}
|
|
209
|
-
else if (
|
|
213
|
+
else if (combinedScore >= 30 || dataLossLikely > 0) {
|
|
210
214
|
verdict = "MODERATE RISK — review lock duration and test on staging";
|
|
211
215
|
}
|
|
212
216
|
else {
|
|
213
217
|
verdict = "LOW RISK — standard migration, proceed with normal deployment";
|
|
214
218
|
}
|
|
215
|
-
const output = `## Risk Score: ${
|
|
219
|
+
const output = `## Risk Score: ${combinedScore}/100
|
|
216
220
|
|
|
217
221
|
**Verdict**: ${verdict}
|
|
218
222
|
|
|
219
223
|
### Breakdown
|
|
220
224
|
|
|
221
|
-
| Category | Count |
|
|
222
|
-
|
|
223
|
-
| CRITICAL lock risks | ${criticalCount} |
|
|
224
|
-
| HIGH lock risks | ${highCount} |
|
|
225
|
-
| Certain data loss | ${dataLossCertain} |
|
|
226
|
-
| Likely data loss | ${dataLossLikely} |
|
|
227
|
-
|
|
|
225
|
+
| Category | Count | Score contribution |
|
|
226
|
+
|----------|-------|--------------------|
|
|
227
|
+
| CRITICAL lock risks | ${criticalCount} | ${criticalCount * 30} |
|
|
228
|
+
| HIGH lock risks | ${highCount} | ${highCount * 20} |
|
|
229
|
+
| Certain data loss | ${dataLossCertain} | ${dataLossCertain * 25} |
|
|
230
|
+
| Likely data loss | ${dataLossLikely} | ${dataLossLikely * 15} |
|
|
231
|
+
| Possible data loss | ${dataLossPossible} | ${dataLossPossible * 5} |
|
|
232
|
+
| Total statements | ${migration.statements.length} | — |
|
|
228
233
|
`;
|
|
229
234
|
return {
|
|
230
235
|
content: [{ type: "text", text: output }],
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mcp-migration-advisor",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "MCP server for database migration risk analysis — Flyway and Liquibase XML/YAML/SQL support with lock detection and conflict analysis",
|
|
5
|
-
"mcpName": "
|
|
5
|
+
"mcpName": "io.github.dmitriusan/mcp-migration-advisor",
|
|
6
6
|
"main": "build/index.js",
|
|
7
7
|
"bin": {
|
|
8
8
|
"mcp-migration-advisor": "build/index.js"
|