Connect via HTTPS
Configure agentgateway to connect to an MCP server over HTTPS for encrypted transport.
Configure your agentgateway proxy to connect to an MCP server by using the HTTPS protocol.
About this guide
In this guide, you configure your agentgateway proxy to connect to the remote GitHub MCP server by using the HTTPS protocol. The server allows you to interact with GitHub repositories, issues, pull requests, and more. All connections to the server must be secured via HTTPS and a GitHub access token must be provided for authentication.
Before you begin
Follow the Get started guide to install agentgateway.
Follow the Sample app guide to create a gateway proxy with an HTTP listener and deploy the httpbin sample app.
Get the external address of the gateway and save it in an environment variable.
Tip
Kind cluster? Kind does not support
LoadBalancerservices by default. To use this option with a Kind cluster, install and runcloud-provider-kind.export INGRESS_GW_ADDRESS=$(kubectl get svc -n agentgateway-system agentgateway-proxy -o jsonpath="{.status.loadBalancer.ingress[0]['hostname','ip']}") echo $INGRESS_GW_ADDRESS
Connect to the MCP server
Create a personal access token in GitHub and save it in an environment variable. For more information, see the GitHub docs.
export GH_PAT=<personal-access-token>Create the AgentgatewayBackend for the remote GitHub MCP server. The server requires you to connect to it by using the HTTPS protocol. Because of that, you set the
mcp.targets.static.portfield to 443.kubectl apply -f- <<EOF apiVersion: agentgateway.dev/v1alpha1 kind: AgentgatewayBackend metadata: name: github-mcp-backend namespace: agentgateway-system spec: mcp: targets: - name: mcp-target static: host: api.githubcopilot.com port: 443 path: /mcp/ policies: tls: sni: api.githubcopilot.com EOFCreate an HTTPRoute that routes traffic to the GitHub MCP server along the
/mcp-githubpath. To properly connect to the MCP server, you must allow traffic fromhttp://localhost:8080, which is the domain and port you expose your agentgateway proxy on later. If you expose the proxy under a different domain, make sure to add this domain to the allowed origins. Because the MCP server also requires a GitHub access token to connect, you set theAuthorizationheader to the token that you created earlier.kubectl apply -f- <<EOF apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: name: mcp-github namespace: agentgateway-system spec: parentRefs: - name: agentgateway-proxy namespace: agentgateway-system rules: - matches: - path: type: PathPrefix value: /mcp-github filters: - type: CORS cors: allowHeaders: - "*" allowMethods: - "*" allowOrigins: - "http://localhost:8080" - type: RequestHeaderModifier requestHeaderModifier: set: - name: Authorization value: "Bearer ${GH_PAT}" backendRefs: - name: github-mcp-backend group: agentgateway.dev kind: AgentgatewayBackend EOF
Verify the connection
Use the MCP Inspector tool to verify that you can connect to your sample MCP server through agentgateway.
Get the agentgateway address.
export INGRESS_GW_ADDRESS=$(kubectl get gateway agentgateway-proxy -n agentgateway-system -o=jsonpath="{.status.addresses[0].value}") echo $INGRESS_GW_ADDRESSFrom your terminal, run the MCP Inspector. The MCP Inspector opens in your browser. If the browser does not open, open the URL that the command prints, including the
MCP_INSPECTOR_API_TOKENquery parameter. The MCP Inspector requires Node.js 22.23.4 or a later 22.x release, 24.22.1 or a later 24.x release, or 26.12.1 or later. To check your version, runnode -v.npx @modelcontextprotocol/inspector@2.17.0Add your agentgateway address as a server, and connect to it.
- Click Add Servers > + Add manually.
- Enter the following details, and click Add.
- Server ID: Enter a name for the server, such as
agentgateway. - Transport: Select
streamable-http. - URL: Enter the agentgateway address, port, and the
/mcp-githubpath. If your agentgateway proxy is exposed with a LoadBalancer server, usehttp://<lb-address>/mcp-github. In local test setups where you port-forwarded the agentgateway proxy on your local machine, usehttp://localhost:8080/mcp-github.
- Server ID: Enter a name for the server, such as
- On the
agentgatewayserver card, click the toggle. Verify that the card shows Connected.
From the menu bar, click Tools. From the list of tools, select the
get_metool.Click Execute Tool.
Verify that the Results pane shows information about your GitHub user.


Cleanup
You can remove the resources that you created in this guide.kubectl delete AgentgatewayBackend github-mcp-backend -n agentgateway-system
kubectl delete HTTPRoute mcp-github -n agentgateway-system