|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// *mcp_gateway_install/mcp-gateway-install.adoc |
| 4 | + |
| 5 | +:_mod-docs-content-type: PROCEDURE |
| 6 | +[id="proc-config-mcp-gateway-listener_{context}"] |
| 7 | += Configuring MCP gateway listeners |
| 8 | + |
| 9 | +[role="_abstract"] |
| 10 | +Connect your MCP gateway to your agentic AI systems by appending your `Gateway` custom resource (CR) with your MCP listener information. The MCP listener handles the transport protocol, opens an MCP session on the port, and establishes a security perimeter. You can also add listeners for unencrypted web traffic and secured traffic. |
| 11 | + |
| 12 | +.Prerequisites |
| 13 | + |
| 14 | +* You are logged in to your {ocp} cluster. |
| 15 | +* You created a gateway custom resource (CR). |
| 16 | +* You installed {mcpg}. |
| 17 | +* You configured a gateway API provider. |
| 18 | +* Optional. If you are adding a secure listener, you have a TLS certificate to reference. The certificate must be in the same namespace as the `Gateway` CR. |
| 19 | +
|
| 20 | +.Procedure |
| 21 | + |
| 22 | +. Add an MCP gateway listener to your `Gateway` CR by appending it with the following command: |
| 23 | ++ |
| 24 | +[source,terminal,subs="+quotes"] |
| 25 | +---- |
| 26 | +$ $ oc patch gateway _<mcp_gateway>_ -n _<gateway_namespace>_ --type='json' -p='[ |
| 27 | + { |
| 28 | + "op": "add", |
| 29 | + "path": "/spec/listeners/-", |
| 30 | + "value": { |
| 31 | + "name": "mcps", |
| 32 | + "hostname": "_<mcp.example.com>_", |
| 33 | + "port": 8080, |
| 34 | + "protocol": "HTTP", |
| 35 | + "allowedRoutes": { |
| 36 | + "namespaces": { |
| 37 | + "from": "All" |
| 38 | + } |
| 39 | + } |
| 40 | + } |
| 41 | + } |
| 42 | +]' |
| 43 | +---- |
| 44 | ++ |
| 45 | +* Replace `_<mcp_gateway>_` with the name of your MCP gateway. |
| 46 | +* Replace `_<gateway_namespace>_` with the namespace where your `Gateway` object is applied. |
| 47 | +* Replace `_<mcp.example.com>_` with the hostname you want to use. |
| 48 | +
|
| 49 | +. Verify that your listener is working by running the following command: |
| 50 | ++ |
| 51 | +[source,terminal,subs="+quotes"] |
| 52 | +---- |
| 53 | +$ oc get gateway _<mcp_gateway>_ -n _<gateway_namespace>_ -o yaml |
| 54 | +---- |
| 55 | ++ |
| 56 | +* Replace `_<mcp_gateway>_` with the name of your MCP gateway deployment. |
| 57 | +* Replace `_<gateway_namespace>_` with the namespace where your `Gateway` object is applied. |
| 58 | +* The conditions `Accepted: True` and `Programmed: True` are expected in the `status` of the output. |
| 59 | +
|
| 60 | +. Add a standard web traffic listener to your `Gateway` CR by appending it with the following command: |
| 61 | ++ |
| 62 | +[source,terminal,subs="+quotes"] |
| 63 | +---- |
| 64 | +$ oc patch gateway _<mcp_gateway>_ -n _<gateway_namespace>_ --type='json' -p='[ |
| 65 | + { |
| 66 | + "op": "add", |
| 67 | + "path": "/spec/listeners/-", |
| 68 | + "value": { |
| 69 | + "name": "http-web", |
| 70 | + "port": 80, |
| 71 | + "protocol": "HTTP", |
| 72 | + "allowedRoutes": { |
| 73 | + "namespaces": { |
| 74 | + "from": "All" |
| 75 | + } |
| 76 | + } |
| 77 | + } |
| 78 | + } |
| 79 | +]' |
| 80 | +---- |
| 81 | ++ |
| 82 | +* Replace `_<mcp_gateway>_` with the name of your MCP gateway. |
| 83 | +* Replace `_<gateway_namespace>_` with the namespace where your `Gateway` object is applied. |
| 84 | +* The `listener.name` value must be a unique name within the `Gateway` object. In this example, `http-web` is used. |
| 85 | +* The `listener.port: 80,` is the standard port for unencrypted web traffic. |
| 86 | +* You can add a `hostname` if you want to limit incoming domain names. |
| 87 | +
|
| 88 | +. Add a secure listener to your `Gateway` CR by appending it with the following command: |
| 89 | ++ |
| 90 | +[source,terminal,subs="+quotes"] |
| 91 | +---- |
| 92 | +$ oc patch gateway _<mcp_gateway>_ -n _<gateway_namespace>_ --type='json' -p='[ |
| 93 | + { |
| 94 | + "op": "add", |
| 95 | + "path": "/spec/listeners/-", |
| 96 | + "value": { |
| 97 | + "name": "https", |
| 98 | + "hostname": "_<mcp.example.com>_", |
| 99 | + "port": 443, |
| 100 | + "protocol": "HTTPS", |
| 101 | + "tls": { |
| 102 | + "mode": "Terminate", |
| 103 | + "certificateRefs": [ |
| 104 | + { |
| 105 | + "name": "mcp-tls-secret", |
| 106 | + "kind": "Secret" |
| 107 | + } |
| 108 | + ] |
| 109 | + }, |
| 110 | + "allowedRoutes": { |
| 111 | + "namespaces": { |
| 112 | + "from": "All" |
| 113 | + } |
| 114 | + } |
| 115 | + } |
| 116 | + } |
| 117 | +]' |
| 118 | +---- |
| 119 | ++ |
| 120 | +* Replace `_<mcp_gateway>_` with the name of your MCP gateway deployment. |
| 121 | +* Replace `_<gateway_namespace>_` with the namespace where your `Gateway` object is applied. |
| 122 | +* Replace `_<mcp.example.com>_` with the hostname you are targeting. |
| 123 | +* The `spec.listeners.tls.certificateRefs.name:` parameter specifies the name of your secret. This example uses `mcp-tls-secret`. |
| 124 | +* The `spec.listeners.tls.mode: Terminate` value means that the gateway decrypts the traffic and sends it as plain text to your MCP server. You can specify the mode that you require. |
| 125 | +* You must set a `spec.listeners.hostname` so that the relevant certificate is presented to the correct client. |
| 126 | +
|
| 127 | +. Check that your certificates are properly linked by running the following command: |
| 128 | ++ |
| 129 | +[source,terminal,subs="+quotes"] |
| 130 | +---- |
| 131 | +$ oc get gateway _<mcp_gateway>_ -n _<gateway_namespace>_ -o jsonpath='{.status.listeners[?(@.name=="https")]}' |
| 132 | +---- |
| 133 | ++ |
| 134 | +* Replace `_<mcp_gateway>_` with the name of your MCP gateway deployment. |
| 135 | +* Replace `_<gateway_namespace>_` with the namespace where your `Gateway` object is applied. |
| 136 | +* The `status` message outputs any errors. |
| 137 | +
|
| 138 | +.Verification |
| 139 | + |
| 140 | +. Check the status your listeners and related objects by running the following command: |
| 141 | ++ |
| 142 | +[source,terminal,subs="+quotes"] |
| 143 | +---- |
| 144 | +$ oc describe gateway _<mcp_gateway>_ -n _<gateway_namespace>_ |
| 145 | +---- |
| 146 | ++ |
| 147 | +* Replace `_<mcp_gateway>_` with the name of your MCP gateway deployment. |
| 148 | +* Replace `_<gateway_namespace>_` with the namespace where your `Gateway` object is applied. |
| 149 | ++ |
| 150 | +.Example output |
| 151 | +[source,yaml] |
| 152 | +---- |
| 153 | +# ... |
| 154 | +Status: |
| 155 | + Listeners: |
| 156 | + - Name: http-web |
| 157 | + Supported Kinds: |
| 158 | + Group: gateway.networking.k8s.io |
| 159 | + Kind: HTTPRoute |
| 160 | + Conditions: |
| 161 | + Last Transition Time: 2026-04-01T... |
| 162 | + Message: None |
| 163 | + Reason: Programmed |
| 164 | + Status: True |
| 165 | + Type: Programmed |
| 166 | + - Name: https |
| 167 | + Conditions: |
| 168 | + Reason: ResolvedRefs |
| 169 | + Status: True |
| 170 | + Type: ResolvedRefs |
| 171 | +# ... |
| 172 | +Events: |
| 173 | + Type Reason Age From Message |
| 174 | + Normal Synced 12m gateway-api-controller Successfully synced Gateway configuration |
| 175 | + Normal IPAllocated 11m mcp-operator Assigned IP 192.168.1.100 to Gateway |
| 176 | + Normal ListenerAccepted 10m gateway-api-controller Listener "http-web" accepted |
| 177 | + Normal Programmed 10m gateway-api-controller Gateway has been successfully programmed |
| 178 | +# ... |
| 179 | +---- |
| 180 | ++ |
| 181 | +* The `Events` section of the output can also show port conflicts, problems with your `gatewayClassName:` value, missing routes, and a lack of permissions to read secrets. |
0 commit comments