목록으로

Programming Notes

Amazon Bedrock AgentCore로 Claude Desktop에 안전한 웹 검색 추가하기

글: Jishnu Dasgupta, 2026년 10월 2일, 고급(300), Amazon Bedrock, Amazon Bedrock AgentCore, 기술 활용 가이드

Amazon Bedrock에서의 Claude Desktop은 강력한 AI 지원을 제공하지만, 통합된 웹 검색이 없으면 응답이 모델의 학습 지식 컷오프 시점으로 제한됩니다. 최신 문서 업데이트, 실시간 가격, 날씨 업데이트처럼 최신 정보가 필요한 경우, 모델이 스스로 그 정보를 가져올 수 없습니다.

Amazon Bedrock AgentCore는 어떤 프레임워크나 모델과도 함께 사용하여 규모에 맞게 에이전트를 구축하고 연결하며 최적화할 수 있는 플랫폼입니다. Amazon Bedrock AgentCore의 기능인 AgentCore Gateway를 사용하면 Claude Desktop을 웹 검색(Web Search)에 연결하여 이러한 지식 컷오프 격차를 해소할 수 있습니다. 웹 검색은 수백억 개의 문서를 아우르는 Amazon 웹 인덱스를 기반으로 하는, 완전관리형 Model Context Protocol(MCP) 호환 웹 검색 기능입니다. 모든 쿼리 트래픽은 AWS 인프라 내에 머무르며, 관리해야 할 외부 API 키가 없고 쿼리가 여러분의 경계를 벗어나지도 않습니다.

Claude Desktop에서는 관리형 MCP 서버를 사용하여 웹 검색 타깃이 활성화된 AgentCore Gateway에 연결할 수 있습니다. 이 글에서는 이러한 통합을 설정하는 단계를 살펴보고, JSON Web Token(JWT) 기반 인바운드 인증을 사용하여 통신을 보호하는 방법을 알아봅니다.

아키텍처

AWS에서 운영되는 많은 기업은 AWS 계정에 대한 싱글 사인온(SSO) 접근을 위해 AWS IAM Identity Center를 사용합니다. 이번 실습에서는 AgentCore Gateway의 인증 소스로 AWS IAM Identity Center를 사용합니다. 이 구성에서는 Amazon Bedrock의 Claude Desktop이 신뢰할 수 있는 기업 관리형 자격 증명 흐름을 통해 웹 검색을 호출할 수 있습니다. 이 접근 방식은 기존 조직의 자격 증명 거버넌스와 부합하며, 별도의 자격 증명이나 서드파티 자격 증명 공급자가 필요하지 않습니다.

AWS IAM Identity Center를 AgentCore Gateway의 JWT 기반 인증과 연결하기 위해, OAuth 2.0 인가 코드 부여 흐름(authorization code grant flow)을 사용하는 페더레이션 계층으로 Amazon Cognito를 사용합니다. IAM Identity Center는 Security Assertion Markup Language(SAML)를 통해 사용자 인증을 처리합니다. Amazon Cognito가 JWT를 발급하고, AgentCore Gateway가 모든 요청에서 이를 검증합니다. 전체 인증 체인은 AWS 안에 머무릅니다.

다음 시퀀스 다이어그램은 이 인증 흐름을 보여 줍니다.

그림 1: 사용자 인증 및 권한 부여 시퀀스 다이어그램

사전 요구 사항

이 글의 단계를 따라 하려면 다음이 필요합니다.

  • AWS Identity and Access Management(IAM) 역할과 Amazon Bedrock AgentCore 리소스를 생성할 수 있는 권한이 있는 AWS 계정
  • AWS Organizations의 관리 계정에 대한 관리자 접근 권한(AWS IAM Identity Center 구성용)
  • AWS 계정에 대한 SSO 접근이 미리 구성된 AWS IAM Identity Center
  • Amazon Bedrock을 추론 공급자로 설정한 Claude Desktop
  • 설치 및 구성된 AWS Command Line Interface(AWS CLI) v2
  • Python 3.10 이상
  • 최신 버전으로 업데이트된 Boto3 SDK

Amazon Bedrock AgentCore의 웹 검색은 현재 미국 동부(버지니아 북부) 리전(us-east-1), 유럽(아일랜드) 리전(eu-west-1), 아시아 태평양(도쿄) 리전(ap-northeast-1)에서 사용할 수 있습니다. 게이트웨이가 이러한 리전 중 하나에서 생성되었는지 확인하세요.

구성

구성은 인증 체인(AWS IAM Identity Center → Amazon Cognito → JWT)을 설정한 다음, AgentCore Gateway를 Claude Desktop에 연결하는 과정으로 이루어집니다. 다음 절에서 각 단계를 하나씩 살펴봅니다.

1단계: Amazon Cognito 사용자 풀 생성

대상 AWS 계정에서 AgentCore Gateway의 OpenID Connect(OIDC) 토큰 발급자 역할을 할 Amazon Cognito 사용자 풀을 생성합니다.

export AWS_REGION=<your-region>

# 사용자 풀 생성
aws cognito-idp create-user-pool \
  --pool-name "agentcore-websearch-pool" \
  --region $AWS_REGION \
  --auto-verified-attributes email \
  --schema '[{"Name":"email","Required":true,"Mutable":true,"AttributeDataType":"String"}]' \
  --username-attributes email \
  --username-configuration "CaseSensitive=false" \
  --mfa-configuration "OFF"

# 풀 ID 기록
export USER_POOL_ID=$(aws cognito-idp list-user-pools --max-results 10 \
  --region $AWS_REGION \
  --query "UserPools[?Name=='agentcore-websearch-pool'].Id" --output text)
echo "User Pool ID: $USER_POOL_ID"

# 도메인 생성 (전역적으로 고유해야 함)
aws cognito-idp create-user-pool-domain \
  --domain "<your-unique-prefix>" \
  --user-pool-id $USER_POOL_ID \
  --region $AWS_REGION

다음 단계를 위해 다음 값들을 저장해 두세요.

  • 사용자 풀 ID: $USER_POOL_ID
  • 도메인: <your-unique-prefix>.auth.<region>.amazoncognito.com
  • 대상(Audience): urn:amazon:cognito:sp:<user-pool-id>
  • ACS URL: https://<your-unique-prefix>.auth.<region>.amazoncognito.com/saml2/idpresponse

2단계: IAM Identity Center SAML 애플리케이션 구성

AWS Organizations 관리 계정에서 Cognito와 페더레이션할 SAML 애플리케이션을 생성합니다.

  1. IAM Identity Center 콘솔을 엽니다.

  2. Applications, Add application, I have an application I want to set up, SAML 2.0을 차례로 선택한 다음 Next를 선택합니다.

  3. 다음 세부 정보를 입력합니다.

    a. 표시 이름(Display name): AgentCore Web Search b. Manually type your metadata value를 선택합니다.

    i. ACS URL: https://<your-unique-prefix>.auth.<region>.amazoncognito.com/saml2/idpresponse ii. 대상(Audience): urn:amazon:cognito:sp:<user-pool-id>

    c. SAML 메타데이터 XML 파일을 다운로드하고 Submit을 선택합니다. d. 애플리케이션이 생성된 후, 속성 매핑(attribute mappings)을 편집하고 다음 값을 추가합니다.

    i. Subject, ${user:subject}, 형식: Persistent ii. Email, ${user:email}, 형식: Basic

    e. 웹 검색에 대한 접근 권한을 부여할 사용자 또는 그룹을 할당합니다.

3단계: SAML IdP를 Cognito에 연결

대상 계정으로 돌아가서, Cognito 사용자 풀에 IAM Identity Center를 SAML 자격 증명 공급자로 등록합니다.

# IAM Identity Center를 SAML IdP로 추가
METADATA=$(cat /path/to/downloaded-metadata.xml)

aws cognito-idp create-identity-provider \
  --user-pool-id $USER_POOL_ID \
  --provider-name "IAMIdentityCenterIdP" \
  --provider-type SAML \
  --provider-details "{\"MetadataFile\": $(echo "$METADATA" | python3 -c 'import sys,json; print(json.dumps(sys.stdin.read()))')}" \
  --attribute-mapping '{"email": "email"}' \
  --region $AWS_REGION

4단계: Amazon Bedrock AgentCore용 Cognito 앱 클라이언트 생성

클라이언트 시크릿이 있는 앱 클라이언트를 생성합니다. Claude Desktop은 이 클라이언트를 사용해 OAuth 흐름을 시작하고, 이 흐름이 IAM Identity Center를 통해 사용자를 인증한 뒤 AgentCore Gateway용 JWT를 획득합니다.

aws cognito-idp create-user-pool-client \
  --user-pool-id $USER_POOL_ID \
  --client-name "agentcore-websearch-client" \
  --generate-secret \
  --supported-identity-providers "IAMIdentityCenterIdP" \
  --callback-urls '["http://localhost:53280/callback"]' \
  --allowed-o-auth-flows code \
  --allowed-o-auth-scopes "openid" "email" "profile" \
  --allowed-o-auth-flows-user-pool-client \
  --region $AWS_REGION

출력에서 Client ID와 Client Secret을 기록해 두세요. 이것이 여러분의 애플리케이션 클라이언트 ID와 시크릿입니다.

5단계: 웹 검색 도구를 사용해 AgentCore Gateway 구성

이 단계에서는 인바운드 인증 유형(Inbound Auth Type)이 JSON Web Token(JWT)인 새 AgentCore Gateway를 생성합니다. 이 구성에는 앞 단계에서 생성한 Cognito 사용자 풀 ID와 애플리케이션 클라이언트 ID를 사용합니다.

다음 Python 스크립트를 실행하여 필요한 구성으로 게이트웨이를 생성하세요. 모든 자리 표시자는 여러분의 환경에 맞는 실제 값으로 바꿔야 합니다.

import boto3
import json
import time

session = boto3.Session(region_name="your-region")
iam_client = session.client("iam")
gateway_client = session.client("bedrock-agentcore-control")

ACCOUNT_ID = "your-target-aws-account-id"
ROLE_NAME = "websearch-gateway-role"
GATEWAY_NAME = "websearch-gateway"
COGNITO_DISCOVERY_URL = "https://cognito-idp.<your-region>.amazonaws.com/<user-pool-id>/.well-known/openid-configuration"
COGNITO_CLIENT_ID = "<cognito-application-client-id>"

# --- 1단계: IAM 실행 역할 생성 ---
trust_policy = {
    "Version": "2012-10-17",
    "Statement": [{
        "Effect": "Allow",
        "Principal": {"Service": "bedrock-agentcore.amazonaws.com"},
        "Action": "sts:AssumeRole",
        "Condition": {
            "StringEquals": {"aws:SourceAccount": ACCOUNT_ID}
        }
    }]
}

permissions_policy = {
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "GetGateway",
            "Effect": "Allow",
            "Action": "bedrock-agentcore:GetGateway",
            "Resource": f"arn:aws:bedrock-agentcore:us-east-1:{ACCOUNT_ID}:gateway/*"
        },
        {
            "Sid": "GetConfigBundle",
            "Effect": "Allow",
            "Action": "bedrock-agentcore:GetConfigurationBundleVersion",
            "Resource": f"arn:aws:bedrock-agentcore:us-east-1:{ACCOUNT_ID}:configuration-bundle/*"
        },
        {
            "Sid": "InvokeWebSearch",
            "Effect": "Allow",
            "Action": "bedrock-agentcore:InvokeWebSearch",
            "Resource": "arn:aws:bedrock-agentcore:us-east-1:aws:tool/web-search.v1"
        }
    ]
}

try:
    iam_client.create_role(
        RoleName=ROLE_NAME,
        AssumeRolePolicyDocument=json.dumps(trust_policy),
        Description="Execution role for web search AgentCore gateway",
    )
    print(f"✓ Role '{ROLE_NAME}' created.")
except iam_client.exceptions.EntityAlreadyExistsException:
    print(f"✓ Role '{ROLE_NAME}' already exists, reusing.")

iam_client.put_role_policy(
    RoleName=ROLE_NAME,
    PolicyName="websearch-gateway-policy",
    PolicyDocument=json.dumps(permissions_policy),
)
print(f"✓ Inline policy attached to '{ROLE_NAME}'.")

# --- 2단계: 게이트웨이 생성 ---
response = gateway_client.create_gateway(
    name=GATEWAY_NAME,
    description="AgentCore gateway with managed Web Search connector",
    roleArn=f"arn:aws:iam::{ACCOUNT_ID}:role/{ROLE_NAME}",
    protocolType="MCP",
    protocolConfiguration={
        "mcp": {
            "supportedVersions": ["2025-03-26"],
        }
    },
    authorizerType="CUSTOM_JWT",
    authorizerConfiguration={
        "customJWTAuthorizer": {
            "discoveryUrl": COGNITO_DISCOVERY_URL,
            "allowedClients": [COGNITO_CLIENT_ID],
        }
    },
)
gateway_id = response["gatewayId"]
gateway_url = response.get("gatewayUrl")
print(f"✓ Gateway created: {gateway_id}")
print(f"  URL: {gateway_url}")

# --- 3단계: 게이트웨이가 READY 상태가 될 때까지 대기 ---
print("Waiting for gateway to reach READY status...", end="", flush=True)
for i in range(40):  # 최대 약 10분
    resp = gateway_client.get_gateway(gatewayIdentifier=gateway_id)
    status = resp.get("status")
    if status == "READY":
        print(f" READY (after {(i+1)*15}s)")
        break
    elif status == "FAILED":
        print(f"
✗ Gateway entered FAILED status.")
        reasons = resp.get("statusReasons", [])
        for r in reasons:
            print(f"  Reason: {r}")
        exit(1)
    print(".", end="", flush=True)
    time.sleep(15)
else:
    print(f"
✗ Gateway did not reach READY within 10 minutes (last status: {status})")
    exit(1)

# --- 4단계: 관리형 웹 검색 커넥터 타깃 연결 ---
gateway_client.create_gateway_target(
    gatewayIdentifier=gateway_id,
    name="web-search-tool",
    description="Managed Web Search connector",
    targetConfiguration={
        "mcp": {
            "connector": {
                "source": {"connectorId": "web-search"},
                "configurations": [{"name": "WebSearch", "parameterValues": {}}],
            }
        }
    },
    credentialProviderConfigurations=[
        {"credentialProviderType": "GATEWAY_IAM_ROLE"}
    ],
)
print("✓ Web search target attached.")
print()
print("=" * 60)
print(f" Gateway ID: {gateway_id}")
print(f" Gateway URL: {gateway_url}")
print(f" Auth: CUSTOM_JWT (Cognito)")
print(f" Target: web-search (managed connector)")
print("=" * 60)

이제 JWT 기반 인바운드 인가가 적용된, 웹 검색 도구를 갖춘 AgentCore Gateway가 준비되었습니다.

6단계: Claude Desktop 구성

Claude Desktop 구성 문서의 단계에 따라 Amazon Bedrock용 Claude Desktop의 구성 창에 접근합니다. 창을 열고 나서 Connectors and Extensions를 선택한 다음, Add server, 이어서 Blank를 선택합니다.

다음 스크린샷은 이러한 옵션이 있는 구성 창을 보여 줍니다.

그림 2: Claude Desktop 커넥터 구성 창

다음 세부 정보를 입력합니다.

  1. 이름(Name): websearchtool
  2. 전송 방식(Transport): Streamable HTTP
  3. URL: 5단계에서 생성한 AgentCore Gateway의 게이트웨이 리소스 URL을 입력합니다.
  4. OAuth: Bring your own client
  5. Client ID: 4단계에서 생성한 앱 클라이언트의 클라이언트 ID를 입력합니다.
  6. Client Secret: 4단계에서 생성한 앱 클라이언트의 클라이언트 시크릿을 입력합니다.
  7. Authorization Server: ["https://<your-unique-prefix>.auth.<region>.amazoncognito.com/oauth2/authorize"]를 입력합니다.
  8. Scope: openid
  9. Callback host: localhost
  10. Callback port: 53280

완료되면 sign in and test를 선택합니다. 그러면 인증을 위한 브라우저가 열리고 AWS IAM Identity Center SSO 로그인으로 리디렉션됩니다. 자격 증명을 입력하여 인증하세요. 성공하면 "Authorization complete. You can close this tab and return to Claude."와 같은 메시지가 표시됩니다.

다시 Claude Desktop으로 돌아가면 다음 이미지처럼 MCP 등록 성공 메시지가 표시됩니다.

그림 3: Claude Desktop에서 MCP 서버 등록 성공

이제 Claude Desktop은 MCP tools/list 호출을 통해 WebSearchTool을 검색합니다. 모델이 웹에서 최신 정보를 필요로 할 때마다 이 도구를 자동으로 호출합니다.

테스트 및 검증

선호하는 인터페이스(예: Chat 또는 Cowork)에서 Claude Desktop이 최신 결과를 가져와야 하는 질의를 보내세요. 그러면 Claude가 웹 검색 도구를 성공적으로 검색했음을 나타내는 도구 실행 승인 상자가 표시됩니다. 승인하면 웹 검색 결과가 응답에 포함되는 것을 볼 수 있습니다.

그림 4: 웹 검색 도구 실행 승인 대화 상자

이 대화 상자는 Claude가 실행하려는 쿼리를 보여 주고 세 가지 옵션인 Deny(거부), Allow for this task(이 작업에 대해 허용), Allow once(한 번 허용)를 제공합니다. 승인하면 웹 검색 결과가 응답에 포함됩니다.

정리(Clean up)

따라 하면서 리소스를 생성했다면 다음 단계를 수행하여 삭제합니다.

# 게이트웨이 타깃 삭제
aws bedrock-agentcore-control delete-gateway-target --gateway-identifier <gateway-id> --target-id <target-id> --region $AWS_REGION

# 게이트웨이 삭제 (이 실습을 위해 생성한 경우에만)
aws bedrock-agentcore-control delete-gateway --gateway-identifier <gateway-id> --region $AWS_REGION

# IAM 정책 삭제 (이 실습을 위해 생성한 경우에만)
aws iam delete-role-policy --role-name websearch-gateway-role --policy-name websearch-gateway-policy

# IAM 역할 삭제 (이 실습을 위해 생성한 경우에만)
aws iam delete-role --role-name websearch-gateway-role

# Cognito 애플리케이션 클라이언트 삭제
aws cognito-idp delete-user-pool-client --user-pool-id $USER_POOL_ID --client-id <client-id> --region $AWS_REGION

# Cognito 자격 증명 공급자 삭제
aws cognito-idp delete-identity-provider --user-pool-id $USER_POOL_ID --provider-name IAMIdentityCenterIdP --region $AWS_REGION

# Cognito 풀 도메인 삭제
aws cognito-idp delete-user-pool-domain --user-pool-id $USER_POOL_ID --domain <your-unique-prefix> --region $AWS_REGION

# Cognito 풀 삭제
aws cognito-idp delete-user-pool --user-pool-id $USER_POOL_ID --region $AWS_REGION

마지막으로, 관리 계정의 IAM Identity Center 콘솔에서 2단계에서 생성한 SAML 애플리케이션을 삭제합니다.

결론

이 글에서는 AgentCore의 웹 검색을 Claude Desktop과 통합하는 방법을 살펴보았습니다. 이 실습에서는 AWS IAM Identity Center를 자격 증명 공급자로 사용했지만, 동일한 패턴은 SAML 또는 OIDC를 지원하는 모든 자격 증명 공급자와 함께 동작합니다. 기존 IdP를 Amazon Cognito의 페더레이션 소스로 구성하여 대체할 수도 있습니다. 이 접근 방식은 서드파티 의존성을 도입하지 않으면서 웹 검색 격차를 해소하며, 모든 쿼리는 여러분의 AWS 경계 안에 머무릅니다.

시작하려면 위 단계에 따라 여러분의 환경에 통합을 설정하세요. 고급 게이트웨이 구성에 대해서는 AgentCore Gateway 개발자 가이드를, 웹 검색에 대해 더 알아보려면 웹 검색 설명서를 참조하세요.

글쓴이 소개 — Jishnu Dasgupta

관련 리소스: 시작하기 · 새 소식 · 블로그 주제 · Amazon Bedrock · Amazon Comprehend · Amazon Kendra · Amazon Lex · Amazon Polly · Amazon Q · Amazon Rekognition · Amazon SageMaker · Amazon Textract

팔로우: Twitter · Facebook · LinkedIn · Twitch · 이메일 업데이트