{ "cells": [ { "cell_type": "markdown", "id": "83d8ecde-5c0b-4f95-827c-5c4b7209e17f", "metadata": {}, "source": [ "# Lab 3: Securely connect tools to your Agent with AgentCore Gateway \n", "\n", "## Overview\n", "\n", "In this Lab, you will learn how to integrate tools available in your organization with the Customer Support Agent using the Amazon Bedrock Gateway.\n", "\n", "The [Model Context Protocol (MCP)](https://modelcontextprotocol.io/docs/getting-started/intro) is an open protocol that standardizes how applications provide tools and context to Large Language Models (LLMs).\n", "\n", "With [Amazon Bedrock Agent Core Gateway](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/gateway.html), developers can convert APIs, Lambda functions, and existing services into MCP-compatible tools and make them available to agents through Gateway endpoints with just a few lines of code.\n", "\n", "\n", "**Workshop Journey:**\n", "\n", "- **Lab 1 (Done):** Create Agent Prototype - Built a functional customer support agent\n", "- **Lab 2 (Done):** Enhance with Memory - Added conversation context and personalization\n", "- **Lab 3 (Current):** Scale with Gateway & Identity - Shared tools across agents securely\n", "- **Lab 4:** Deploy to Production - Used AgentCore Runtime with observability\n", "- **Lab 5:** Build User Interface - Create a customer-facing application\n", "\n", "\n", "### Why AgentCore Gateway & Tool Sharing Matter\n", "\n", "Current State (Lab 1-2): Each agent has its own copy of tools. I practice that is not scalable and leads to:\n", "\n", "- Code duplication across different agents\n", "- Inconsistent tool behavior and maintenance overhead\n", "- No centralized security or access control\n", "- Difficulty scaling to multiple use cases\n", "\n", "After this lab, we will have centralized, reusable tools that can serve:\n", "\n", "- Customer Support Agent (our current use case)\n", "- Sales Agent (needs same product info and customer data)\n", "- Inventory Agent (needs same product info and warranty checking)\n", "- Returns Processing Agent (needs return policies and customer profiles)\n", "\n", "and other use cases. \n", "\n", "### Adding secure authentication with AgentCore Identity\n", "\n", "Additionally, AgentCore Gateway requires you to securely authenticate both inbound and outbound connections. [AgentCore Identity](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/identity.html) provides seamless agent identity and access management across AWS services and third-party applications such as Slack and Zoom while supporting any standard identity providers such as Okta, Entra, and Amazon Cognito. In this lab we will see how AgentCore Gateway integrates with AgentCore Identity to provide secure connections via inbound and outbound authentication. \n", "\n", "For the inbound authentication, the AgentCore Gateway analyzes the OAuth token passed during invocation to decide allow or deny the access to a tool in the gateway. If a tool needs access to external resources, the AgentCore Gateway can use outbound authentication via API Key, IAM or OAuth Token to allow or deny the access to the external resource.\n", "\n", "During the inbound authorization flow, an agent or the MCP client calls an MCP tool in the AgentCore Gateway adding an OAuth access token (generated from the user’s IdP). AgentCore Gateway then validates the OAuth access token and performs inbound authorization.\n", "\n", "If the tool running in AgentCore Gateway needs to access external resources, OAuth will retrieve credentials of downstream resources using the resource credential provider for the Gateway target. AgentCore Gateway pass the authorization credentials to the caller to get access to the downstream API.\n", "\n", "\n", "## Architecture for Lab 3\n", "\n", "