すべてのプロダクト
Search
ドキュメントセンター

Container Service for Kubernetes:Knative での MCP サーバーのデプロイ

最終更新日:Oct 14, 2026

Knative で Model Context Protocol (MCP) サーバーをホストし、そのサーバーレスアーキテクチャを活用することで、AI サービス向けにオンデマンドオートスケーリングとイベント駆動型処理を実現します。

仕組み

次のワークフローは、Knative の AI アプリケーションが MCP を使用して外部ツールと連携する方法を示しています。

image
  1. リクエストの開始:ユーザーが AI エージェントにコマンドを発行します。エージェントの組み込み MCP クライアントは、標準化されたツール呼び出しリクエストを生成し、サーバーセントイベント (SSE) または HTTP 経由で送信します。

    Knative は、stdio トランスポートプロトコルを使用する MCP サーバーをサポートしていません。
  2. サービスの処理と実行:Knative Service が HTTP リクエストを受信し、MCP サーバーインスタンスにルーティングして、負荷に応じて自動的にスケーリングします。

    独自の MCP サーバーを構築するには、MCP Server SDK または FastMCP をご参照ください。既存の実装については、MCP Server GitHub リポジトリで確認できます。
  3. 結果の応答:MCP サーバーがタスクの結果を AI エージェントに返し、エージェントが最終的な応答をユーザーに送信します。

前提条件

クラスターに Knative をデプロイ済みであること。詳細については、「Knative コンポーネントのデプロイと管理」をご参照ください。

ステップ 1:MCP サーバーのデプロイ

このセクションでは、中国 (杭州) の旅行計画用 MCP サーバーをデプロイします。このサーバーは、旅行計画、フライト検索、ホテル予約、天気予報の機能を、AI エージェントが呼び出せる標準化されたツールとしてパッケージ化しています。

  1. mcp-server.yaml を作成します。

    次の例では、サンプル MCP サーバーイメージをプルする Knative Service を定義します。
    apiVersion: serving.knative.dev/v1
    kind: Service
    metadata:
      name: helloworld-go
      namespace: default
    spec:
      template:
        spec:
          containers:
            - env:
                - name: TARGET
                  value: Knative
              # イメージアドレスの {region} を実際のリージョン ID (例: cn-hangzhou) に置き換えてください
              image: >-
                registry-{region}-vpc.ack.aliyuncs.com/acs/knative-samples-mcp-trip:v1.0-6b9fc59
              name: user-container
  2. Knative Service を作成します。

    kubectl apply -f mcp-server.yaml

ステップ 2:サービスへのアクセス

サービスをデプロイした後、MCP リクエストを送信して、期待どおりに動作することを確認します。

  1. サービス管理 ページで、サービスの ゲートウェイ と デフォルトドメイン を取得します。

    この例では、[ゲートウェイ] は Application Load Balancer (ALB) アドレス (例:alb-xxx.aliyuncsslb.com) です。[helloworld-go] サービスの [デフォルトドメイン] は helloworld-go.default.example.com です。

  2. helloworld-go サービスにアクセスします。

    helloworld-go.default.example.com を実際のドメイン名に、<GATEWAY_IP> を実際のゲートウェイアドレスに置き換えてください。

    このコマンドは、サポートされているすべてのツールを一覧表示するために、サービスに tools/list リクエストを送信します。
    curl -H "Host: helloworld-go.default.example.com" http://<GATEWAY_IP>/mcp -H "Content-Type: application/json" \
      -d '{
        "jsonrpc": "2.0",
        "id": "1",
        "method": "tools/list",
        "params": {}
      }' | jq .

    このコマンドは、MCP サーバーが提供するツールの一覧を含む、フォーマット済みの JSON レスポンスを返します。

    期待される出力

    {
      "jsonrpc": "2.0",
      "id": "1",
      "result": {
        "tools": [
          {
            "annotations": {
              "readOnlyHint": false,
              "destructiveHint": true,
              "idempotentHint": false,
              "openWorldHint": true
            },
            "description": "Book a hotel near West Lake in China (Hangzhou)",
            "inputSchema": {
              "type": "object",
              "properties": {
                "check_in": {
                  "description": "Check-in date (YYYY-MM-DD)",
                  "type": "string"
                },
                "guests": {
                  "description": "Number of guests",
                  "type": "number"
                },
                "nights": {
                  "description": "Number of nights",
                  "type": "number"
                }
              },
              "required": [
                "check_in",
                "guests",
                "nights"
              ]
            },
            "name": "book_hotel"
          },
          {
            "annotations": {
              "readOnlyHint": false,
              "destructiveHint": true,
              "idempotentHint": false,
              "openWorldHint": true
            },
            "description": "Get the weather forecast for the next several days in China (Hangzhou) to prepare for the trip",
            "inputSchema": {
              "type": "object",
              "properties": {
                "date_start": {
                  "description": "Start date (YYYY-MM-DD)",
                  "type": "string"
                },
                "days": {
                  "description": "Number of forecast days",
                  "type": "number"
                }
              },
              "required": [
                "date_start",
                "days"
              ]
            },
            "name": "get_weather_forecast"
          },
          {
            "annotations": {
              "readOnlyHint": false,
              "destructiveHint": true,
              "idempotentHint": false,
              "openWorldHint": true
            },
            "description": "Generate a detailed multi-day travel itinerary for China (Hangzhou), including daily attractions, cuisine, and cultural experiences",
            "inputSchema": {
              "type": "object",
              "properties": {
                "days": {
                  "description": "Number of travel days (1-7)",
                  "maximum": 7,
                  "minimum": 1,
                  "type": "number"
                }
              },
              "required": [
                "days"
              ]
            },
            "name": "plan_hangzhou_trip"
          },
          {
            "annotations": {
              "readOnlyHint": false,
              "destructiveHint": true,
              "idempotentHint": false,
              "openWorldHint": true
            },
            "description": "Search for flight information to China (Hangzhou)",
            "inputSchema": {
              "type": "object",
              "properties": {
                "date": {
                  "description": "Departure date (YYYY-MM-DD)",
                  "type": "string"
                },
                "origin": {
                  "description": "Departure city (for example, Beijing, Shanghai)",
                  "type": "string"
                }
              },
              "required": [
                "origin",
                "date"
              ]
            },
            "name": "search_flights"
          }
        ]
      }
    }

課金

Knative アドオン自体に追加料金は発生しません。ただし、各クラウド製品では、消費するコンピューティングリソース、ネットワークリソース、その他のリソースに対して課金されます。詳細については「クラウドリソースコスト」をご参照ください。