0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

IBM BobからMCP経由でOpenShiftに接続し、仮想マシンを操作する

0
Posted at

1. 初めに

IBM BobからMCP経由でOpenshiftに接続して、Openshift Virtulizationの仮想マシンを操作してみたので、ご紹介します。

MCPサーバーとしては、以下のものを使用しました。
Openshift MCP Server (https://github.com/openshift/openshift-mcp-server)

2. 実行結果

(1) 仮想マシン作成
vm-create.gif

(2) 仮想マシン起動
vm-start.gif

(3) 仮想マシン停止
vm-stop.gif

3. セットアップ手順(Windows環境を想定)

前提条件
・node.jsが導入されていること(npxコマンドが使えること)

導入手順
(1) Openshift Service Accountの作成
以下のコマンドを実行

PS> oc new-project mcp
PS> oc create serviceaccount mcp-viewer -n mcp
PS> oc adm policy add-cluster-role-to-user cluster-reader system:serviceaccount:mcp:mcp-viewer
PS> oc adm policy add-cluster-role-to-user kubevirt.io:edit system:serviceaccount:mcp:mcp-viewer

(2) kubeconfigファイルの作成
以下のコマンドの実行

PS> $TOKEN=(oc -n mcp create token mcp-viewer --duration=24h)
PS> $API=(oc whoami --show-server)
PS> oc login --server="$API" --token="$TOKEN" --kubeconfig="$HOME/.kube/mcp-viewer.kubeconfig"
PS> icacls "$HOME\.kube\mcp-viewer.kubeconfig" /inheritance:d
PS> icacls "$HOME\.kube\mcp-viewer.kubeconfig" /inheritance:r
PS> icacls "$HOME\.kube\mcp-viewer.kubeconfig" /grant:r "${env:USERNAME}:(R)"

(3) BobのMCPサーバーの設定
MCPサーバーを定義してjsonファイルを作成します。
mcp.jsonファイルを配置するフォルダーは以下になります。

  1. グローバル設定: /.bob/mcp_settings.jsonの設定はすべてのワークスペースに適用
  2. プロジェクト・レベル設定: .bob/mcp.jsonの設定は現在のプロジェクトにのみ適用
mcp.json
{
  "mcpServers": {
    "kubernetes": {
      "type": "stdio",
      "command": "cmd",
      "args": [
        "/c",
        "npx",
        "-y",
        "kubernetes-mcp-server@latest",
        "--toolsets",
        "core,kubevirt",
        "--kubeconfig",
        "C:\\Users\\<user>\\.kube\\mcp-viewer.kubeconfig"
      ]
    }
  }
}
※<user>は実行環境のユーザー名に置き換えてください。
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?