Hosting the Model Context Protocol (MCP) server in Knative allows you to use serverless advantages, such as on-demand auto-scaling and event-driven processing for AI workloads.
How it works
The following workflow outlines how an AI application running on Knative interacts with external tools via the MCP protocol.
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 using the Server-Sent Events (SSE) or HTTP protocol.
Knative does not support MCP servers that use the
stdiotransport protocol.Request handling and execution: The Knative Service receives the HTTP request, routes it to an available MCP server instance, and automatically scales based on the load.
To develop your own MCP server, see the MCP Server SDK or FastMCP. For existing implementations, see the MCP Server GitHub repository.
Result response: The MCP server returns the task result to the AI agent, which then forwards the final response to the user.
Prerequisites
Knative is deployed in the cluster. For more information, see Deploy and manage Knative.
Step 1: Deploy the MCP server
This section deploys a sample MCP server for Hangzhou trip planning. The server packages functions for trip planning, flight booking, hotel reservation, and weather forecasting into standardized tools for an AI agent.
Create a file named
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 path with the actual region, such as cn-hangzhou. image: >- registry-{region}-vpc.ack.aliyuncs.com/acs/knative-samples-mcp-trip:v1.0-6b9fc59 name: user-containerCreate the Knative Service.
kubectl apply -f mcp-server.yaml
Step 2: Access the server
After deploying the server, send an MCP request to verify that it is working correctly.
Log on to the ACK console. In the left navigation pane, click Clusters.
On the Clusters page, find the cluster you want and click its name. In the left navigation pane, choose .
Click the Services tab, obtain the Gateway and Default Domain of the Knative Service.

Access the
helloworld-goService.Replace
helloworld-go.default.example.comwith your domain name. Replace<GATEWAY_IP>with your gateway IP address.This command sends a
tools/listrequest to the Service to retrieve the list of 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 expected output is a formatted JSON response that contains the list of tools provided by the MCP server.
Billing
There is no additional cost for Knative itself. However, you are responsible for the costs of any underlying cloud resources that are provisioned while using Knative, such as compute resources (Elastic Compute Service instances) and network resources (Application Load Balancer). These resources are billed separately by each respective cloud service. For detailed pricing information, see Cloud resource fee.