2
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?

OKEを自然言語で操作してみる

2
Last updated at Posted at 2025-12-10

はじめに

最近 「AWS がフルマネージドな Amazon EKS MCP Server をプレビュー開始」 というニュースを見て、OKE はどうにか自然言語で操作できないか?と思って探してみたところ、 oke-mcp-server というまさにそれっぽいものを見つけたので試してみました。 実際に動かしてみたところ自然言語で OKEの操作(ぽいこと)ができたので、セットアップ手順と動作例をまとめます。

事前準備

■ OKE クラスタを作成

OCI コンソールから OKE クラスタを作成します。
Compartment OCID は後で使うので控えておきます。


■ 作業用インスタンス(Compute)を作成

OKE を操作する VM として利用します。
今回はOKEと同じサブネットに作成しました。
以下の作業を実施します。

必要な作業:


Python 3.10 のインストール

sudo dnf install python3.11

uvのインストール

curl -LsSf https://astral.sh/uv/install.sh | sh

oke-mcp-server のインストール・起動

uvx oke-mcp-server --transport stdio

実行すると以下のように表示されます。

[opc@instance ~]$ uvx oke-mcp-server --transport stdio
2025-12-04 07:10:13,610 INFO oke-mcp-server: Starting OKE MCP Server v0.1.5
2025-12-04 07:10:13,823 INFO oci.circuit_breaker: Default Auth client Circuit breaker strategy enabled


        ╭──────────────────────────────────────────────────────────────────────────────╮         
        │                                                                              │         
        │                         ▄▀▀ ▄▀█ █▀▀ ▀█▀ █▀▄▀█ █▀▀ █▀█                        │         
        │                         █▀  █▀█ ▄▄█  █  █ ▀ █ █▄▄ █▀▀                        │         
        │                                                                              │         
        │                                FastMCP 2.13.2                                │         
        │                                                                              │         
        │                                                                              │         
        │                    🖥  Server name: OKE MCP Server                            │         
        │                                                                              │         
        │                    📦 Transport:   STDIO                                     │         
        │                                                                              │         
        │                    📚 Docs:        https://gofastmcp.com                     │         
        │                    🚀 Hosting:     https://fastmcp.cloud                     │         
        │                                                                              │         
        ╰──────────────────────────────────────────────────────────────────────────────╯         


[12/04/25 07:10:13] INFO     Starting MCP server 'OKE MCP Server' with transport   server.py:1974
                             'stdio'

oke-mcp-server は HTTP ではなく STDIO 専用 です。
Claude Code の MCP 設定は任意の場所(/home/opc/.mcp.json)に以下の内容で記述します。

~/.mcp.json
{
  "mcpServers": {
    "oke": {
      "command": "uvx",
      "args": [
        "oke-mcp-server",
        "--transport",
        "stdio"
      ]
    }
  }
}

MCP で利用できるツール一覧

/mcp list で確認したところ、利用できるツールは以下のものでした。

  • k8s_list
  • k8s_get
  • oke_get_pod_logs
  • oke_list_clusters
  • oke_get_cluster
  • oke_list_node_metrics
  • oke_list_pod_metrics
  • oke_list_events
  • meta_health
  • meta_list_tools
  • config_get_effective_defaults

※ NOTE
基本的に提供されるのは GET と LIST の “読み取り専用” の機能のみ です。
クラスタ削除、apply / patch / create などの 変更系操作は現状提供されていないようです。

実行例(Claude Code 実際のログ)

Compartment Idは指定しないとエラーになりました。

  • OKE クラスタ一覧を取得する
> このコンパートメント(ocid1.compartment.oc1..xxx)で OKE クラスタ一覧を取得してください。

● OKEクラスタ一覧を取得します。

● oke - oke_list_clusters (MCP)(compartment_id: "ocid1.compartment.oc1..xxx")
  ⎿  {
       "items": [
         {
     … +20 lines (ctrl+o to expand)

● 指定されたコンパートメントに以下のOKEクラスタが見つかりました:

  cluster1
  - クラスタID: ocid1.cluster.oc1.ap-tokyo-1.xxx
  - Kubernetesバージョン: v1.34.1
  - ステータス: ACTIVE
  - パブリックエンドポイント: xxx.xxx.xxx.xxx:6443
  - プライベートエンドポイント: 10.0.0.9:6443

■ Kubernetes ノード一覧を取得する

> この OKE クラスタ内の Kubernetes ノード一覧を取得してください。クラスタ OCID: ocid1.cluster.oc1..xxx

● OKEクラスタ内のKubernetesノード一覧を取得します。
  先ほど取得した cluster1 のOCIDを使用します。

● oke - k8s_list (MCP)(cluster_id:
                      "ocid1.cluster.oc1.ap-tokyo-1.xxx",
                      kind: "Node")
  ⎿  {
       "items": [
         {
     … +8 lines (ctrl+o to expand)

● クラスタ内のKubernetesノードが見つかりました:

  ノード一覧:
  - 10.0.10.188

  ノードの詳細情報(ステータス、容量、Kubernetesバージョンなど)を
  取得する場合は、お知らせください。
  • podの一覧を取得する(動いていないものがあると直し方を提示してくれました)
> この OKE クラスタ内の Kubernetes ポッド一覧を取得してください。コンパートメントocid:ocid1.compartment.oc1..xxx 

● OKEクラスタ内のKubernetesポッド一覧を取得します。まず、指定されたコンパートメント内のクラス
  タを確認してから、ポッド一覧を取得します。

● oke - oke_list_clusters (MCP)(compartment_id: "ocid1.compartment.oc1..xxx")
  ⎿  {                             
       "items": [
         {
     … +20 lines (ctrl+o to expand)

● クラスタが見つかりました。次に、このクラスタ内の全ネームスペースのポッド一覧を取得します。

● oke - k8s_list (MCP)(cluster_id: "ocid1.cluster.oc1.ap-tokyo-1.xxx", kind: "Pod")
  ⎿  {                             
       "items": [
         {
     … +47 lines (ctrl+o to expand)

● OKEクラスタ cluster1 内のKubernetesポッド一覧:

  | ポッド名                                | ネームスペース     | 状態      | Ready |
  |-------------------------------------|-------------|---------|-------|
  | nginx                               | default     | Pending | False |
  | coredns-d97645db-v6n5p              | kube-system | Running | True  |
  | csi-oci-node-zzx77                  | kube-system | Running | True  |
  | kube-dns-autoscaler-68958cf77-rxz4h | kube-system | Running | True  |
  | kube-proxy-nnnkx                    | kube-system | Running | True  |
  | proxymux-client-pl55q               | kube-system | Running | True  |
  | vcn-native-ip-cni-5cqtj             | kube-system | Running | True  |

  合計: 7つのポッド
  - default namespace: 1つ (Pending状態)
  - kube-system namespace: 6つ (すべてRunning状態)

  注: nginx ポッドがPending状態です。詳細を確認する場合は、そのポッドの詳細やイベントを調べる
  ことができます。

> おねがいします 

● nginx ポッドの詳細とイベントを確認します。

● oke - k8s_get (MCP)(cluster_id: "ocid1.cluster.oc1.ap-tokyo-1.xxx", kind: "Pod", name: "nginx", namespace:
                     "default")
  ⎿  {                            
       "name": "nginx",
       "namespace": "default",
     … +3 lines (ctrl+o to expand)

● oke - oke_list_events (MCP)(cluster_id: "ocid1.cluster.oc1.ap-tokyo-1.xxx", namespace: "default",
                             field_selector: "involvedObject.name=nginx")
  ⎿  {                             
       "items": [
         {
     … +75 lines (ctrl+o to expand)

● nginx ポッドがPending状態の原因:

  イメージプルに失敗しています。以下がイベントの詳細です:

  イベント一覧:

  | タイプ     | 理由      | メッセージ
                                                      | 発生回数   |
  |---------|---------|----------------------------------------------------------------------
  ------------------------------------------|--------|
  | Normal  | Pulling | Pulling image "nginx"
                                            | 45回    |
  | Warning | Failed  | Failed to pull image "nginx": short name mode is enforcing, but image
   name nginx:latest returns ambiguous list | 45回    |
  | Normal  | BackOff | Back-off pulling image "nginx"
                                            | 1,081回 |
  | Warning | Failed  | Error: ImagePullBackOff
                                            | 1,081回 |

  問題の原因:

  イメージ名が短縮形 nginx
  で指定されているため、コンテナランタイムが曖昧なイメージリストを返し、プルできません。

  解決策:

  完全修飾イメージ名を使用してポッドを再作成する必要があります:

  # 現在のポッドを削除
  kubectl delete pod nginx -n default

  # 完全修飾イメージ名で再作成
  kubectl run nginx --image=docker.io/library/nginx:latest -n default

  または、既存のYAMLファイルがある場合は、image: フィールドを以下のように変更してください:
  - 変更前: image: nginx
  - 変更後: image: docker.io/library/nginx:latest

  この修正により、ポッドは正常にRunning状態になります。

おわりに

今のところあまり実用性はないかもしれませんが、構築・設定は割と楽なのと自然言語でOKEの情報取得できるのはやってみて楽しかったです。OSS?だとmcp-server-kubernetesというものがあり、そちらはcreate, applyなどもできそうなのでいずれ試してみたいと思います。

参考リンク

PyPI(oke-mcp-server)
https://pypi.org/project/oke-mcp-server

mcp-server-kubernetes
https://github.com/Flux159/mcp-server-kubernetes

2
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
2
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?