All Products
Search
Document Center

Container Service for Kubernetes:Deploy an MCP Server in Knative

Last Updated:Oct 13, 2026

Host a Model Context Protocol (MCP) Server in Knative to use its serverless architecture, which provides on-demand autoscaling and event-driven processing for AI services.

How it works

The following workflow shows how an AI application in Knative uses MCP to interact with external tools.

image
  1. Request initiation: A user issues a command to an AI agent. The agent's built-in MCP client generates a standardized tool-calling request and sends it over Server-Sent Events (SSE) or HTTP.

    Knative does not support MCP Servers that use the stdio transport protocol.
  2. Service handling and execution: The Knative Service receives the HTTP request, routes it to an MCP Server instance, and scales automatically based on the load.

    To build your own MCP Server, see the MCP Server SDK or FastMCP. You can also find existing implementations in the MCP Server GitHub repository.
  3. Result response: The MCP Server returns the task result to the AI agent, which then sends the final response to the user.

Prerequisites

You have deployed Knative in the cluster. For more information, see Deploy and manage Knative components.

Step 1: Deploy the MCP Server

In this section, you deploy an MCP Server for trip planning in China (Hangzhou). The server packages trip planning, flight search, hotel booking, and weather forecasting capabilities into standardized tools that AI agents can call.

  1. Create mcp-server.yaml.

    The following example defines a Knative Service that pulls the sample MCP Server image.
    apiVersion: serving.knative.dev/v1
    kind: Service
    metadata:
      name: helloworld-go
      namespace: default
    spec:
      template:
        spec:
          containers:
            - env:
                - name: TARGET
                  value: Knative
              # Replace {region} in the image address with your actual region ID, such as cn-hangzhou
              image: >-
                registry-{region}-vpc.ack.aliyuncs.com/acs/knative-samples-mcp-trip:v1.0-6b9fc59
              name: user-container
  2. Create the Knative Service.

    kubectl apply -f mcp-server.yaml

Step 2: Access the service

After you deploy the service, send an MCP request to verify that it works as expected.

  1. On the Services page, get the Gateway and Default Domain of the service.

    In this example, the Gateway is an Application Load Balancer (ALB) address, such as alb-xxx.aliyuncsslb.com. The helloworld-go service's Default Domain is helloworld-go.default.example.com.

  2. Access the helloworld-go service.

    Replace helloworld-go.default.example.com with your actual domain name, and <GATEWAY_IP> with your actual gateway address.

    This command sends a tools/list request to the service to list all supported tools.
    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 .

    The command returns a formatted JSON response that contains the list of tools provided by the MCP Server.

    Expected output

    {
      "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"
          }
        ]
      }
    }

Billing

The Knative add-on itself does not incur additional charges. However, each cloud product charges for the compute resources, network resources, and other resources that you consume. For more information, see Cloud resource costs.