mcpField
A
Argocd

Argocd

ローカル
github.com/asklokeshクラウド・インフラ043 週間前に更新

Argocd について

Argocdは、GitOpsによる継続的デリバリーとKubernetesデプロイを管理する、GenAIアプリ向けのArgoCD MCPサーバーです。アプリ、プロジェクト、リポジトリ、クラスターやマルチクラスターのワークフローを扱います。

主な機能

  1. 01アプリの作成、同期、ロールバック、削除
  2. 02プロジェクト、リポジトリ、Kubernetesクラスターの管理
  3. 03アプリの健全性、同期状態、リソースツリーの監視
  4. 04RBAC、ロール、ポリシーの設定
  5. 05ApplicationSetとマルチクラスター展開のサポート
  6. 06段階的デリバリーと災害復旧ワークフロー

活用シーン

  1. 01アプリの健全性確認と同期ずれの調査
  2. 02GitリポジトリからKubernetesアプリを同期
  3. 03複数クラスターへのアプリ展開
  4. 04障害後のアプリのロールバックや復旧

MCP 対応

MCPサーバーとして、アプリ、プロジェクト、リポジトリ、クラスター、同期操作、健全性監視を行うArgoCD管理ツールをGenAIクライアントに提供します。

設定

ローカルサーバーの設定はどのクライアントでも共通です。コピーしてクライアントの MCP 設定ファイルに貼り付けてください。

mcp.json · 共通設定
{
"mcpServers": {
"asklokesh-argocd": {
"command": "uvx",
"args": [
"argocd-mcp-server"
],
"env": {
"ARGOCD_API_KEY": "<ARGOCD_API_KEY>",
"ARGOCD_API_URL": "<ARGOCD_API_URL>"
}
}
}
}
起動コマンドuvx argocd-mcp-server
設定が必要な環境変数
ARGOCD_API_KEYシークレットAPI Key for ARGOCD
ARGOCD_API_URLAPI URL for ARGOCD

ローカルサーバーにはマシン上の実行環境(Node.js 18 以上など)が必要です。設定ファイルの場所はクライアントごとに異なります。

パッケージ
pypiargocd-mcp-server0.1.0

ツール

ツール一覧はまだ取得されていません

ローカルサーバーのツールはマシン上で起動して初めて取得できます。メンテナーはまだツール一覧を提供していません。

詳細

ArgoCD MCP サーバー

ArgoCD MCP サーバー

GitHub stars GitHub forks GitHub watchers

License Issues Pull Requests Last Commit

Python MCP

Commit Activity Code Size Contributors

GenAI アプリケーションと ArgoCD GitOps 継続的デリバリーツールを統合し、Kubernetes デプロイメントをインテリジェントに管理できる Model Context Protocol(MCP)サーバーです。

機能

  • 包括的な ArgoCD API 対応:

    • アプリケーション管理:アプリケーションの作成、同期、削除、ロールバック
    • プロジェクト管理:プロジェクト、ロール、ポリシーの設定
    • リポジトリ管理:Git リポジトリや Helm チャートの追加/削除
    • クラスター管理:Kubernetes クラスターの登録と管理
    • 同期操作:手動/自動同期、同期ウィンドウ、フック
    • ヘルスモニタリング:アプリケーションのヘルス、同期ステータス、リソースツリー
    • RBAC 管理:ユーザー、ロール、ポリシー、JWT トークン
    • GitOps ワークフロー:Git コミットからの自動デプロイ
    • マルチテナンシー:名前空間の分離、プロジェクトの制限
    • ApplicationSet:テンプレートベースのマルチクラスター デプロイ
  • 認証方式:

    • JWT トークン認証
    • API トークン認証
    • OIDC/OAuth2 統合
    • LDAP 認証のサポート
  • エンタープライズ機能:

    • マルチクラスター対応
    • 災害復旧ワークフロー
    • プログレッシブデリバリー(カナリア、ブルーグリーン)
    • 障害発生時の自動ロールバック
    • 監査ログとコンプライアンス
    • リソース最適化
    • シークレット管理との統合

インストール

pip install argocd-mcp-server

または、ソースからインストールします:

git clone https://github.com/asklokesh/argocd-mcp-server.git
cd argocd-mcp-server
pip install -e .

設定

.env ファイルを作成するか、環境変数を設定します:

# ArgoCD Connection
ARGOCD_SERVER=argocd.example.com
ARGOCD_AUTH_TOKEN=your_auth_token
ARGOCD_INSECURE=false

# Optional Settings
ARGOCD_GRPC_WEB=true
ARGOCD_TIMEOUT=30
ARGOCD_CLIENT_CERT=/path/to/cert.pem
ARGOCD_CLIENT_KEY=/path/to/key.pem

# Multi-Cluster Support
ARGOCD_PROD_SERVER=argocd-prod.example.com
ARGOCD_PROD_TOKEN=prod_token

ARGOCD_DEV_SERVER=argocd-dev.example.com
ARGOCD_DEV_TOKEN=dev_token

クイックスタート

基本的な使い方
from argocd_mcp import ArgoCDMCPServer

# Initialize the server
server = ArgoCDMCPServer()

# Start the server
server.start()
Claude Desktop の設定

Claude Desktop の設定に追加します:

{
  "mcpServers": {
    "argocd": {
      "command": "python",
      "args": ["-m", "argocd_mcp.server"],
      "env": {
        "ARGOCD_SERVER": "argocd.example.com",
        "ARGOCD_AUTH_TOKEN": "your_auth_token"
      }
    }
  }
}

利用可能なツール

アプリケーション管理
アプリケーション一覧
{
  "tool": "argocd_list_applications",
  "arguments": {
    "project": "default",
    "namespace": "argocd"
  }
}
アプリケーションの作成
{
  "tool": "argocd_create_application",
  "arguments": {
    "name": "my-app",
    "project": "default",
    "source": {
      "repoURL": "https://github.com/org/repo.git",
      "path": "manifests",
      "targetRevision": "main"
    },
    "destination": {
      "server": "https://kubernetes.default.svc",
      "namespace": "production"
    },
    "syncPolicy": {
      "automated": {
        "prune": true,
        "selfHeal": true
      }
    }
  }
}
アプリケーションの同期
{
  "tool": "argocd_sync_application",
  "arguments": {
    "name": "my-app",
    "prune": true,
    "force": false,
    "strategy": {
      "hook": {
        "force": true
      }
    }
  }
}
アプリケーションのステータス取得
{
  "tool": "argocd_get_application_status",
  "arguments": {
    "name": "my-app",
    "refresh": true
  }
}
アプリケーションのロールバック
{
  "tool": "argocd_rollback_application",
  "arguments": {
    "name": "my-app",
    "revision": "abc123"
  }
}
プロジェクト管理
プロジェクトの作成
{
  "tool": "argocd_create_project",
  "arguments": {
    "name": "production",
    "description": "Production applications",
    "sourceRepos": ["https://github.com/org/*"],
    "destinations": [
      {
        "server": "https://kubernetes.default.svc",
        "namespace": "prod-*"
      }
    ],
    "clusterResourceWhitelist": [
      {"group": "*", "kind": "*"}
    ]
  }
}
リポジトリ管理
リポジトリの追加
{
  "tool": "argocd_add_repository",
  "arguments": {
    "url": "https://github.com/org/repo.git",
    "name": "my-repo",
    "type": "git",
    "username": "git-user",
    "password": "git-token",
    "insecure": false
  }
}
Helm リポジトリの追加
{
  "tool": "argocd_add_helm_repository",
  "arguments": {
    "url": "https://charts.example.com",
    "name": "my-charts",
    "type": "helm",
    "username": "helm-user",
    "password": "helm-password"
  }
}
クラスター管理
クラスターを追加
{
  "tool": "argocd_add_cluster",
  "arguments": {
    "name": "production-cluster",
    "server": "https://k8s-prod.example.com",
    "config": {
      "bearerToken": "cluster-token",
      "tlsClientConfig": {
        "insecure": false,
        "caData": "base64-encoded-ca"
      }
    }
  }
}
アプリケーションセット
ApplicationSet を作成
{
  "tool": "argocd_create_applicationset",
  "arguments": {
    "name": "multi-cluster-app",
    "generators": [
      {
        "clusters": {},
        "selector": {
          "matchLabels": {
            "environment": "production"
          }
        }
      }
    ],
    "template": {
      "metadata": {
        "name": "{{cluster}}-app"
      },
      "spec": {
        "project": "default",
        "source": {
          "repoURL": "https://github.com/org/repo.git",
          "path": "{{cluster}}"
        },
        "destination": {
          "server": "{{server}}",
          "namespace": "default"
        }
      }
    }
  }
}
ヘルスとモニタリング
アプリケーションのヘルスを取得
{
  "tool": "argocd_get_application_health",
  "arguments": {
    "name": "my-app"
  }
}
リソースツリーを取得
{
  "tool": "argocd_get_resource_tree",
  "arguments": {
    "name": "my-app"
  }
}

高度な設定

マルチクラスター GitOps
from argocd_mcp import ArgoCDMCPServer, ClusterConfig

# Configure multiple ArgoCD instances
clusters = {
    "production": ClusterConfig(
        server="argocd-prod.example.com",
        auth_token="prod_token",
        default_namespace="argocd"
    ),
    "staging": ClusterConfig(
        server="argocd-staging.example.com",
        auth_token="staging_token",
        default_namespace="argocd-staging"
    ),
    "development": ClusterConfig(
        server="argocd-dev.example.com",
        auth_token="dev_token",
        default_namespace="argocd-dev"
    )
}

server = ArgoCDMCPServer(clusters=clusters, default_cluster="production")
プログレッシブデリバリー
# Configure progressive delivery strategies
progressive_config = {
    "canary": {
        "steps": [
            {"setWeight": 10},
            {"pause": {"duration": "5m"}},
            {"setWeight": 30},
            {"pause": {"duration": "5m"}},
            {"setWeight": 50},
            {"pause": {"duration": "5m"}},
            {"setWeight": 100}
        ]
    },
    "blueGreen": {
        "activeService": "app-active",
        "previewService": "app-preview",
        "autoPromotionEnabled": false
    }
}

server = ArgoCDMCPServer(progressive_config=progressive_config)
災害復旧
from argocd_mcp import ArgoCDMCPServer, DisasterRecoveryConfig

dr_config = DisasterRecoveryConfig(
    backup_enabled=True,
    backup_schedule="0 2 * * *",  # Daily at 2 AM
    backup_location="s3://backups/argocd",
    restore_priority=["production", "staging", "development"]
)

server = ArgoCDMCPServer(dr_config=dr_config)

統合例

完全な統合例については、examples/ ディレクトリを参照してください。

  • basic_gitops.py - 基本的な GitOps ワークフロー
  • multi_cluster_deployment.py - マルチクラスターアプリケーションのデプロイ
  • progressive_delivery.py - カナリアデプロイとブルーグリーンデプロイ
  • disaster_recovery.py - バックアップと復元のワークフロー
  • genai_gitops.py - AI を活用した GitOps の自動化
  • security_scanning.py - セキュリティツールとの統合

セキュリティのベストプラクティス

  1. 最小限の権限を持つサービスアカウントを使用する
  2. 適切なポリシーで RBAC を有効にする
  3. クラスターを分離するネットワークポリシーを実装する
  4. Sealed Secrets または外部シークレットオペレーターを使用する
  5. コンプライアンスのために監査ログを有効にする
  6. ポリシー適用のためにアドミッションコントローラーを実装する
  7. イメージとマニフェストを定期的にセキュリティスキャンする

エラー処理

サーバーは詳細なエラー情報を提供します。

try:
    result = server.execute_tool("argocd_sync_application", {
        "name": "my-app"
    })
except ArgoCDError as e:
    print(f"ArgoCD error: {e.error_code} - {e.message}")
    if e.error_code == "OutOfSync":
        print("Application is out of sync")
    elif e.error_code == "ComparisonError":
        print("Error comparing application state")

パフォーマンスの最適化

  1. 類似したアプリにはアプリケーションセットを使用する
  2. ArgoCD でリソースキャッシュを有効にする
  3. デプロイ時刻を制御するために同期ウィンドウを実装する
  4. ポーリングの代わりに Webhook 通知を使用する
  5. Helm/Kustomize でマニフェスト生成を最適化する

トラブルシューティング

よくある問題
  1. 同期の失敗

    • アプリケーションログを確認する
    • リポジトリへのアクセスを確認する
    • リソースクォータを確認する
  2. 認証エラー

    • トークンの有効性を確認する
    • RBAC ポリシーを確認する
    • サーバーの接続状態を確認する
  3. パフォーマンスの問題

    • ArgoCD サーバーのリソースを確認する
    • アプリケーション数を確認する
    • マニフェストサイズを最適化する

コントリビューション

コントリビューションを歓迎します。コントリビューションガイドラインをお読みのうえ、プルリクエストを送信してください。

ライセンス

MIT License - 詳細については LICENSE file を参照してください

コメント

MCP は初めてですか?

プロトコルの概要から最初のサーバーの導入まで、よくある疑問にまとめて答えます。

AI アプリケーションが外部のツールやデータソースに統一的な方法で接続するためのオープンなプロトコルです。クライアントはモデルとの対話を担い、MCP サーバーはツール・リソース・プロンプトテンプレートを提供します。標準メッセージでやり取りするため、1 つのサーバーを複数のクライアントで再利用できます。