Secure External MCP Gateway

Minimum Version
AI Gateway - 2.0
Incompatible with
on-prem

Overview

Put Kong AI Gateway in front of third-party MCP servers, so that you identify each caller, control which tools they can call, and keep shared upstream credentials out of client configuration. You’ll set up:

  • A GitHub MCP endpoint that identifies each caller with an AI Consumer key and limits developers to read-only GitHub tools
  • A Konnect MCP endpoint that authenticates users through Okta or Keycloak and calls Konnect with a stored credential
  • One place for MCP access rules and MCP traffic logs

For MCP servers that your own teams build, see the Secure Internal MCP Gateway cookbook.

Prerequisites

This tutorial uses Kong Konnect. The AI Gateway quickstart script provisions a recipe-scoped AI Gateway and local data plane.

  1. Create a new personal access token by opening the Konnect PAT page and selecting Generate Token.
  2. Export your token. You reuse the same token later for kongctl commands:

    export KONNECT_TOKEN='YOUR_KONNECT_PAT'
  3. Set the recipe-scoped AI Gateway name and run the quickstart script:

    export KONNECT_CONTROL_PLANE_NAME='secure-external-mcp-gateway-recipe'
    curl -Ls https://get.konghq.com/ai | bash -s -- -k $KONNECT_TOKEN

    This provisions an AI Gateway named secure-external-mcp-gateway-recipe, a local data plane connected to it, and prints export lines for the rest of the session vars, including AI_GATEWAY_ID. Paste those into your shell when prompted.

This tutorial uses kongctl to manage AI Gateway configuration.

  1. Install kongctl from the kongctl documentation.
  2. Verify it’s installed:

    kongctl version

The GitHub MCP server uses GitHub’s OAuth. GitHub doesn’t support Dynamic Client Registration, so you register an OAuth App for your MCP client (GitHub: Creating an OAuth app).

  1. On GitHub, click your profile picture, then Settings > Developer settings > OAuth Apps, and click New OAuth App.
  2. Set Application name to Kong MCP Client.
  3. Set Homepage URL to https://localhost:8443.
  4. Set Authorization callback URL to https://app.insomnia.rest/oauth/redirect, Insomnia’s default OAuth redirect URL.
  5. Click Register application.
  6. Click Generate a new client secret.
  7. Copy the Client ID and the client secret. You enter both in Insomnia in Connect Insomnia to GitHub MCP.

GitHub requires the client secret when it exchanges the authorization code for a token, also when the client uses PKCE (GitHub: Authorizing OAuth apps). An MCP client that sends only the Client ID fails at the token exchange.

The Konnect MCP route authenticates users against your identity provider (IdP) with token introspection. This cookbook covers Okta and Keycloak. Each setup creates two applications: a confidential client that Kong uses to call the introspection endpoint, and a public client for the MCP client.

Kong calls the Konnect MCP server with a stored Konnect credential. The server accepts a personal access token or a system account access token.

  1. Export the server URL:

    export KONNECT_MCP_HOST='https://global.mcp.konghq.com'
  2. Export the credential as the complete header that Kong adds to each request. This cookbook reuses your personal access token:

    export KONNECT_MCP_TOKEN="Authorization:Bearer ${KONNECT_TOKEN}"

A personal access token has the permissions of the user who created it. In production, use a system account access token with only the permissions the MCP tools need.

This tutorial uses Insomnia as the MCP client. Insomnia connects to MCP servers and runs the OAuth flow that MCP servers advertise (MCP clients in Insomnia).

Install the latest version of Insomnia from insomnia.rest/download.

What this cookbook solves

Most teams connect AI agents directly to third-party MCP servers, each with its own tokens and its own tool catalog, which causes the following problems:

Problem

Solution

Third-party MCP servers often issue opaque tokens. A gateway can’t read a user or a group from them, so it can’t apply access rules. A Key Auth AI Auth Strategy identifies the caller with an AI Consumer key, next to the GitHub token. The AI Consumer’s group decides which tools the caller can use.
Each agent gets every tool that the upstream token allows. A developer’s agent can merge pull requests as easily as it can search code. Tool ACLs on the AI MCP Server limit the developer AI Consumer Group to read-only GitHub tools. Kong removes the other tools from tools/list and rejects calls to them.
Each developer manages their own token for each MCP server, so there’s no central place to revoke access or rotate a shared credential. For Konnect MCP, users sign in with your IdP. An OpenID Connect AI Auth Strategy validates their token, and a Request Transformer Advanced Policy replaces it with one stored Konnect credential.
Agents call MCP servers directly, so there’s no record of which tools people call. Both AI MCP Servers log payloads and ACL decisions, and their traffic shows in Konnect analytics.

Try it out

Apply the configuration, connect Insomnia to both MCP endpoints, then compare the GitHub tools that a developer and an admin get and call a Konnect MCP tool through the token swap.

Apply the Kong configuration

The configuration creates a Key Auth AI Auth Strategy, two AI Consumers with demo API keys, two AI Consumer Groups (secure-external-mcp-gateway-admin and secure-external-mcp-gateway-developer), an OpenID Connect AI Auth Strategy for your IdP, a Request Transformer Advanced Policy, and two AI MCP Servers: one for GitHub MCP and one for Konnect MCP. A kongctl namespace scopes every resource, so you can remove this configuration without affecting anything else on the same AI Gateway. See the kongctl documentation for more on namespaces.

Adopt the quickstart AI Gateway into a kongctl namespace so that kongctl can manage it. Adoption adds the KONGCTL-namespace label to the AI Gateway:

kongctl adopt ai-gateway "${KONNECT_CONTROL_PLANE_NAME}" \
  --namespace "${KONNECT_CONTROL_PLANE_NAME}" \
  --pat "${KONNECT_TOKEN}"

Export the demo API keys of the admin and developer AI Consumers. The credential’s api_key field is write-only, so its value must come from an environment variable, even for a fixed demo key:

export ADMIN_API_KEY='admin-api-key'
export DEV_API_KEY='dev-api-key'

The IdP values and the Konnect MCP values come from the prerequisites. The same configuration works with Okta and Keycloak. Apply the Kong configuration:

cat <<'EOF' > kong-recipe.yaml
_defaults:
  kongctl:
    namespace: secure-external-mcp-gateway-recipe
ai_gateway_auth_strategies:
- ref: secure-external-mcp-gateway-github-key-auth
  ai_gateway: !lookup {id: !env 'AI_GATEWAY_ID'}
  name: secure-external-mcp-gateway-github-key-auth
  display_name: secure-external-mcp-gateway GitHub key auth
  type: key-auth
  config:
    key_names:
    - apikey
    hide_credentials: true
- ref: secure-external-mcp-gateway-konnect-oauth
  ai_gateway: !lookup {id: !env 'AI_GATEWAY_ID'}
  name: secure-external-mcp-gateway-konnect-oauth
  display_name: secure-external-mcp-gateway Konnect OAuth2
  type: openid-connect
  config:
    issuer: !env 'OAUTH_AUTH_SERVER'
    introspection_endpoint: !env 'OAUTH_INTROSPECTION_URL'
    client_id:
    - !env 'OAUTH_CLIENT_ID'
    client_secret:
    - !secret {source: !env 'OAUTH_CLIENT_SECRET'}
    auth_methods:
    - introspection
    cache_introspection: true
    cache_tokens_salt: secure-external-mcp-gateway-oidc-cache
    ssl_verify: true
    hide_credentials: true
    consumer_optional: true
    consumer_groups_claim:
    - groups
    consumer_groups_optional: true
    credential_claim:
    - sub
ai_gateway_consumers:
- ref: secure-external-mcp-gateway-admin-user
  ai_gateway: !lookup {id: !env 'AI_GATEWAY_ID'}
  name: secure-external-mcp-gateway-admin-user
  display_name: secure-external-mcp-gateway admin user
  type: api-key
  credentials:
  - ref: secure-external-mcp-gateway-admin-credential
    name: secure-external-mcp-gateway-admin-credential
    display_name: secure-external-mcp-gateway admin API key
    type: api-key
    api_key: !secret {source: !env 'ADMIN_API_KEY'}
- ref: secure-external-mcp-gateway-dev-user
  ai_gateway: !lookup {id: !env 'AI_GATEWAY_ID'}
  name: secure-external-mcp-gateway-dev-user
  display_name: secure-external-mcp-gateway developer user
  type: api-key
  credentials:
  - ref: secure-external-mcp-gateway-dev-credential
    name: secure-external-mcp-gateway-dev-credential
    display_name: secure-external-mcp-gateway developer API key
    type: api-key
    api_key: !secret {source: !env 'DEV_API_KEY'}
ai_gateway_consumer_groups:
- ref: secure-external-mcp-gateway-admin
  ai_gateway: !lookup {id: !env 'AI_GATEWAY_ID'}
  name: secure-external-mcp-gateway-admin
  display_name: secure-external-mcp-gateway admin group
  consumers:
  - secure-external-mcp-gateway-admin-user
- ref: secure-external-mcp-gateway-developer
  ai_gateway: !lookup {id: !env 'AI_GATEWAY_ID'}
  name: secure-external-mcp-gateway-developer
  display_name: secure-external-mcp-gateway developer group
  consumers:
  - secure-external-mcp-gateway-dev-user
ai_gateway_policies:
- ref: secure-external-mcp-gateway-konnect-token-swap
  ai_gateway: !lookup {id: !env 'AI_GATEWAY_ID'}
  name: secure-external-mcp-gateway-konnect-token-swap
  display_name: secure-external-mcp-gateway Konnect token swap
  type: request-transformer-advanced
  config:
    add:
      headers:
      - !env 'KONNECT_MCP_TOKEN'
ai_gateway_mcp_servers:
- ref: secure-external-mcp-gateway-github-mcp
  ai_gateway: !lookup {id: !env 'AI_GATEWAY_ID'}
  name: secure-external-mcp-gateway-github-mcp
  display_name: secure-external-mcp-gateway GitHub MCP
  type: passthrough-listener
  enabled: true
  access:
    auth_strategies:
    - secure-external-mcp-gateway-github-key-auth
    acl_attribute_type: consumer
    default_tool_acls:
      deny:
      - secure-external-mcp-gateway-developer
  config:
    url: https://api.githubcopilot.com/mcp
    route:
      paths:
      - /github-mcp
      protocols:
      - http
      - https
      strip_path: true
      request_buffering: false
      response_buffering: false
    logging:
      payloads: true
      audits: true
    max_request_body_size: 10485760
  tools:
  - name: search_repositories
    access:
      acls:
        allow:
        - secure-external-mcp-gateway-admin
        - secure-external-mcp-gateway-developer
  - name: get_file_contents
    access:
      acls:
        allow:
        - secure-external-mcp-gateway-admin
        - secure-external-mcp-gateway-developer
  - name: list_issues
    access:
      acls:
        allow:
        - secure-external-mcp-gateway-admin
        - secure-external-mcp-gateway-developer
  - name: list_pull_requests
    access:
      acls:
        allow:
        - secure-external-mcp-gateway-admin
        - secure-external-mcp-gateway-developer
  - name: search_users
    access:
      acls:
        allow:
        - secure-external-mcp-gateway-admin
        - secure-external-mcp-gateway-developer
  - name: search_code
    access:
      acls:
        allow:
        - secure-external-mcp-gateway-admin
        - secure-external-mcp-gateway-developer
  - name: issue_write
    access:
      acls:
        allow:
        - secure-external-mcp-gateway-admin
  - name: push_files
    access:
      acls:
        allow:
        - secure-external-mcp-gateway-admin
  - name: create_pull_request
    access:
      acls:
        allow:
        - secure-external-mcp-gateway-admin
  - name: merge_pull_request
    access:
      acls:
        allow:
        - secure-external-mcp-gateway-admin
  - name: create_repository
    access:
      acls:
        allow:
        - secure-external-mcp-gateway-admin
- ref: secure-external-mcp-gateway-konnect-mcp
  ai_gateway: !lookup {id: !env 'AI_GATEWAY_ID'}
  name: secure-external-mcp-gateway-konnect-mcp
  display_name: secure-external-mcp-gateway Konnect MCP
  type: passthrough-listener
  enabled: true
  access:
    auth_strategies:
    - secure-external-mcp-gateway-konnect-oauth
    acl_attribute_type: consumer
    metadata:
      resource: https://localhost:8443/konnect-mcp
      authorization_servers:
      - !env 'OAUTH_AUTH_SERVER'
      scopes_supported:
      - openid
      endpoint: /.well-known/oauth-protected-resource/konnect-mcp
  config:
    url: !env 'KONNECT_MCP_HOST'
    route:
      paths:
      - /konnect-mcp
      protocols:
      - http
      - https
      request_buffering: false
      response_buffering: false
    logging:
      payloads: true
      audits: true
    max_request_body_size: 10485760
  policies:
  - secure-external-mcp-gateway-konnect-token-swap
EOF

kongctl apply -f kong-recipe.yaml -o text --auto-approve --pat "${KONNECT_TOKEN}"

rm -f kong-recipe.yaml

Connect Insomnia to GitHub MCP

Create an MCP client in Insomnia for the GitHub route. The client sends two credentials: the apikey header identifies the AI Consumer for Kong, and the GitHub token from the OAuth flow authenticates the user to GitHub.

The Konnect MCP server rejects traffic that reaches Kong over HTTP, so this cookbook uses the data plane’s HTTPS listener at https://localhost:8443, which has a self-signed certificate. In each Insomnia MCP client, click Manage Certificates and turn off SSL Certificate Validation under Extra Options. The setting applies to that MCP client only.

  1. In Insomnia, click MCP Clients in the left pane, name the client GitHub MCP, and click Create.
  2. In MCP Server URL, enter https://localhost:8443/github-mcp.
  3. Click the Headers tab and add the header apikey with the value dev-api-key.
  4. Click the Auth tab, select OAuth 2.0, and set Grant Type to MCP Auth Flow.
  5. Enter the Client ID and Client Secret of your GitHub OAuth App.
  6. Under Advanced Options, set Scope to repo read:user read:org. GitHub issues a token with no scopes when the request has none, and the GitHub MCP server then rejects tool calls.
  7. Click Connect. Kong forwards the first request to GitHub, which answers with 401 and its protected resource metadata. Insomnia opens GitHub in your browser.
  8. Sign in to GitHub and authorize the application. Insomnia stores the token and connects.

If Insomnia doesn’t start the GitHub sign-in, set Grant Type to Authorization Code, set Authorization URL to https://github.com/login/oauth/authorize and Access Token URL to https://github.com/login/oauth/access_token, and keep the same Client ID, Client Secret, and Scope. This cookbook hasn’t confirmed the discovery through Kong against a live AI Gateway.

Compare developer and admin tools

The left pane lists the tools that Kong returns for the dev-api-key AI Consumer. The developer AI Consumer Group gets six read-only tools: search_repositories, get_file_contents, list_issues, list_pull_requests, search_users, and search_code.

  1. Call search_repositories with the query kong language:go. The response contains GitHub’s search results.
  2. Click the Headers tab, change the apikey value to admin-api-key, and reconnect.

The admin AI Consumer Group gets each tool that the GitHub MCP server offers, including the write tools issue_write, push_files, create_pull_request, merge_pull_request, and create_repository.

If a client calls a tool that its AI Consumer Group can’t use, Kong rejects the tools/call request with 403 Forbidden before it reaches GitHub (ACL evaluation logic).

Call Konnect MCP through the token swap

Create a second MCP client for the Konnect route. This route needs no apikey header. Kong identifies the user from the IdP token.

  1. Click MCP Clients, name the client Konnect MCP, and click Create.
  2. In MCP Server URL, enter https://localhost:8443/konnect-mcp, and turn off SSL Certificate Validation in Manage Certificates.
  3. Click the Auth tab, select OAuth 2.0, set Grant Type to MCP Auth Flow, and enter the Client ID of the MCP Client application (Okta) or mcp-client (Keycloak). Leave Client Secret empty.
  4. Click Connect. Kong answers with 401 and a link to its own protected resource metadata, which names your IdP as the authorization server. Insomnia opens your IdP in the browser.
  5. Sign in as your test user. Insomnia connects with the IdP token.
  6. Call a read-only tool from the list, for example one that lists your control planes.

Kong validates the IdP token, removes it, and adds the stored Konnect credential, so the response comes from Konnect with the permissions of KONNECT_MCP_TOKEN. This cookbook hasn’t confirmed the token swap against a live AI Gateway.

Check the results

The Insomnia sessions confirm the following:

Behavior

Evidence

AI Consumer identification next to the GitHub token The GitHub MCP client connects only with a valid apikey header and a GitHub token.
Tool ACLs for each AI Consumer Group With dev-api-key, the tool list has six read-only tools. With admin-api-key, it also has the write tools.
IdP sign-in through protected resource metadata The Konnect MCP client gets a 401 from Kong, then opens your IdP’s sign-in page.
Token swap Konnect MCP tools return data for the stored credential, although Insomnia only holds an IdP token.

To review the created entities and the MCP traffic, open the secure-external-mcp-gateway-recipe AI Gateway in Konnect. For traffic across all your AI Gateways, use the Observability menu.

How it works

Each route has its own AI MCP Server in passthrough-listener mode, which forwards MCP traffic to the upstream MCP server without converting tools. The GitHub route authenticates the AI Consumer with an API key and leaves the GitHub token in place. The Konnect route authenticates the user with your IdP and replaces the user’s token with a stored credential.

The following diagram shows the GitHub route:

sequenceDiagram
    participant C as MCP Client
    participant K as Kong AI Gateway
    participant GH as GitHub

    C->>K: MCP request with apikey, no GitHub token
    activate K
    K->>K: Key Auth AI Auth Strategy (else 401)
    K->>GH: Forwarded request
    activate GH
    GH-->>K: 401 and GitHub protected resource metadata
    deactivate GH
    K-->>C: 401 from GitHub
    deactivate K
    C->>GH: OAuth sign-in with Client ID and Client Secret
    activate GH
    GH-->>C: GitHub token
    deactivate GH
    C->>K: MCP request with apikey and GitHub token
    activate K
    K->>K: Key Auth AI Auth Strategy (else 401)
    K->>K: Tool ACL for the AI Consumer Group (else 403)
    K->>GH: Request with the GitHub token
    activate GH
    GH-->>K: MCP response
    deactivate GH
    K-->>C: MCP response
    deactivate K

The following diagram shows the Konnect route:

sequenceDiagram
    participant C as MCP Client
    participant K as Kong AI Gateway
    participant I as Identity Provider
    participant KM as Konnect MCP

    C->>K: MCP request, no token
    activate K
    K-->>C: 401 and Kong protected resource metadata
    deactivate K
    C->>I: Authorization Code with PKCE
    activate I
    I-->>C: Access token
    deactivate I
    C->>K: MCP request with the IdP token
    activate K
    K->>I: Introspect the token (else 401)
    activate I
    I-->>K: Token claims
    deactivate I
    K->>K: Remove the IdP token, add the stored Konnect credential
    K->>KM: Request with the stored credential
    activate KM
    KM-->>K: MCP response
    deactivate KM
    K-->>C: MCP response
    deactivate K

Key Auth AI Auth Strategy and AI Consumers

Authentication is an AI Auth Strategy, not an AI Policy. The Key Auth AI Auth Strategy reads the apikey header and maps the key to an AI Consumer. The AI Consumer’s group is the identity that the tool ACLs use. The GitHub token travels in the Authorization header, which Key Auth doesn’t read.

The following settings configure the Key Auth AI Auth Strategy, the AI Consumers, and the AI Consumer Groups:

Setting

Purpose

key_names: [apikey] Kong reads the AI Consumer key from the apikey header, so it doesn’t conflict with the GitHub token in Authorization.
hide_credentials: true Kong removes the apikey header before it forwards the request, so GitHub never sees the AI Consumer key.
credentials[].api_key The demo keys, from ADMIN_API_KEY and DEV_API_KEY. The field is write-only.
ai_gateway_consumer_groups[].consumers Puts each AI Consumer in its group: the admin AI Consumer in secure-external-mcp-gateway-admin, the developer AI Consumer in secure-external-mcp-gateway-developer.

Kong adds X-Consumer-Username and related headers to the upstream request, not to the response. MCP traffic for each AI Consumer appears in Konnect analytics.

GitHub AI MCP Server and tool ACLs

The GitHub AI MCP Server forwards MCP traffic to https://api.githubcopilot.com/mcp. Its tools list names GitHub MCP tools only to attach ACLs to them. Kong doesn’t own their schema. A per-tool ACL replaces the default ACL for that tool, so each tool lists every group it allows.

The following settings configure the GitHub AI MCP Server:

Setting

Purpose

type: passthrough-listener Kong proxies MCP traffic to the upstream server and applies the tool ACLs to tools/list and tools/call.
access.auth_strategies Each request needs a valid AI Consumer key.
access.acl_attribute_type: consumer Kong evaluates the ACLs against the AI Consumer and its AI Consumer Groups.
access.default_tool_acls.deny Denies the developer AI Consumer Group each tool that has no ACL of its own. Other AI Consumers, including the admin, can call those tools.
tools[].access.acls.allow The AI Consumer Groups that can call the tool. Read-only tools allow both groups. Write tools allow only the admin group.
config.url GitHub’s remote MCP server.
config.route.paths: [/github-mcp] and strip_path: true Clients call /github-mcp, and Kong removes the path before it adds the upstream path /mcp.
config.route.request_buffering and response_buffering: false Kong streams requests and responses instead of buffering them, so MCP streams aren’t delayed.
config.logging.payloads and audits: true Kong logs MCP payloads and an audit entry for each ACL decision.
config.max_request_body_size: 10485760 Accepts request bodies up to 10 MB, instead of the 8 MB default, for tool calls with file contents.

The tools that the cookbook lists have the following access:

Tool

Admin

Developer

search_repositories, get_file_contents, list_issues, list_pull_requests, search_users, search_code Allowed Allowed
issue_write, push_files, create_pull_request, merge_pull_request, create_repository Allowed Denied
Each other GitHub MCP tool Allowed Denied

OpenID Connect AI Auth Strategy

The OpenID Connect AI Auth Strategy validates the IdP token on the Konnect route by calling your IdP’s introspection endpoint. Because the AI MCP Server also sets access.metadata, AI Gateway adds the OAuth resource server behavior that MCP clients expect: it serves protected resource metadata and challenges requests that have no token (Protected resource metadata).

The following settings configure the OpenID Connect AI Auth Strategy:

Setting

Purpose

issuer Your IdP’s authorization server, from OAUTH_AUTH_SERVER.
auth_methods: [introspection] Kong validates the token with the introspection endpoint, so the IdP can issue opaque tokens.
introspection_endpoint, client_id, and client_secret The introspection endpoint and the Kong MCP Gateway client’s credentials. client_id and client_secret are lists.
cache_introspection: true Kong caches introspection results, so it doesn’t call the IdP for each request.
cache_tokens_salt A stable, non-secret value for the token cache keys.
consumer_optional: true Any authenticated IdP user can call the route without an AI Consumer. The AI Auth Strategy sets consumer_groups_claim and no consumer_claims: Konnect accepts only one of the two.
consumer_groups_claim: [groups] and consumer_groups_optional: true Kong maps a groups claim to AI Consumer Groups when the token has one, and doesn’t reject tokens without it.
credential_claim: [sub] Kong identifies a caller without an AI Consumer by the sub claim.
ssl_verify: true Kong verifies the IdP’s TLS certificate.
hide_credentials: true Kong removes the IdP token before it forwards the request, so the token never reaches Konnect.

Konnect AI MCP Server and token swap

The Konnect AI MCP Server forwards MCP traffic to KONNECT_MCP_HOST and advertises your IdP in its protected resource metadata. Its Request Transformer Advanced Policy runs after the OpenID Connect AI Auth Strategy and adds the stored Konnect credential to the request.

The following settings configure the Konnect AI MCP Server and the Request Transformer Advanced Policy:

Setting

Purpose

access.metadata.resource The URL that MCP clients use for this route, https://localhost:8443/konnect-mcp.
access.metadata.authorization_servers and scopes_supported Your IdP and the openid scope, which MCP clients read from the metadata to start the sign-in.
access.metadata.endpoint The path of the metadata document. AI Gateway adds it to the route.
config.url The Konnect MCP server, from KONNECT_MCP_HOST.
policies Attaches the Request Transformer Advanced Policy to this AI MCP Server only.
config.add.headers (Request Transformer Advanced Policy) Adds the header in KONNECT_MCP_TOKEN. A kongctl !env tag replaces the whole value, so the variable holds the complete Authorization:Bearer <token> string.

Production credentials: This cookbook stores the AI Consumer keys, the IdP client secret, and the Konnect credential in environment variables for simplicity. In production, use AI Vaults to reference them from a secret manager, for example AWS Secrets Manager, HashiCorp Vault, GCP Secret Manager, or Azure Key Vault.

Variations and next steps

You can change or extend this configuration in the following ways:

Variation

How

Add ACLs for more GitHub tools Add entries to the GitHub AI MCP Server’s tools list with the AI Consumer Groups that can call each tool. Tools without an entry follow access.default_tool_acls.
Use a system account access token Create a system account access token with only the permissions the Konnect MCP tools need, set KONNECT_MCP_TOKEN to Authorization:Bearer <token>, and apply again.
Restrict Konnect MCP tools by group Add a groups claim in your IdP, create AI Consumer Groups with the same names, and add tools[].access.acls to the Konnect AI MCP Server. The Secure Internal MCP Gateway cookbook shows the pattern.
Limit MCP calls Set rate_limiting on a passthrough-listener AI MCP Server to cap requests for an MCP method or a tool. See Rate limiting.
Connect another MCP client Add the client’s OAuth redirect URL to the GitHub OAuth App and to your IdP’s MCP client application. For GitHub, the client must accept a Client ID and a Client Secret and send the apikey header.
Proxy another external MCP server Add a passthrough-listener AI MCP Server with the provider’s MCP URL in config.url and reference the same Key Auth AI Auth Strategy. The AI Consumers and AI Consumer Groups don’t change.

Cleanup

The recipe’s kongctl namespace scoped all resources, so this teardown removes only this recipe’s configuration. Tear down the local data plane and delete the AI Gateway from Konnect:

export KONNECT_CONTROL_PLANE_NAME='secure-external-mcp-gateway-recipe' && curl -Ls https://get.konghq.com/ai | bash -s -- -d -k $KONNECT_TOKEN

In Insomnia, delete the GitHub MCP and Konnect MCP MCP clients. On GitHub, delete the Kong MCP Client OAuth App, and in your IdP, delete the two applications that you created.

Help us make these docs great!

Kong Developer docs are open source. If you find these useful and want to make them better, contribute today!