Skip to main content
Glama

Django Migrations MCP Service

by mrrobotke

Django 移行 MCP サービス

分散環境におけるDjangoの移行を管理するためのモデルコンテキストプロトコル(MCP)サービス。このサービスはDjangoの移行コマンドをラップし、MCPエンドポイントとして公開することで、複数のサービスにまたがる移行の管理やCI/CDパイプラインとの統合を容易にします。

特徴

  • 移行ステータスを確認する( showmigrationsと同等)
  • 検証付きの新しい移行を作成する( makemigrationsと同等)
  • 安全性チェック付きの移行を適用する( migrateと同等)
  • 追加の検証と安全性チェック:
    • 順次移行順序の検証
    • 競合検出
    • 依存関係の検証
    • 移行作業の安全性分析

インストール

地域開発

  1. リポジトリをクローンします。
git clone https://github.com/mrrobotke/django-migrations-mcp.git cd django-migrations-mcp
  1. 依存関係をインストールします:
pip install -r requirements.txt

構成

次の環境変数を設定します。

export DJANGO_SETTINGS_MODULE="your_project.settings" export MCP_SERVICE_PORT=8000 # Optional, defaults to 8000

使用法

サービスの実行

  1. Python で直接:
python -m migrations_mcp.service
  1. Docker の使用:
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-mcp

MCPエンドポイント

  1. 移行を表示:
from mcp import MCPClient client = MCPClient() migrations = await client.call("show_migrations")
  1. 移行を行う:
result = await client.call("make_migrations", { "app_labels": ["myapp"], # Optional "dry_run": True # Optional })
  1. 移行を適用します:
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.py

check_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ライセンス。詳細はLICENSEファイルを参照してください。

貢献

  1. リポジトリをフォークする
  2. 機能ブランチを作成します( git checkout -b feature/amazing-feature
  3. 変更をコミットします( git commit -m 'Add amazing feature'
  4. ブランチにプッシュする ( git push origin feature/amazing-feature )
  5. プルリクエストを開く

Dockerの使用

このプロジェクトには、様々なデプロイメントシナリオに対応する構造化されたコマンドを提供するdocker-commands.jsonファイルが含まれています。これらのコマンドは直接使用することも、スクリプト内で解析することもできます。

利用可能なDocker構成

  1. Redis MCP サーバー
# Run Redis MCP server docker run -i --rm mcp/redis redis://host.docker.internal:6379
  1. Django 移行 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
  1. 開発環境
# Using docker-compose docker-compose up -d --build
  1. テスト環境
# Run tests in container docker run --rm \ -e DJANGO_SETTINGS_MODULE=your_project.settings \ -e PYTHONPATH=/app \ -v ${PWD}:/app \ django-migrations-mcp \ pytest
  1. 生産環境
# 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'])

ネットワーク設定

  1. 開発ネットワーク
docker network create mcp-dev-network
  1. 生産ネットワーク
docker network create --driver overlay --attachable mcp-prod-network

MCPツールの使用

このサービスは、curl または任意の HTTP クライアント経由でアクセスできるいくつかのエンドポイントを公開します。

  1. 移行を表示
curl -X POST http://localhost:8000/mcp \ -H "Content-Type: application/json" \ -d '{"method": "show_migrations"}'
  1. 移行を行う
curl -X POST http://localhost:8000/mcp \ -H "Content-Type: application/json" \ -d '{"method": "make_migrations", "params": {"apps": ["your_app"]}}'
  1. 移行を適用する
curl -X POST http://localhost:8000/mcp \ -H "Content-Type: application/json" \ -d '{"method": "migrate", "params": {"app": "your_app"}}'
-
security - not tested
F
license - not found
-
quality - not tested

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

Django の移行コマンドを MCP エンドポイントとしてラップするモデル コンテキスト プロトコル サービス。これにより、複数のサービスにわたる移行の管理や CI/CD パイプラインとの統合が容易になります。

  1. 特徴
    1. インストール
      1. 地域開発
    2. 構成
      1. 使用法
        1. サービスの実行
        2. MCPエンドポイント
      2. CI/CD統合
        1. 発達
          1. テストの実行
          2. コードスタイル
        2. ライセンス
          1. 貢献
            1. Dockerの使用
              1. 利用可能なDocker構成
              2. プログラムによるコマンドの使用
              3. ネットワーク設定
              4. MCPツールの使用

            Related MCP Servers

            • -
              security
              A
              license
              -
              quality
              MCP Server simplifies the implementation of the Model Context Protocol by providing a user-friendly API to create custom tools and manage server workflows efficiently.
              Last updated 6 months ago
              4
              3
              TypeScript
              MIT License
            • -
              security
              A
              license
              -
              quality
              MCP Server provides a simpler API to interact with the Model Context Protocol by allowing users to define custom tools and services to streamline workflows and processes.
              Last updated 5 months ago
              13
              2
              TypeScript
              MIT License
            • -
              security
              F
              license
              -
              quality
              A Model Context Protocol server built with mcp-framework that allows users to create and manage custom tools for processing data, integrating with the Claude Desktop via CLI.
              Last updated 5 months ago
              48
              4
              TypeScript
              • Apple
            • A
              security
              A
              license
              A
              quality
              A dynamic service that creates and manages Model Context Protocol (MCP) servers, allowing users to spawn, customize, and control multiple MCP servers as child processes.
              Last updated 2 months ago
              5
              65
              TypeScript
              MIT License
              • Apple
              • Linux

            View all related MCP servers

            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/mrrobotke/django-migrations-mcp'

            If you have feedback or need assistance with the MCP directory API, please join our Discord server