MSSQL Migration MCP Server (Python)
MSSQL Stored Procedure / Function을 분석하고, Java + Spring Boot + MyBatis 마이그레이션을 표준화/자동화하기 위한 MCP(Model Context Protocol) 서버입니다. VS Code에서 GitHub Copilot과 연동하여 SP/FN 분석 결과, 변환 가이드, RAG 기반 참고 자료를 툴 형태로 제공하는 것을 목표로 합니다.
주요 기능
1) SP/FN 분석
- SP/FN 에 사용하고 있는 함수 및 테이블 추출
- 트랜잭션 패턴 분석 (BEGIN/COMMIT/ROLLBACK, TRY/CATCH)
- 마이그레이션 영향 로직 탐지 (CURSOR, 동적 SQL, 임시테이블, MERGE 등)
- 제어 흐름 분석 (IF/WHILE/CASE/RETURN)
- 데이터 변경 유형 분류 (SELECT/INSERT/UPDATE/DELETE/MERGE)
- 에러/예외 처리 패턴 분석
2) 공통 기능 후보 판별
- 해당 SP/FN을 호출하는 다른 SP/FN 존재 여부 및 호출 수 확인
- 재사용/확장 가능성(유틸화 가능성) 평가
- 비즈니스 규칙 추출 및 표준 템플릿 매핑
- 호출 그래프(Call Graph) 생성
- 공통화 위험도 스코어링
3) 마이그레이션 설계 지원
- Java/MyBatis 매핑 전략 추천
- 트랜잭션 경계 제안
- MyBatis 변환 난이도 평가
4) 품질/운영 지원
- 성능 리스크 탐지
- DB 의존도 점수
5) RAG 기반 표준화(옵션)
- 사내 표준 문서/가이드, 변환 규칙, 예제 코드 등을 인덱싱
- 분석 결과와 함께 근거 문서/권장 패턴을 함께 반환
MCP API
Endpoints
GET /health: 서버 상태 확인 ({"status":"ok"})POST /mcp/analyze: SP/FN 분석 결과 반환POST /mcp/standardize/spec: 표준화 스펙 생성 (5.1)POST /mcp/standardize/spec-with-evidence: 표준화 스펙 + 근거 문서 (5.2)POST /mcp/callers: 호출 관계(콜러) 분석POST /mcp/external-deps: 외부 의존성 분석POST /mcp/common/reusability: 유틸화 가능성 평가(스코어/사유/권장사항)POST /mcp/common/rules-template: 비즈니스 규칙 + 템플릿 매핑POST /mcp/common/call-graph: 호출 그래프 생성POST /mcp/migration/mapping-strategy: Java + MyBatis 매핑 전략 추천POST /mcp/migration/mybatis-difficulty: MyBatis 변환 난이도 평가POST /mcp/migration/transaction-boundary: 트랜잭션 경계 가이드POST /mcp/quality/performance-risk: 성능 리스크 분석POST /mcp/quality/db-dependency: DB 의존도 분석
Notes
- Offline only (no network, no DB, no API keys required for tests).
- No raw SQL is returned in API responses.
- Deterministic outputs for identical inputs (ordering and truncation are stable).
Example curl
curl -X POST http://localhost:9700/mcp/analyze \
-H "Content-Type: application/json" \
-d '{"sql":"","dialect":"tsql"}'curl -X POST http://localhost:9700/mcp/standardize/spec-with-evidence \
-H "Content-Type: application/json" \
-d '{"object":{"name":"dbo.usp_Name","type":"procedure"},"sql":"","options":{"docs_dir":"data/standard_docs","top_k":3}}'curl -X POST http://localhost:9700/mcp/migration/mapping-strategy \
-H "Content-Type: application/json" \
-d '{"name":"dbo.usp_Name","type":"procedure","sql":"","options":{"target_style":"rewrite"}}'VS Code MCP (HTTP)
VS Code 설정 예시 (.vscode/mcp.json)
{
"servers": {
"mssql-migration": {
"type": "http",
"url": "http://localhost:9700/mcp"
}
}
}실행 방법
uvicorn app.main:app --host 0.0.0.0 --port 9700Handshake expectations
initialize(JSON-RPC request)notifications/initialized(JSON-RPC notification)tools/listtools/call
MCP tools
tsql.analyze
- 설명: T-SQL을 분석하여 참조/트랜잭션/제어 흐름/마이그레이션 영향 등을 반환한다.
- Input schema 요약:
- sql (string, required): 분석 대상 T-SQL - dialect (string, optional, default: tsql)
- Output 요약:
- references, transactions, migration_impacts, control_flow, data_changes, error_handling, errors
