This recipe places Kong AI Gateway in front of external MCP servers with two AI MCP Server
entities, one per pattern:
sequenceDiagram
participant C as MCP Client
participant GH as GitHub
participant K as Kong AI Gateway
C->>GH: OAuth flow (Client ID and Secret configured directly in the MCP client)
activate GH
GH-->>C: GitHub Bearer token
deactivate GH
C->>K: MCP request (apikey and Bearer token)
activate K
K->>K: key-auth Auth Strategy, validate apikey, resolve Consumer (else 401)
K->>K: AI MCP Server ACLs, evaluate tool access for the Consumer's group (else 403)
K->>GH: Forward request with Bearer token
activate GH
GH-->>K: MCP response
deactivate GH
K-->>C: MCP response
deactivate KGitHub MCP (passthrough pattern). GitHub issues the upstream OAuth token directly to the MCP
client. Kong identifies the caller separately through a Key Auth AI Auth Strategy and enforces
tool-level ACLs before forwarding the GitHub Bearer token upstream unchanged.
sequenceDiagram
participant C as MCP Client
participant K as Kong AI Gateway
participant IdP as Identity Provider
participant KM as Konnect MCP Server
C->>K: MCP initialize (no token)
activate K
K-->>C: 401 and protected resource metadata
deactivate K
C->>IdP: OAuth flow (browser to Okta or Keycloak, then callback)
activate IdP
IdP-->>C: Bearer token
deactivate IdP
C->>K: MCP request (Bearer token)
activate K
K->>IdP: openid-connect Auth Strategy, introspect token (else 401)
activate IdP
IdP-->>K: Claims (sub maps to Consumer, groups maps to Consumer Group)
deactivate IdP
K->>K: Strip user token, inject stored Konnect credential
K->>KM: Forward request with stored Konnect credential
activate KM
KM-->>K: MCP response
deactivate KM
K-->>C: MCP response
deactivate KKonnect MCP (token swap pattern). The user authenticates against the organization’s IdP. An
OpenID Connect AI Auth Strategy validates the token, maps the caller to an AI Consumer, and serves
protected resource metadata on Kong’s behalf. Kong then swaps the user’s token for a stored
Konnect credential before forwarding.
|
Component
|
Responsibility
|
|
GitHub OAuth
|
Issues tokens for GitHub API access; the MCP client authenticates directly with GitHub
|
|
Identity Provider (Okta or Keycloak)
|
Issues tokens for organizational identity; used by the Konnect MCP pattern
|
|
Key Auth AI Auth Strategy
|
Resolves an AI Consumer from the apikey header for GitHub MCP ACL evaluation
|
|
OpenID Connect AI Auth Strategy
|
Validates the IdP token for Konnect MCP through introspection and maps claims to an AI Consumer and AI Consumer Group
|
|
AI MCP Server (GitHub MCP)
|
Proxies MCP traffic to GitHub in passthrough mode and enforces tool-level ACLs
|
|
AI MCP Server (Konnect MCP)
|
Proxies MCP traffic to the Konnect MCP server, advertises protected resource metadata, and hosts the token-swap AI Policy
|
|
Request Transformer Advanced Policy
|
Injects the stored Konnect credential once the OpenID Connect AI Auth Strategy strips the user’s token
|
The GitHub MCP server exposes 70+ tools. This recipe defines ACLs for a representative subset,
with a default deny for the developer AI Consumer Group on unlisted tools:
|
Tool
|
admin
|
developer
|
Type
|
search_repositories
|
yes
|
yes
|
read
|
get_file_contents
|
yes
|
yes
|
read
|
list_issues
|
yes
|
yes
|
read
|
list_pull_requests
|
yes
|
yes
|
read
|
search_users
|
yes
|
yes
|
read
|
search_code
|
yes
|
yes
|
read
|
create_issue
|
yes
|
no
|
write
|
push_files
|
yes
|
no
|
write
|
create_pull_request
|
yes
|
no
|
write
|
merge_pull_request
|
yes
|
no
|
write
|
create_repository
|
yes
|
no
|
write
|
|
(all other tools)
|
yes
|
no
|
default deny
|
Developers can search and read repositories, issues, pull requests, and code. Admins can also
create issues, push code, create and merge pull requests, and create repositories. The default
ACL denies only the developer group, so admins can call any GitHub MCP tool not explicitly
listed in the config, while developers can’t.