For the complete documentation index, see llms.txt. Markdown versions of all docs pages are available by appending .md to any docs URL.
OpenAPI
Expose REST APIs as MCP tools by using an OpenAPI schema.
Expose REST APIs as Model Context Protocol (MCP) tools so that AI agents can interact with your existing APIs without a custom MCP server. You provide an OpenAPI 3.0 JSON schema in a ConfigMap, and the gateway converts each API operation into an MCP tool.
Before you begin
Step 1: Deploy a sample REST API server
Deploy a sample REST API server that the gateway proxies requests to. These steps use a Petstore sample app as an example.
Deploy the Petstore app.
kubectl apply -f- <<EOF apiVersion: apps/v1 kind: Deployment metadata: name: petstore namespace: default spec: replicas: 1 selector: matchLabels: app: petstore template: metadata: labels: app: petstore spec: containers: - name: petstore image: soloio/petstore-example:latest ports: - containerPort: 8080 --- apiVersion: v1 kind: Service metadata: name: petstore namespace: default spec: selector: app: petstore ports: - port: 8080 targetPort: 8080 EOFVerify that the Petstore pod is ready.
kubectl wait --for=condition=available deployment/petstore --timeout=60s
Step 2: Create a ConfigMap with the OpenAPI schema
Store the OpenAPI 3.0 JSON schema for your REST API in a ConfigMap. The gateway reads the schema from the data.schema key.
Note
In the OpenAPI schema, set the server URL to / so that the gateway correctly concatenates the request path. If no URL is set, extra slashes can break requests.
kubectl apply -f- <<EOF
apiVersion: v1
kind: ConfigMap
metadata:
name: petstore-schema
namespace: default
data:
schema: |
{
"openapi": "3.0.0",
"info": {
"title": "Swagger Petstore",
"version": "1.0.0"
},
"servers": [
{
"url": "/"
}
],
"paths": {
"/api/pets": {
"get": {
"operationId": "findPets",
"summary": "Returns all pets from the system",
"parameters": [
{
"name": "limit",
"in": "query",
"description": "Maximum number of results to return",
"required": false,
"schema": { "type": "integer" }
}
],
"responses": {
"200": {
"description": "A list of pets"
}
}
},
"post": {
"operationId": "addPet",
"summary": "Creates a new pet in the store",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"id": { "type": "integer" },
"name": { "type": "string" },
"tag": { "type": "string" }
},
"required": ["name"]
}
}
}
},
"responses": {
"200": {
"description": "Pet created successfully"
}
}
}
},
"/api/pets/{id}": {
"get": {
"operationId": "findPetById",
"summary": "Find pet by ID",
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": { "type": "integer" }
}
],
"responses": {
"200": {
"description": "Pet details"
}
}
},
"delete": {
"operationId": "deletePet",
"summary": "Delete a pet",
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": { "type": "integer" }
}
],
"responses": {
"204": {
"description": "Pet deleted"
}
}
}
}
}
}
EOFSuccess
You can also create the ConfigMap from a file:
kubectl create configmap petstore-schema --from-file=schema=openapi.jsonStep 3: Create the OpenAPI backend
Create an EnterpriseAgentgatewayBackend with the entMcp backend type. Set the protocol to OpenAPI and reference the ConfigMap that contains the OpenAPI schema.
kubectl apply -f- <<EOF
apiVersion: enterpriseagentgateway.solo.io/v1alpha1
kind: EnterpriseAgentgatewayBackend
metadata:
name: petstore-openapi
namespace: default
spec:
entMcp:
targets:
- name: petstore
static:
host: petstore.default.svc.cluster.local
port: 8080
protocol: OpenAPI
openAPI:
schemaRef:
name: petstore-schema
EOFReview the following table to understand this configuration.
| Setting | Description |
|---|---|
entMcp | The enterprise MCP backend type, which supports OpenAPI, Streamable HTTP, and SSE protocols. |
targets[].static.protocol | The protocol for connecting to the target. Set to OpenAPI to expose REST API endpoints as MCP tools. Other options are StreamableHTTP and SSE. |
targets[].static.openAPI.schemaRef.name | The name of the ConfigMap that contains the OpenAPI 3.0 JSON schema. The ConfigMap must have a data.schema key. |
targets[].static.host | The hostname of the REST API server. For in-cluster services, use the format <service>.<namespace>.svc.cluster.local. |
Step 4: Create an HTTPRoute
Create an HTTPRoute to expose the OpenAPI backend through the gateway.
kubectl apply -f- <<EOF apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: name: openapi-mcp namespace: default spec: parentRefs: - name: agentgateway-proxy namespace: agentgateway-system rules: - matches: - path: type: PathPrefix value: /mcp backendRefs: - name: petstore-openapi group: enterpriseagentgateway.solo.io kind: EnterpriseAgentgatewayBackend EOFVerify that the HTTPRoute is accepted.
kubectl get httproute openapi-mcp -o jsonpath='{.status.parents[0].conditions[?(@.type=="Accepted")].status}'Example output:
True
Step 5: Verify the OpenAPI tools
Send an MCP initialize request to the gateway to start a session, then list the available tools.
Port-forward the gateway service.
kubectl port-forward -n agentgateway-system svc/agentgateway-proxy 8080:80In a separate terminal, initialize an MCP session.
curl -sD - "http://localhost:8080/mcp" \ -H "Content-Type: application/json" \ -H "Accept: application/json, text/event-stream" \ -d '{ "jsonrpc": "2.0", "id": 1, "method": "initialize", "params": { "protocolVersion": "2025-03-26", "capabilities": {}, "clientInfo": {"name": "test", "version": "1.0"} } }'In the response headers, note the
mcp-session-idvalue. You need this session ID for subsequent requests.Example output:
... mcp-session-id: eyJ0Ijoib... ... data: {"jsonrpc":"2.0","id":1,"result":{"protocolVersion":"2025-06-18","capabilities":{"tools":{}},"serverInfo":{"name":"rmcp","version":"1.3.0"}}}List the MCP tools. Replace
<session-id>with the session ID from the previous response.curl -s "http://localhost:8080/mcp" \ -H "Content-Type: application/json" \ -H "Accept: application/json, text/event-stream" \ -H "Mcp-Session-Id: <session-id>" \ -d '{"jsonrpc": "2.0", "id": 2, "method": "tools/list", "params": {}}'Verify that the Petstore API operations appear as MCP tools.
Example output (truncated):
data: {"jsonrpc":"2.0","id":2,"result":{"tools":[{"name":"findPets","description":"Returns all pets from the system",...},{"name":"addPet","description":"Creates a new pet in the store",...},{"name":"findPetById","description":"Find pet by ID",...},{"name":"deletePet","description":"Delete a pet",...}]}}
Cleanup
Remove the resources that you created in this guide.
kubectl delete httproute openapi-mcp
kubectl delete enterpriseagentgatewaypolicy cors -n agentgateway-system --ignore-not-found
kubectl delete enterpriseagentgatewaybackend petstore-openapi
kubectl delete configmap petstore-schema
kubectl delete deployment petstore
kubectl delete svc petstoreNext
- Control access to MCP tools with authorization policies.
- Set up HTTPS for your MCP backends.
- Add rate limiting to protect your MCP services.
More resources
Check out how to use code mode to expose your existing OAS-compatible APIs as an MCP.