Hosting an MCP Server in Knative allows you to use its serverless architecture for on-demand autoscaling and event-driven processing for AI services.
How it works
This workflow shows how an AI application in Knative uses the MCP protocol to interact with external tools.
-
Request initiation: A user issues a command to an AI agent. The agent's built-in MCP client generates a standard tool-calling request and sends it over SSE or HTTP.
Knative does not support MCP Servers that use the stdio transport protocol.
-
Service 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 build your own MCP Server, see the MCP Server SDK or FastMCP. You can also find existing implementations in the MCP Server GitHub repository.
-
Result response: The MCP Server returns the 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 will deploy a sample MCP service for trip planning in China (Hangzhou). The service packages trip planning, flight search, hotel booking, and weather forecasting functions into standardized tools that an AI agent can call.
-
Create a file named
mcp-server.yaml.The following YAML 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 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 -
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.
-
On the Services page, obtain the Gateway and Default Domain of the service.
The Gateway is an ALB address, such as
alb-xxx.aliyuncsslb.com. The Default Domain for the helloworld-go service ishelloworld-go.default.example.com. -
Access the
helloworld-goservice.Replace
helloworld-go.default.example.comwith your actual domain name and<GATEWAY_IP>with your actual gateway IP address.This command sends a
tools/listrequest 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 containing the list of tools from the MCP Server.
Billing
Knative itself does not incur additional charges. However, you are billed for the cloud services that you use, such as computing and network resources. For more information, see Cloud service costs and .