쿠키 변환을 사용하는 conversion-listener 모드로 MCP 서버 생성
쿠키 변환을 사용하는 conversion-listener 모드로 MCP 서버 생성 (AI MCP Proxy)
이 문서는 AI MCP Proxy 플러그인을 conversion-listener 모드로 구성해 쿠키 기반 인증이 적용된 Kong Gateway 서비스를 MCP 서버로 변환하는 방법을 안내해요 예제에서는 간단한 마켓플레이스 mock API를 띄운 뒤 decK 설정으로 도구를 정의하고 session_id 쿠키를 인증 증표로 업스트림에 전달하는 흐름까지 살펴봐요 Service와 Route 준비부터 플러그인 설정까지 차근차근 따라 하면 완성할 수 있어요
출처: 문서
본문
쿠키 conversion을 사용하는 conversion-listener 모드로 MCP 서버 생성하기 v3.13+
v3.13+ 쿠키 기반 인증을 사용해 Kong Gateway Services에서 MCP 서버를 생성해요.
이 설정이 제대로 동작하려면 다음과 같은 설정을 갖춘 Service와 Route가 필요해요:
services: - name: mcp-service url: http://host.docker.internal:3000 routes: - name: mcp-route paths: - /marketplace
AI MCP Proxy 플러그인을 사용하기 전에 노출할 업스트림 HTTP API가 필요해요.
외부 서비스에 의존하지 않고 플러그인을 테스트할 수 있도록 이 모의(mock) API를 사용하세요. 이 API는 /marketplace/users와 /marketplace/{userId}/orders 엔드포인트를 통해 노출되는 샘플 사용자와 주문으로 이루어진 작은 마켓플레이스를 시뮬레이션해요:
curl -s -o api.js "https://gist.githubusercontent.com/subnetmarco/5ddb23876f9ce7165df17f9216f75cce/raw/a44a947d69e6f597465050cc595b6abf4db2fbea/api.js"
npm install express
node api.js
이 예제는 config.tools.annotations.title을 사용해 도구에 의미 있는 이름을 추가함으로써 사람이 디버깅하기 쉽게 만들어요. 이 설정은 인증을 위해 session_id 쿠키를 필요로 하며, 플러그인이 들어오는 요청에서 이 쿠키를 추출해 업스트림 서비스로 전달해요.
사전 준비
-
실행 중이고 외부에 노출된 API
-
인증 서비스가 설정한 유효한 session_id 쿠키
플러그인 설정하기
Global
decK
이 섹션을 kong.yaml 설정 파일에 추가하세요:
_format_version: "3.0"
plugins:
- name: ai-mcp-proxy
config:
mode: conversion-listener
tools:
- description: Get users
method: GET
path: "/marketplace/users"
annotations:
title: Get users
parameters:
- name: id
in: query
required: false
schema:
type: string
description: Optional user ID
- name: session_id
in: cookie
description: Session identifier set by the authentication service. Treated
as the proof of an authenticated session.
required: true
schema:
type: string
- description: Get orders for a user
method: GET
path: "/marketplace/orders"
annotations:
title: Get users orders
parameters:
- name: userid
in: query
required: true
schema:
type: string
description: User ID to filter orders
- name: session_id
in: cookie
description: Session identifier set by the authentication service. Treated
as the proof of an authenticated session.
required: true
schema:
type: string
server:
timeout: 60000
max_request_body_size: 8192
{: data-file="kong.yaml" data-tool="deck" }
Admin API
다음 요청을 보내세요:
curl -i -X POST http://localhost:8001/plugins/ \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
--data '
{
"name": "ai-mcp-proxy",
"config": {
"mode": "conversion-listener",
"tools": [
{
"description": "Get users",
"method": "GET",
"path": "/marketplace/users",
"annotations": {
"title": "Get users"
},
"parameters": [
{
"name": "id",
"in": "query",
"required": false,
"schema": {
"type": "string"
},
"description": "Optional user ID"
},
{
"name": "session_id",
"in": "cookie",
"description": "Session identifier set by the authentication service. Treated as the proof of an authenticated session.",
"required": true,
"schema": {
"type": "string"
}
}
]
},
{
"description": "Get orders for a user",
"method": "GET",
"path": "/marketplace/orders",
"annotations": {
"title": "Get users orders"
},
"parameters": [
{
"name": "userid",
"in": "query",
"required": true,
"schema": {
"type": "string"
},
"description": "User ID to filter orders"
},
{
"name": "session_id",
"in": "cookie",
"description": "Session identifier set by the authentication service. Treated as the proof of an authenticated session.",
"required": true,
"schema": {
"type": "string"
}
}
]
}
],
"server": {
"timeout": 60000
},
"max_request_body_size": 8192
}
}
'
Konnect API
다음 요청을 보내세요:
curl -X POST https://{region}.api.konghq.com/v2/control-planes/{controlPlaneId}/core-entities/plugins/ \
--header "accept: application/json" \
--header "Content-Type: application/json" \
--header "Authorization: Bearer $KONNECT_TOKEN" \
--data '
{
"name": "ai-mcp-proxy",
"config": {
"mode": "conversion-listener",
"tools": [
{
"description": "Get users",
"method": "GET",
"path": "/marketplace/users",
"annotations": {
"title": "Get users"
},
"parameters": [
{
"name": "id",
"in": "query",
"required": false,
"schema": {
"type": "string"
},
"description": "Optional user ID"
},
{
"name": "session_id",
"in": "cookie",
"description": "Session identifier set by the authentication service. Treated as the proof of an authenticated session.",
"required": true,
"schema": {
"type": "string"
}
}
]
},
{
"description": "Get orders for a user",
"method": "GET",
"path": "/marketplace/orders",
"annotations": {
"title": "Get users orders"
},
"parameters": [
{
"name": "userid",
"in": "query",
"required": true,
"schema": {
"type": "string"
},
"description": "User ID to filter orders"
},
{
"name": "session_id",
"in": "cookie",
"description": "Session identifier set by the authentication service. Treated as the proof of an authenticated session.",
"required": true,
"schema": {
"type": "string"
}
}
]
}
],
"server": {
"timeout": 60000
},
"max_request_body_size": 8192
}
}
'
다음 플레이스홀더는 반드시 여러분의 값으로 바꾸세요:
-
region: 여러분의 Kong Konnect가 호스팅되고 운영되는 지리적 지역이에요. -
KONNECT_TOKEN: Konnect 계정에 연결된 여러분의 개인 액세스 토큰(PAT)이에요. -
controlPlaneId: 컨트롤 플레인의id예요.
지역별 URL과 개인 액세스 토큰에 대해 알아보려면 Konnect Control Planes Config API reference를 참고하세요.
KIC
echo "
apiVersion: configuration.konghq.com/v1
kind: KongClusterPlugin
metadata:
name:
namespace: kong
annotations:
kubernetes.io/ingress.class: kong
labels:
global: 'true'
config:
mode: conversion-listener
tools:
- description: Get users
method: GET
path: '/marketplace/users'
annotations:
title: Get users
parameters:
- name: id
in: query
required: false
schema:
type: string
description: Optional user ID
- name: session_id
in: cookie
description: Session identifier set by the authentication service. Treated as
the proof of an authenticated session.
required: true
schema:
type: string
- description: Get orders for a user
method: GET
path: '/marketplace/orders'
annotations:
title: Get users orders
parameters:
- name: userid
in: query
required: true
schema:
type: string
description: User ID to filter orders
- name: session_id
in: cookie
description: Session identifier set by the authentication service. Treated as
the proof of an authenticated session.
required: true
schema:
type: string
server:
timeout: 60000
max_request_body_size: 8192
plugin: ai-mcp-proxy
" | kubectl apply -f -
Terraform
사전 준비: 개인 액세스 토큰 설정하기
terraform {
required_providers {
konnect = {
source = "kong/konnect"
}
}
}
provider "konnect" {
personal_access_token = "$KONNECT_TOKEN"
server_url = "https://us.api.konghq.com/"
}
Konnect Gateway Plugin을 생성하려면 Terraform 설정에 다음을 추가하세요:
resource "konnect_gateway_plugin_ai_mcp_proxy" "my_ai_mcp_proxy" {
enabled = true
config = {
mode = "conversion-listener"
tools = [
{
description = "Get users"
method = "GET"
path = "/marketplace/users"
annotations = {
title = "Get users"
}
parameters = [
{
name = "id"
in = "query"
required = false
schema = {
type = "string"
}
description = "Optional user ID"
},
{
name = "session_id"
in = "cookie"
description = "Session identifier set by the authentication service. Treated as the proof of an authenticated session."
required = true
schema = {
type = "string"
}
} ]
},
{
description = "Get orders for a user"
method = "GET"
path = "/marketplace/orders"
annotations = {
title = "Get users orders"
}
parameters = [
{
name = "userid"
in = "query"
required = true
schema = {
type = "string"
}
description = "User ID to filter orders"
},
{
name = "session_id"
in = "cookie"
description = "Session identifier set by the authentication service. Treated as the proof of an authenticated session."
required = true
schema = {
type = "string"
}
} ]
} ]
server = {
timeout = 60000
}
max_request_body_size = 8192
}
control_plane_id = konnect_gateway_control_plane.my_konnect_cp.id
}
Service
decK
설정 파일인 kong.yaml에 다음 섹션을 추가해요:
_format_version: "3.0"
plugins:
- name: ai-mcp-proxy
service: serviceName|Id
config:
mode: conversion-listener
tools:
- description: Get users
method: GET
path: "/marketplace/users"
annotations:
title: Get users
parameters:
- name: id
in: query
required: false
schema:
type: string
description: Optional user ID
- name: session_id
in: cookie
description: Session identifier set by the authentication service. Treated
as the proof of an authenticated session.
required: true
schema:
type: string
- description: Get orders for a user
method: GET
path: "/marketplace/orders"
annotations:
title: Get users orders
parameters:
- name: userid
in: query
required: true
schema:
type: string
description: User ID to filter orders
- name: session_id
in: cookie
description: Session identifier set by the authentication service. Treated
as the proof of an authenticated session.
required: true
schema:
type: string
server:
timeout: 60000
max_request_body_size: 8192
{: data-file="kong.yaml" data-tool="deck" }
다음 자리표시자는 여러분의 값으로 바꿔야 해요:
serviceName|Id: 플러그인 설정이 대상으로 삼을 서비스의id또는name이에요.
Admin API
다음 요청을 보내세요:
curl -i -X POST http://localhost:8001/services/{serviceName|Id}/plugins/ \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
--data '
{
"name": "ai-mcp-proxy",
"config": {
"mode": "conversion-listener",
"tools": [
{
"description": "Get users",
"method": "GET",
"path": "/marketplace/users",
"annotations": {
"title": "Get users"
},
"parameters": [
{
"name": "id",
"in": "query",
"required": false,
"schema": {
"type": "string"
},
"description": "Optional user ID"
},
{
"name": "session_id",
"in": "cookie",
"description": "Session identifier set by the authentication service. Treated as the proof of an authenticated session.",
"required": true,
"schema": {
"type": "string"
}
}
]
},
{
"description": "Get orders for a user",
"method": "GET",
"path": "/marketplace/orders",
"annotations": {
"title": "Get users orders"
},
"parameters": [
{
"name": "userid",
"in": "query",
"required": true,
"schema": {
"type": "string"
},
"description": "User ID to filter orders"
},
{
"name": "session_id",
"in": "cookie",
"description": "Session identifier set by the authentication service. Treated as the proof of an authenticated session.",
"required": true,
"schema": {
"type": "string"
}
}
]
}
],
"server": {
"timeout": 60000
},
"max_request_body_size": 8192
}
}
'
다음 자리표시자는 여러분의 값으로 바꿔야 해요:
serviceName|Id: 플러그인 설정이 대상으로 삼을 서비스의id또는name이에요.
Konnect API
다음 요청을 보내세요:
curl -X POST https://{region}.api.konghq.com/v2/control-planes/{controlPlaneId}/core-entities/services/{serviceId}/plugins/ \
--header "accept: application/json" \
--header "Content-Type: application/json" \
--header "Authorization: Bearer $KONNECT_TOKEN" \
--data '
{
"name": "ai-mcp-proxy",
"config": {
"mode": "conversion-listener",
"tools": [
{
"description": "Get users",
"method": "GET",
"path": "/marketplace/users",
"annotations": {
"title": "Get users"
},
"parameters": [
{
"name": "id",
"in": "query",
"required": false,
"schema": {
"type": "string"
},
"description": "Optional user ID"
},
{
"name": "session_id",
"in": "cookie",
"description": "Session identifier set by the authentication service. Treated as the proof of an authenticated session.",
"required": true,
"schema": {
"type": "string"
}
}
]
},
{
"description": "Get orders for a user",
"method": "GET",
"path": "/marketplace/orders",
"annotations": {
"title": "Get users orders"
},
"parameters": [
{
"name": "userid",
"in": "query",
"required": true,
"schema": {
"type": "string"
},
"description": "User ID to filter orders"
},
{
"name": "session_id",
"in": "cookie",
"description": "Session identifier set by the authentication service. Treated as the proof of an authenticated session.",
"required": true,
"schema": {
"type": "string"
}
}
]
}
],
"server": {
"timeout": 60000
},
"max_request_body_size": 8192
}
}
'
다음 자리표시자는 여러분의 값으로 바꿔야 해요:
-
region: Kong Konnect가 호스팅되고 운영되는 지리적 지역이에요. -
KONNECT_TOKEN: Konnect 계정과 연결된 여러분의 개인 액세스 토큰(PAT)이에요. -
controlPlaneId: 컨트롤 플레인의id예요. -
serviceId: 플러그인 설정이 대상으로 삼을 서비스의id예요.
지역별 URL과 개인 액세스 토큰에 대해 알아보려면 Konnect Control Planes Config API reference 문서를 참고하세요.
KIC
echo "
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
name:
namespace: kong
annotations:
kubernetes.io/ingress.class: kong
config:
mode: conversion-listener
tools:
- description: Get users
method: GET
path: '/marketplace/users'
annotations:
title: Get users
parameters:
- name: id
in: query
required: false
schema:
type: string
description: Optional user ID
- name: session_id
in: cookie
description: Session identifier set by the authentication service. Treated as
the proof of an authenticated session.
required: true
schema:
type: string
- description: Get orders for a user
method: GET
path: '/marketplace/orders'
annotations:
title: Get users orders
parameters:
- name: userid
in: query
required: true
schema:
type: string
description: User ID to filter orders
- name: session_id
in: cookie
description: Session identifier set by the authentication service. Treated as
the proof of an authenticated session.
required: true
schema:
type: string
server:
timeout: 60000
max_request_body_size: 8192
plugin: ai-mcp-proxy
" | kubectl apply -f -
다음으로, service 리소스에 어노테이션을 붙여서 KongPlugin 리소스를 적용해요:
kubectl annotate -n kong service SERVICE_NAME konghq.com/plugins=
Terraform
사전 준비: 개인 액세스 토큰 설정하기
terraform {
required_providers {
konnect = {
source = "kong/konnect"
}
}
}
provider "konnect" {
personal_access_token = "$KONNECT_TOKEN"
server_url = "https://us.api.konghq.com/"
}
Konnect Gateway 플러그인을 생성하려면 Terraform 설정에 다음 내용을 추가해요:
resource "konnect_gateway_plugin_ai_mcp_proxy" "my_ai_mcp_proxy" {
enabled = true
config = {
mode = "conversion-listener"
tools = [
{
description = "Get users"
method = "GET"
path = "/marketplace/users"
annotations = {
title = "Get users"
}
parameters = [
{
name = "id"
in = "query"
required = false
schema = {
type = "string"
}
description = "Optional user ID"
},
{
name = "session_id"
in = "cookie"
description = "Session identifier set by the authentication service. Treated as the proof of an authenticated session."
required = true
schema = {
type = "string"
}
} ]
},
{
description = "Get orders for a user"
method = "GET"
path = "/marketplace/orders"
annotations = {
title = "Get users orders"
}
parameters = [
{
name = "userid"
in = "query"
required = true
schema = {
type = "string"
}
description = "User ID to filter orders"
},
{
name = "session_id"
in = "cookie"
description = "Session identifier set by the authentication service. Treated as the proof of an authenticated session."
required = true
schema = {
type = "string"
}
} ]
} ]
server = {
timeout = 60000
}
max_request_body_size = 8192
}
control_plane_id = konnect_gateway_control_plane.my_konnect_cp.id
service = {
id = konnect_gateway_service.my_service.id
}
}
Route
decK
설정 파일인 kong.yaml에 다음 섹션을 추가해요:
_format_version: "3.0"
plugins:
- name: ai-mcp-proxy
route: routeName|Id
config:
mode: conversion-listener
tools:
- description: Get users
method: GET
path: "/marketplace/users"
annotations:
title: Get users
parameters:
- name: id
in: query
required: false
schema:
type: string
description: Optional user ID
- name: session_id
in: cookie
description: Session identifier set by the authentication service. Treated
as the proof of an authenticated session.
required: true
schema:
type: string
- description: Get orders for a user
method: GET
path: "/marketplace/orders"
annotations:
title: Get users orders
parameters:
- name: userid
in: query
required: true
schema:
type: string
description: User ID to filter orders
- name: session_id
in: cookie
description: Session identifier set by the authentication service. Treated
as the proof of an authenticated session.
required: true
schema:
type: string
server:
timeout: 60000
max_request_body_size: 8192
{: data-file="kong.yaml" data-tool="deck" }
다음 자리표시자는 여러분의 값으로 바꿔야 해요:
routeName|Id: 플러그인 설정이 대상으로 삼을 라우트의id또는name이에요.
Admin API
다음 요청을 보내세요:
curl -i -X POST http://localhost:8001/routes/{routeName|Id}/plugins/ \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
--data '
{
"name": "ai-mcp-proxy",
"config": {
"mode": "conversion-listener",
"tools": [
{
"description": "Get users",
"method": "GET",
"path": "/marketplace/users",
"annotations": {
"title": "Get users"
},
"parameters": [
{
"name": "id",
"in": "query",
"required": false,
"schema": {
"type": "string"
},
"description": "Optional user ID"
},
{
"name": "session_id",
"in": "cookie",
"description": "Session identifier set by the authentication service. Treated as the proof of an authenticated session.",
"required": true,
"schema": {
"type": "string"
}
}
]
},
{
"description": "Get orders for a user",
"method": "GET",
"path": "/marketplace/orders",
"annotations": {
"title": "Get users orders"
},
"parameters": [
{
"name": "userid",
"in": "query",
"required": true,
"schema": {
"type": "string"
},
"description": "User ID to filter orders"
},
{
"name": "session_id",
"in": "cookie",
"description": "Session identifier set by the authentication service. Treated as the proof of an authenticated session.",
"required": true,
"schema": {
"type": "string"
}
}
]
}
],
"server": {
"timeout": 60000
},
"max_request_body_size": 8192
}
}
'
다음 플레이스홀더를 여러분의 값으로 바꾸는 걸 잊지 마세요:
routeName|Id: 플러그인 구성이 대상으로 지정할 라우트의id또는name이에요.
Konnect API
다음 요청을 보내세요:
curl -X POST https://{region}.api.konghq.com/v2/control-planes/{controlPlaneId}/core-entities/routes/{routeId}/plugins/ \
--header "accept: application/json" \
--header "Content-Type: application/json" \
--header "Authorization: Bearer $KONNECT_TOKEN" \
--data '
{
"name": "ai-mcp-proxy",
"config": {
"mode": "conversion-listener",
"tools": [
{
"description": "Get users",
"method": "GET",
"path": "/marketplace/users",
"annotations": {
"title": "Get users"
},
"parameters": [
{
"name": "id",
"in": "query",
"required": false,
"schema": {
"type": "string"
},
"description": "Optional user ID"
},
{
"name": "session_id",
"in": "cookie",
"description": "Session identifier set by the authentication service. Treated as the proof of an authenticated session.",
"required": true,
"schema": {
"type": "string"
}
}
]
},
{
"description": "Get orders for a user",
"method": "GET",
"path": "/marketplace/orders",
"annotations": {
"title": "Get users orders"
},
"parameters": [
{
"name": "userid",
"in": "query",
"required": true,
"schema": {
"type": "string"
},
"description": "User ID to filter orders"
},
{
"name": "session_id",
"in": "cookie",
"description": "Session identifier set by the authentication service. Treated as the proof of an authenticated session.",
"required": true,
"schema": {
"type": "string"
}
}
]
}
],
"server": {
"timeout": 60000
},
"max_request_body_size": 8192
}
}
'
다음 플레이스홀더를 여러분의 값으로 바꾸는 걸 잊지 마세요:
-
region: 여러분의 Kong Konnect가 호스팅되고 운영되는 지리적 리전이에요. -
KONNECT_TOKEN: Konnect 계정에 연결된 여러분의 개인 액세스 토큰(PAT)이에요. -
controlPlaneId: 컨트롤 플레인의id예요. -
routeId: 플러그인 구성이 대상으로 지정할 라우트의id예요.
리전별 URL과 개인 액세스 토큰에 대해 알아보려면 Konnect Control Planes Config API reference를 참고하세요.
KIC
echo "
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
name:
namespace: kong
annotations:
kubernetes.io/ingress.class: kong
config:
mode: conversion-listener
tools:
- description: Get users
method: GET
path: '/marketplace/users'
annotations:
title: Get users
parameters:
- name: id
in: query
required: false
schema:
type: string
description: Optional user ID
- name: session_id
in: cookie
description: Session identifier set by the authentication service. Treated as
the proof of an authenticated session.
required: true
schema:
type: string
- description: Get orders for a user
method: GET
path: '/marketplace/orders'
annotations:
title: Get users orders
parameters:
- name: userid
in: query
required: true
schema:
type: string
description: User ID to filter orders
- name: session_id
in: cookie
description: Session identifier set by the authentication service. Treated as
the proof of an authenticated session.
required: true
schema:
type: string
server:
timeout: 60000
max_request_body_size: 8192
plugin: ai-mcp-proxy
" | kubectl apply -f -
다음으로, httproute 또는 ingress 리소스에 어노테이션을 붙여서 KongPlugin 리소스를 적용하세요:
Gateway API
kubectl annotate -n kong httproute konghq.com/plugins=
Ingress
kubectl annotate -n kong ingress konghq.com/plugins=
Terraform
사전 조건: 개인 액세스 토큰 구성하기
terraform {
required_providers {
konnect = {
source = "kong/konnect"
}
}
}
provider "konnect" {
personal_access_token = "$KONNECT_TOKEN"
server_url = "https://us.api.konghq.com/"
}
Konnect Gateway 플러그인을 생성하려면 Terraform 구성에 다음 내용을 추가하세요:
resource "konnect_gateway_plugin_ai_mcp_proxy" "my_ai_mcp_proxy" {
enabled = true
config = {
mode = "conversion-listener"
tools = [
{
description = "Get users"
method = "GET"
path = "/marketplace/users"
annotations = {
title = "Get users"
}
parameters = [
{
name = "id"
in = "query"
required = false
schema = {
type = "string"
}
description = "Optional user ID"
},
{
name = "session_id"
in = "cookie"
description = "Session identifier set by the authentication service. Treated as the proof of an authenticated session."
required = true
schema = {
type = "string"
}
} ]
},
{
description = "Get orders for a user"
method = "GET"
path = "/marketplace/orders"
annotations = {
title = "Get users orders"
}
parameters = [
{
name = "userid"
in = "query"
required = true
schema = {
type = "string"
}
description = "User ID to filter orders"
},
{
name = "session_id"
in = "cookie"
description = "Session identifier set by the authentication service. Treated as the proof of an authenticated session."
required = true
schema = {
type = "string"
}
} ]
} ]
server = {
timeout = 60000
}
max_request_body_size = 8192
}
control_plane_id = konnect_gateway_control_plane.my_konnect_cp.id
route = {
id = konnect_gateway_route.my_route.id
}
}
관련 리소스
다음 단계
더 알아보기 (Learn more)
- AI MCP Proxy 플러그인의 모드와 설정 옵션을 정리한 레퍼런스 — AI MCP Proxy
- MCP 서버로 변환할 대상이 되는 Gateway Service 엔티티 설정 방법 — Service
- Service에 요청 경로를 연결하는 Route 엔티티 설정 방법 — Route
- Kong Gateway가 MCP 트래픽을 처리하는 방식을 다룬 개요 문서 — Kong MCP traffic gateway
- API를 MCP 도구로 자동 변환하는 또 다른 접근 방식을 소개 — Autogenerate serverless MCP
- AI Gateway의 개념과 제공 기능을 전반적으로 안내 — About AI Gateway