db-legacy-migration-agent
Supports MySQL as a source dialect for parsing legacy DDL and transpiling it to PostgreSQL with generated Prisma schema and TypeScript query helpers.
Acts as the target database for transpiled schemas, producing PostgreSQL DDL through the generated Prisma schema.
Generates Prisma ORM schema definitions from legacy DDL, including type mappings, relations, and query helpers for Prisma Client.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@db-legacy-migration-agentMigrate this Oracle DDL to PostgreSQL Prisma schema."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
db-legacy-migration-agent
CLI and MCP Server that parses legacy relational DB schemas (DB2, Oracle PL/SQL, MySQL, MSSQL) and transpiles them automatically to PostgreSQL with a generated Prisma ORM schema and TypeScript query helpers.
Table of Contents
Related MCP server: db-mcp
Overview
Legacy enterprise systems often rely on vendor-specific SQL dialects (Oracle PL/SQL, IBM DB2, Microsoft T-SQL) that cannot be migrated directly to modern stacks without significant manual effort. This tool automates the structural translation phase:
Input | Output |
|
|
PL/SQL | Best-effort TypeScript equivalent |
Any mix of legacy DDL | TypeScript Prisma Client query helpers |
Full DDL file | Validation report with precision-loss analysis |
Architecture
src/
├── parser/
│ └── sql-transpiler.ts # DDL lexer/parser + Prisma/TS code generator
├── engine/
│ └── schema-validator.ts # Precision-loss & semantic mismatch validator
├── mcp/
│ └── server.ts # MCP server (stdio transport)
└── cli.ts # Commander.js interactive CLI
tests/
└── transpiler.test.ts # Jest unit tests (40+ assertions)Core Modules
src/parser/sql-transpiler.ts
Responsible for the full transpilation pipeline:
Tokenisation — strips comments, normalises whitespace, handles quoted identifiers
DDL parsing —
CREATE TABLEwith columns, constraints, FKs, indexesPL/SQL parsing —
CREATE [OR REPLACE] PROCEDURE/FUNCTIONwith parameter directionsType mapping — 40+ legacy type mappings to
{ prismaType, postgresType }Prisma schema generation —
@@map,@db.*annotations, composite PKs, FK relationsTypeScript query generation — CRUD helpers using
PrismaClientPL/SQL structural translation —
BEGIN/END,IF/THEN/ELSIF,FOR/WHILE LOOP,:=,DBMS_OUTPUT
src/engine/schema-validator.ts
Runs a rule engine over the transpiled table definitions and emits structured ValidationIssue records:
Critical — data loss guaranteed (e.g.,
BIGINT_OVERFLOW,NULLABLE_PK)Warning — semantic mismatch requiring review (e.g.,
ORACLE_DATE_HAS_TIME,XMLTYPE_NO_NATIVE)Info — informational notes (e.g.,
LOB_TO_TEXT,DB2_GRAPHIC_TYPE)
src/mcp/server.ts
MCP server exposing three tools over stdio transport:
Tool | Description |
| Full parse + generate: returns AST, Prisma schema, TS queries |
| Returns only the |
| Returns structured or text validation report |
Getting Started
Prerequisites
Node.js ≥ 18
npm ≥ 9
Install
npm installBuild
npm run buildLink CLI globally (optional)
npm link
db-migrate --helpCLI Commands
transpile <file>
Parses a DDL file and generates schema.prisma, queries.ts, and ast.json in the output directory.
npx ts-node src/cli.ts transpile ./examples/oracle_hr.sql \
--dialect oracle \
--out ./outputOptions:
Flag | Default | Description |
|
| Source dialect: |
|
| Output directory |
| — | Skip TypeScript query generation |
| — | Skip post-transpile validation |
validate <file>
Validates type mappings and outputs a structured report.
npx ts-node src/cli.ts validate ./examples/oracle_hr.sql \
--dialect oracle \
--format textOptions:
Flag | Default | Description |
|
| Source dialect |
|
|
|
| — | Exit code 1 if warnings found (for CI pipelines) |
Exit codes:
Code | Meaning |
| No issues or info only |
| Warnings found (only with |
| Critical issues found |
parse-inline <ddl>
Quick test — parse a DDL string directly from the command line.
npx ts-node src/cli.ts parse-inline \
"CREATE TABLE T (ID NUMBER(10) NOT NULL, NAME VARCHAR2(100), CONSTRAINT PK_T PRIMARY KEY (ID));"mcp
Start the MCP server over stdio (for AI assistant integration).
npx ts-node src/cli.ts mcpMCP Server
The MCP server can be registered with any MCP-compatible AI assistant (e.g., Claude Desktop, IBM Bob).
Tool: parse_legacy_ddl
{
"tool": "parse_legacy_ddl",
"input": {
"ddl": "CREATE TABLE EMPLOYEES (...);",
"dialect": "oracle",
"include_typescript": true
}
}Returns: full AST, Prisma schema, TypeScript queries, warnings.
Tool: generate_prisma_schema
{
"tool": "generate_prisma_schema",
"input": {
"ddl": "CREATE TABLE EMPLOYEES (...);",
"dialect": "oracle"
}
}Returns: schema.prisma content as a plain string.
Tool: validate_type_mapping
{
"tool": "validate_type_mapping",
"input": {
"ddl": "CREATE TABLE EMPLOYEES (...);",
"dialect": "oracle",
"format": "json"
}
}Returns: structured ValidationReport JSON or human-readable text.
Type Mapping Reference
Legacy Type | Prisma Type | PostgreSQL Type | Notes |
|
|
| Precision preserved |
|
|
| Scale preserved |
|
|
| Fits 32-bit |
|
|
| Fits 64-bit |
|
|
| ⚠ BigInt would overflow |
|
|
| |
|
|
| Fixed-length padding |
|
|
| ℹ No separate LOB segment |
|
|
| ℹ Inline storage |
|
|
| ⚠ Oracle DATE includes time |
|
|
| |
|
|
| |
|
|
| ⚠ Single precision |
|
|
| |
|
|
| ⚠ No Prisma native XML |
|
|
| |
|
|
| |
|
|
| |
|
|
|
Validation Rules
Code | Severity | Trigger | Recommendation |
| warning |
| Add explicit scale |
| critical |
| Use |
| warning |
| Use |
| info |
| Update LOB streaming APIs |
| info |
| Use lo API for > 1 GB values |
| warning | Oracle | Use |
| warning |
| Verify TZ conversion logic |
| warning |
| Replace with |
| info |
| Use |
| warning |
| Use |
| info | DB2 | Verify UTF-8 transcoding |
| warning | Table has no PK | Add |
| critical | PK column parsed as nullable | Fix source DDL |
Project Structure
db-legacy-migration-agent/
├── src/
│ ├── parser/
│ │ └── sql-transpiler.ts # Type mappings, DDL parser, Prisma & TS generators
│ ├── engine/
│ │ └── schema-validator.ts # Rule engine, ValidationReport, formatter
│ ├── mcp/
│ │ └── server.ts # MCP server with 3 tools
│ └── cli.ts # Commander.js CLI entrypoint
├── tests/
│ └── transpiler.test.ts # Jest unit tests
├── dist/ # Compiled output (after `npm run build`)
├── output/ # Generated files (schema.prisma, queries.ts, ast.json)
├── package.json
├── tsconfig.json
└── README.mdRunning Tests
# Run all tests
npm test
# With coverage
npm test -- --coverage
# Watch mode
npm test -- --watchExpected output: 40+ assertions across transpiler parsing, type mapping, PL/SQL translation, and validator rules.
Contributing
Fork and clone the repository
Run
npm installto install dependenciesAdd your feature/fix in
src/Add or update tests in
tests/Run
npm testandnpm run typecheckbefore submitting a PR
License
MIT
This server cannot be installed
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceAn extensible MCP server for database operations that supports PostgreSQL for managing schemas, tables, data, and user permissions. It features automatic migration recording for DDL changes and integrates with various AI-powered editors like Cursor, Zed, and Claude Code.222MIT
- AlicenseAqualityCmaintenanceA lightweight MCP server for relational databases, enabling dynamic connections to PostgreSQL and MySQL, SQL execution, and transaction control.7511MIT
- AlicenseNot gradedqualityDmaintenanceMCP server that analyzes TypeScript/Prisma projects, builds dependency graphs, and protects against dangerous modifications and silent regressions.141MIT
- AlicenseAqualityAmaintenanceMCP server that reads your database schema from SQL DDL, Prisma, Drizzle, TypeORM, or SQLAlchemy, generates a Mermaid ER diagram, and writes it into your documentation, with drift detection to keep diagrams up-to-date.51MIT
Related MCP Connectors
MCP server for managing Prisma Postgres.
MCP server for interacting with the Supabase platform
Butterbase MCP server — manage your backend: schemas, auth, functions, storage, RAG, deploys.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/felipeassis10/db-legacy-migration-agent'
If you have feedback or need assistance with the MCP directory API, please join our Discord server