Django Migrations MCP Service
Django 마이그레이션 MCP 서비스
분산 환경에서 Django 마이그레이션을 관리하기 위한 모델 컨텍스트 프로토콜(MCP) 서비스입니다. 이 서비스는 Django 마이그레이션 명령을 래핑하여 MCP 엔드포인트로 노출하므로 여러 서비스 간의 마이그레이션을 쉽게 관리하고 CI/CD 파이프라인과 통합할 수 있습니다.
특징
마이그레이션 상태 확인(
showmigrations와 동일)검증을 통해 새로운 마이그레이션을 생성합니다(
makemigrations와 동일)안전 검사를 사용하여 마이그레이션 적용(
migrate와 동일)추가 검증 및 안전 점검:
순차적 마이그레이션 순서 확인
충돌 감지
종속성 검증
이주 작업의 안전 분석
Related MCP server: PocketBase MCP Server
설치
지역 개발
저장소를 복제합니다.
지엑스피1
종속성 설치:
pip install -r requirements.txt구성
다음 환경 변수를 설정하세요.
export DJANGO_SETTINGS_MODULE="your_project.settings"
export MCP_SERVICE_PORT=8000 # Optional, defaults to 8000용법
서비스 실행
Python을 사용하여 직접:
python -m migrations_mcp.serviceDocker 사용:
docker build -t django-migrations-mcp .
docker run -e DJANGO_SETTINGS_MODULE=your_project.settings \
-v /path/to/your/django/project:/app/project \
-p 8000:8000 \
django-migrations-mcpMCP 엔드포인트
마이그레이션 표시:
from mcp import MCPClient
client = MCPClient()
migrations = await client.call("show_migrations")마이그레이션을 수행합니다.
result = await client.call("make_migrations", {
"app_labels": ["myapp"], # Optional
"dry_run": True # Optional
})마이그레이션 적용:
result = await client.call("migrate", {
"app_label": "myapp", # Optional
"migration_name": "0001", # Optional
"fake": False, # Optional
"plan": True # Optional
})CI/CD 통합
GitHub Actions 워크플로 예시:
name: Django Migrations Check
on:
pull_request:
paths:
- '*/migrations/*.py'
- '*/models.py'
jobs:
check-migrations:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.11'
- name: Install dependencies
run: |
pip install -r requirements.txt
- name: Start MCP service
run: |
python -m migrations_mcp.service &
- name: Check migrations
run: |
python ci/check_migrations.pycheck_migrations.py 스크립트 예시:
import asyncio
from mcp import MCPClient
async def check_migrations():
client = MCPClient()
# Check current status
migrations = await client.call("show_migrations")
# Try making migrations
result = await client.call("make_migrations", {"dry_run": True})
if not result.success:
print(f"Error: {result.message}")
exit(1)
print("Migration check passed!")
if __name__ == "__main__":
asyncio.run(check_migrations())개발
테스트 실행
pytest migrations_mcp/tests/코드 스타일
이 프로젝트는 PEP 8 가이드라인을 따릅니다. 다음을 사용하여 코드 형식을 지정하세요.
black migrations_mcp/
isort migrations_mcp/특허
MIT 라이선스. 자세한 내용은 라이선스 파일을 참조하세요.
기여하다
저장소를 포크하세요
기능 브랜치를 생성합니다(
git checkout -b feature/amazing-feature)변경 사항을 커밋하세요(
git commit -m 'Add amazing feature')브랜치에 푸시(
git push origin feature/amazing-feature)풀 리퀘스트 열기
Docker 사용법
이 프로젝트에는 다양한 배포 시나리오에 맞는 구조화된 명령을 제공하는 docker-commands.json 파일이 포함되어 있습니다. 이러한 명령을 직접 사용하거나 스크립트에서 구문 분석할 수 있습니다.
사용 가능한 Docker 구성
Redis MCP 서버
# Run Redis MCP server
docker run -i --rm mcp/redis redis://host.docker.internal:6379Django 마이그레이션 MCP 서버
# Basic setup
docker run -d \
--name django-migrations-mcp \
-e DJANGO_SETTINGS_MODULE=your_project.settings \
-e MCP_SERVICE_PORT=8000 \
-v /path/to/your/django/project:/app/project \
-p 8000:8000 \
django-migrations-mcp
# With Redis integration
docker run -d \
--name django-migrations-mcp \
-e DJANGO_SETTINGS_MODULE=your_project.settings \
-e MCP_SERVICE_PORT=8000 \
-e REDIS_URL=redis://host.docker.internal:6379 \
-v /path/to/your/django/project:/app/project \
-p 8000:8000 \
--network host \
django-migrations-mcp개발 환경
# Using docker-compose
docker-compose up -d --build테스트 환경
# Run tests in container
docker run --rm \
-e DJANGO_SETTINGS_MODULE=your_project.settings \
-e PYTHONPATH=/app \
-v ${PWD}:/app \
django-migrations-mcp \
pytest프로덕션 환경
# Production setup with health check
docker run -d \
--name django-migrations-mcp \
-e DJANGO_SETTINGS_MODULE=your_project.settings \
-e MCP_SERVICE_PORT=8000 \
-e REDIS_URL=redis://your-redis-host:6379 \
-v /path/to/your/django/project:/app/project \
-p 8000:8000 \
--restart unless-stopped \
--network your-network \
django-migrations-mcp프로그래밍 방식으로 명령 사용
명령을 프로그래밍 방식으로 구문 분석하고 사용할 수 있습니다.
import json
import subprocess
# Load commands
with open('docker-commands.json') as f:
commands = json.load(f)
# Run Redis MCP server
redis_config = commands['mcpServers']['redis']
subprocess.run([redis_config['command']] + redis_config['args'])
# Run Django Migrations MCP server
django_config = commands['mcpServers']['djangoMigrations']
subprocess.run([django_config['command']] + django_config['args'])네트워크 설정
개발 네트워크
docker network create mcp-dev-network제작 네트워크
docker network create --driver overlay --attachable mcp-prod-networkMCP 도구 사용
이 서비스는 curl이나 모든 HTTP 클라이언트를 통해 액세스할 수 있는 여러 엔드포인트를 제공합니다.
마이그레이션 표시
curl -X POST http://localhost:8000/mcp \
-H "Content-Type: application/json" \
-d '{"method": "show_migrations"}'마이그레이션을 만드세요
curl -X POST http://localhost:8000/mcp \
-H "Content-Type: application/json" \
-d '{"method": "make_migrations", "params": {"apps": ["your_app"]}}'마이그레이션 적용
curl -X POST http://localhost:8000/mcp \
-H "Content-Type: application/json" \
-d '{"method": "migrate", "params": {"app": "your_app"}}'This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
The official MCP Server from Mia-Platform to interact with Mia-Platform Console
An MCP server that provides an API to LLMs to manage their JumpCloud resources.
Model Context Protocol server for the Apideck Unified API. Connect any MCP-compatible agent framework to 100+ accounting systems, HRIS platforms, file storage providers, and more through one integration. More information https://www.apideck.com/mcp-server
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceA server implementation of the Model Context Protocol (MCP) that provides REST API endpoints for managing and interacting with MCP resources.-
- AlicenseNot gradedqualityDmaintenanceA comprehensive MCP server for managing PocketBase database schemas and migrations via REST API. It enables users to generate and execute migrations for creating, modifying, and deleting collections and fields directly through MCP-compatible clients.9MIT
- FlicenseNot gradedqualityDmaintenanceExposes Django runtime information (settings, apps, URLs, models, migrations) as MCP resources for AI agents to inspect a live Django project without static analysis.-
- AlicenseNot gradedqualityCmaintenanceA Model Context Protocol (MCP) server for developing Django applications. It exposes Django project information through MCP tools, enabling AI assistants to better understand and interact with Django codebases.111MIT