본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

Context Mesh와 Kong Operator로 MCP 서버 배포하기

원문 보기 위키 갱신

Context Mesh와 Kong Operator로 MCP 서버 배포하기 (Deploy an MCP server with Context Mesh and Kong Operator)

이 문서는 Kong Operator 2.3에 mcp-server 기능 게이트를 활성화해서 OpenWeather Context Mesh MCP 서버를 배포하는 전 과정을 안내해요

출처: 문서

본문

핵심 요약

OpenWeather Context Mesh MCP 서버는 어떻게 배포하나요? mcp-server 피처 게이트를 활성화한 Kong Operator 2.3을 설치하고, Konnect 관리형 컨트롤 플레인과 데이터 플레인을 만든 다음, Konnect API로 MCP 서버를 생성하고 배포해요.

사전 준비

Konnect 개인 액세스 토큰

  1. Konnect PAT 페이지를 열고 Generate Token을 선택해서 새 개인 액세스 토큰을 만들어요.

  2. 토큰과 여러분이 사용하는 리전의 Konnect API URL을 내보내요:

    export KONNECT_TOKEN='YOUR_KONNECT_PAT'
    export KONNECT_CONTROL_PLANE_URL='us.api.konghq.com'
    

Kubernetes 클러스터

로컬 Kubernetes 클러스터를 준비해요. 이 예제에서는 minikube를 사용해요:

minikube start

클러스터가 시작되면 터미널 창을 하나 더 열고, 클러스터에서 로드 밸런싱을 활성화해요:

minikube tunnel

프롬프트가 표시되면 비밀번호를 입력하세요. 이 가이드를 따라 하는 동안 이 창은 옆에 열어 두세요.

Claude Code

  1. Claude Code를 설치해요:

    curl -fsSL https://claude.ai/install.sh | bash
    
  2. 설치를 확인해요:

    claude --version
    

OpenWeatherMap 계정과 API 키

  1. openweathermap.org에서 계정을 만들어요
  2. API 키를 생성해요 (활성화되기까지 몇 시간이 걸릴 수 있어요)
export OPENWEATHERMAP_API_KEY='<your-api-key'

OpenWeather OpenAPI 스펙

OpenWeatherMap OpenAPI 스펙을 다운로드해요. 이 파일은 이 가이드 뒤에서 Konnect에 업로드하게 돼요:

curl -O https://developer.konghq.com/assets/context-mesh/openweathermap.json

Kong Helm 리포지터리 추가하기

kong이라는 이름을 Kong Helm 차트 URL에 매핑하고 최신 차트 인덱스를 다운로드해요:

helm repo add kong https://charts.konghq.com
helm repo update

Kong Operator 설치하기

Context Mesh MCP 서버를 실행하려면 Kong Gateway에 Kong Operator가 필요해요:

helm upgrade --install kong-operator kong/kong-operator -n kong \
  --create-namespace \
  --set image.tag=2.3 \
  --set env.ENABLE_CONTROLLER_KONNECT=true \
  --set env.FEATURE_GATES=mcp-server

이 명령은 다음 내용이 담긴 kong 네임스페이스를 만들어요:

  • 오퍼레이터 자체(kong-operator-kong-operator-controller-manager).
  • DataPlane 같은 리소스 타입을 Kubernetes 클러스터에 추가하는 CustomResourceDefinitions(CRD).
  • 오퍼레이터가 여러분 대신 그 리소스들을 관리할 수 있게 해 주는 역할 기반 액세스 제어(RBAC) 규칙.
  • 리소스가 적용되기 전에 검증하는 웹훅 구성.

Konnect 리소스를 만들기 전에 Kong Operator 디플로이먼트가 사용 가능해질 때까지 기다려요:

kubectl -n kong wait --for=condition=Available=true --timeout=120s \
  deployment/kong-operator-kong-operator-controller-manager

Konnect 컨트롤 플레인과 데이터 플레인 배포하기

다음 매니페스트는 Kong Operator가 클러스터에서 Konnect 관리형 데이터 플레인을 실행하는 데 필요한 네 가지 리소스를 만들어요:

  • KonnectAPIAuthConfiguration: 개인 액세스 토큰으로 Kong Operator를 Konnect API에 인증해요. serverURL은 KONNECT_CONTROL_PLANE_URL에서 읽어오기 때문에, 계정이 사용하는 리전을 가리켜요.
  • KonnectGatewayControlPlane: Konnect에 context-mesh-demo라는 이름의 컨트롤 플레인을 만들어요. 나중 단계에서 MCP 서버를 이 컨트롤 플레인에 연결하게 돼요.
  • KonnectExtension: 클러스터를 해당 컨트롤 플레인에 연결하고, 데이터 플레인이 컨트롤 플레인에 접속할 때 사용하는 mTLS 인증서를 프로비저닝해요.
  • DataPlane: Kong Gateway 3.16 프록시 레플리카 세 개를 배포해요. KonnectExtension 참조가 이 프록시들을 하이브리드 모드로 실행하고 context-mesh-demo에서 구성을 가져오도록 설정해요.

매니페스트를 적용해요:

kubectl apply -f - <<EOF
kind: KonnectAPIAuthConfiguration
apiVersion: konnect.konghq.com/v1alpha1
metadata:
  name: konnect-api-auth
  namespace: default
spec:
  type: token
  token: ${KONNECT_TOKEN}
  serverURL: ${KONNECT_CONTROL_PLANE_URL}
---
kind: KonnectGatewayControlPlane
apiVersion: konnect.konghq.com/v1alpha2
metadata:
  name: test
  namespace: default
spec:
  createControlPlaneRequest:
    name: context-mesh-demo
    labels:
      app: context-mesh-demo
  konnect:
    authRef:
      name: konnect-api-auth
---
kind: KonnectExtension
apiVersion: konnect.konghq.com/v1alpha2
metadata:
  name: my-konnect-config
  namespace: default
spec:
  konnect:
    controlPlane:
      ref:
        type: konnectNamespacedRef
        konnectNamespacedRef:
          name: test
---
apiVersion: gateway-operator.konghq.com/v1beta1
kind: DataPlane
metadata:
  name: dataplane
  namespace: default
spec:
  extensions:
  - kind: KonnectExtension
    name: my-konnect-config
    group: konnect.konghq.com
  deployment:
    replicas: 3
    podTemplateSpec:
      spec:
        containers:
        - name: proxy
          image: kong/kong-gateway:3.16
EOF

데이터 플레인이 준비될 때까지 기다리기

kubectl wait --timeout=3m dataplane dataplane -n default --for=condition=Ready

컨트롤 플레인 ID 가져오기

Kong Operator가 생성한 context-mesh-demo 컨트롤 플레인 ID를 확인해요. MCP 서버를 배포할 때 이 ID를 사용해 서버를 컨트롤 플레인에 연결하게 돼요:

CONTROL_PLANE_ID=$(curl -X GET "https://us.api.konghq.com/v2/control-planes?filter%5Bname%5D%5Beq%5D=context-mesh-demo" \
     --no-progress-meter --fail-with-body  \
     -H "Authorization: Bearer $KONNECT_TOKEN" | jq -r ".data[0].id"
)

OpenWeather API를 소스로 추가하기

소스는 Context Mesh가 MCP 서버를 생성할 때 사용하는 OpenAPI 스펙을 담아 두는 곳이에요. 스펙은 하나의 JSON 문자열로 전송되기 때문에, 다운로드해 둔 파일로 요청 본문을 만들어요:

jq -n --rawfile spec openweathermap.json '{
  "name": "openweathermap",
  "display_name": "OpenWeatherMap Current Weather API",
  "description": "Current weather data from OpenWeatherMap",
  "labels": {},
  "type": "api",
  "source": {
    "type": "raw",
    "config": {"spec": $spec}
  }
}' > source.json

소스를 생성해요:

SOURCE_ID=$(curl -X POST "https://us.api.konghq.com/v1/context-sources" \
     --no-progress-meter --fail-with-body  \
     -H "Authorization: Bearer $KONNECT_TOKEN" \
     --json "$(cat source.json)" | jq -r ".id"
)

name은 조직 안에서 고유해야 하고, 소문자, 숫자, 마침표, 하이픈만 포함할 수 있어요.

MCP 서버 생성하기

MCP 서버를 생성해요:

MCP_SERVER_ID=$(curl -X POST "https://us.api.konghq.com/v1/context-interfaces" \
     --no-progress-meter --fail-with-body  \
     -H "Authorization: Bearer $KONNECT_TOKEN" \
     --json '{
       "name": "openweather-service",
       "display_name": "OpenWeather Service",
       "description": "Code Mode MCP server for the OpenWeatherMap API",
       "labels": {}
     }' | jq -r ".id"
)

MCP 서버에는 아직 소스가 없어요. OpenWeather 소스를 이 서버에 매핑해요:

SOURCE_MAPPING_ID=$(curl -X POST "https://us.api.konghq.com/v1/context-interfaces/$MCP_SERVER_ID/context-source-mappings" \
     --no-progress-meter --fail-with-body  \
     -H "Authorization: Bearer $KONNECT_TOKEN" \
     --json '{
       "context_source_id": "'$SOURCE_ID'"
     }' | jq -r ".id"
)

같은 MCP 서버를 통해 두 개 이상의 API나 MCP 서버를 노출하려면, 각 소스에 대해 이 호출을 반복해요.

MCP 서버 배포하기

MCP 서버를 컨트롤 플레인에 매핑하면 배포돼요. mode를 basic으로 설정하면 Konnect가 기본값에 따라 기반이 되는 Kubernetes 워크로드를 관리해요:

CP_MAPPING_ID=$(curl -X POST "https://us.api.konghq.com/v1/context-interfaces/$MCP_SERVER_ID/control-plane-mappings" \
     --no-progress-meter --fail-with-body  \
     -H "Authorization: Bearer $KONNECT_TOKEN" \
     --json '{
       "control_plane_id": "'$CONTROL_PLANE_ID'",
       "mode": "basic"
     }' | jq -r ".id"
)

MCP 서버 파드가 준비될 때까지 기다리기

Kong Operator는 클러스터의 default 네임스페이스에서 mcpserver- 접두사가 붙은 디플로이먼트 형태로 MCP 서버를 실행해요. 파드가 나타날 때까지 기다린 다음, 준비 상태가 될 때까지 기다려요:

until kubectl get pods -n default -o name | grep -q '^pod/mcpserver-'; do sleep 5; done

kubectl wait --for=condition=Ready --timeout=3m -n default \
  $(kubectl get pods -n default -o name | grep '^pod/mcpserver-')

파드가 실행 중인지 확인해요:

kubectl get pods -n default | grep mcpserver

출력은 다음과 같아요:

mcpserver-test-45675cb3-764b4d6d6c-q2gnp   1/1     Running   0   57m

파드가 Pending이나 CrashLoopBackOff 상태에 머물러 있으면 kubectl logs -n default <pod-name>으로 로그를 확인해 보세요.

이제 MCP 런타임이 /mcp/openweather-service 경로에서 노출돼요.

Claude에 OpenWeather MCP 서버 추가하기

MCP 서버를 에이전트에 연결해요:

claude mcp add --transport http context-mesh-weather http://localhost/mcp/openweather-service \
  --header "X-Upstream-Api-Key: ${OPENWEATHERMAP_API_KEY}"

검증하기

Claude Code를 시작해요:

claude

로컬 context-mesh-weather MCP가 목록에 있는지 확인해요:

/mcp

MCP가 disabled로 표시되면 선택해서 활성화해요. 이때 이 단계의 minikube 터널 터미널에서 sudo 비밀번호를 입력해야 할 수도 있어요.

Claude Code에서 프롬프트를 입력해 보세요:

Tell me the weather in Hawaii.

정리

MCP 서버 삭제하기

컨트롤 플레인 매핑을 삭제해서 MCP 서버를 중지한 다음, MCP 서버와 소스를 삭제해요:

컨트롤 플레인 매핑을 삭제해요:

curl -X DELETE "https://us.api.konghq.com/v1/context-interfaces/$MCP_SERVER_ID/control-plane-mappings/$CP_MAPPING_ID" \
     --no-progress-meter --fail-with-body  \
     -H "Authorization: Bearer $KONNECT_TOKEN"

MCP 서버를 삭제해요:

curl -X DELETE "https://us.api.konghq.com/v1/context-interfaces/$MCP_SERVER_ID" \
     --no-progress-meter --fail-with-body  \
     -H "Authorization: Bearer $KONNECT_TOKEN"

MCP 소스를 삭제해요:

curl -X DELETE "https://us.api.konghq.com/v1/context-sources/$SOURCE_ID" \
     --no-progress-meter --fail-with-body  \
     -H "Authorization: Bearer $KONNECT_TOKEN"

컨트롤 플레인과 데이터 플레인 삭제하기

kubectl delete -n default dataplane dataplane
kubectl delete -n default konnectextension my-konnect-config
kubectl delete -n default konnectgatewaycontrolplane test
kubectl delete -n default konnectapiauthconfiguration konnect-api-auth

KonnectGatewayControlPlane을 삭제하면 Konnect에 있는 context-mesh-demo 컨트롤 플레인도 함께 삭제돼요. 가이드를 다시 수행할 계획이라도 이 단계는 꼭 실행하세요. 컨트롤 플레인 이름은 조직 내에서 고유해야 하기 때문에, context-mesh-demo가 남아 있으면 다음 실행이 409 Conflict로 실패하고 데이터 플레인은 끝내 준비되지 않아요.

Kong Operator 제거하기

helm uninstall kong-operator -n kong
kubectl delete namespace kong

더 알아보기 (Learn more)

  • Konnect에서 MCP 서버 배포에 필요한 퍼스널 액세스 토큰(PAT)을 발급할 수 있는 페이지예요 — Konnect PAT page