AI Cloud Architect

Building a secure auth code flow setup using AgentCore Gateway with MCP clients

AWSHow-to by Swagat Kulkarni, Anagh Agrawal, Daniel Suarez and Navneet SabbineniAWS Artificial Intelligence Blog

This post demonstrates how to implement Open Authorization (OAuth) Code flow as an inbound authorization mechanism for MCP servers hosted on Amazon Bedrock AgentCore Gateway. By the end of this guide, you will have a production-ready setup where each AI assistant request is authenticated with a valid user identity token issued from your organization’s identity provider.

Read the original (opens the source's page in a new tab)

AI: Summary

What it is

A step-by-step setup that puts OAuth authorization code flow with PKCE in front of MCP servers on AgentCore Gateway, so each Kiro IDE request carries a user identity token from the organization's IdP.

Who it is for

Platform and security teams that let Kiro IDE users call MCP tools behind AgentCore Gateway and need per-user authentication.

Key points

  • Gateway is set to JWT inbound auth using the IdP discovery URL; Kiro IDE gets a 401 and starts the browser login flow.
  • The post uses mcp-remote as an OAuth proxy, which the post calls experimental proof-of-concept.
  • Tokens from client credentials or auth code flow are treated the same by the Gateway, so validation is the same either way.

The same at other vendors

Timeline

Posts about Amazon Bedrock AgentCore Gateway, oldest first.

  1. How-toConnecting MCP servers to Amazon Bedrock AgentCore Gateway using Authorization Code flow · AWS · How-to
  2. How-toConfiguring Amazon Bedrock AgentCore Gateway for secure access to private resources · AWS · How-to
  3. How-toSecure AI agents with Policy and Lambda interceptors in Amazon Bedrock AgentCore gateway · AWS · How-to
  4. Blog postExtending MCP support for Amazon Bedrock AgentCore Gateway · AWS · Blog post
  5. This postBuilding a secure auth code flow setup using AgentCore Gateway with MCP clients
  6. Generally availableIntroducing Web Search on Amazon Bedrock AgentCore · AWS · Announcement
  7. Generally availableAWS WAF adds support for Amazon Bedrock AgentCore Gateway · AWS · Announcement
  8. How-toImplement on-behalf-of token exchange for multi-tenant agents with Amazon Bedrock AgentCore Gateway · AWS · How-to
  9. Update to an existing featureHow AgentCore Gateway supports the MCP 2026-07-28 spec · AWS · Announcement
Show all 28 posts
  1. New featureAmazon Bedrock AgentCore Gateway supports AWS PrivateLink invocation and invocation logging · AWS · Announcement
  2. How-toSecure ingress connectivity to Amazon Bedrock AgentCore Gateway using interface VPC endpoints · AWS · How-to
  3. Blog postTransform your MCP architecture: Unite MCP servers through AgentCore Gateway · AWS · Blog post
  4. How-toBuild a biomedical research agent with Biomni tools and Amazon Bedrock AgentCore Gateway · AWS · How-to
  5. New featureApply fine-grained access control with Bedrock AgentCore Gateway interceptors · AWS · Announcement
  6. Blog postStreamline AI agent tool interactions: Connect API Gateway to AgentCore Gateway with MCP · AWS · Blog post
  7. How-toConnecting MCP servers to Amazon Bedrock AgentCore Gateway using Authorization Code flow · AWS · How-to
  8. How-toConfiguring Amazon Bedrock AgentCore Gateway for secure access to private resources · AWS · How-to
  9. How-toSecure AI agents with Policy and Lambda interceptors in Amazon Bedrock AgentCore gateway · AWS · How-to
  10. Blog postExtending MCP support for Amazon Bedrock AgentCore Gateway · AWS · Blog post
  11. This postBuilding a secure auth code flow setup using AgentCore Gateway with MCP clients
  12. Generally availableIntroducing Web Search on Amazon Bedrock AgentCore · AWS · Announcement
  13. Generally availableAWS WAF adds support for Amazon Bedrock AgentCore Gateway · AWS · Announcement
  14. How-toImplement on-behalf-of token exchange for multi-tenant agents with Amazon Bedrock AgentCore Gateway · AWS · How-to
  15. Update to an existing featureHow AgentCore Gateway supports the MCP 2026-07-28 spec · AWS · Announcement
  16. How-toConfigure rate limits for AI traffic on AgentCore gateway · AWS · How-to
  17. How-toSecuring AI agents with temporal policies in Amazon Bedrock AgentCore · AWS · How-to
  18. How-toGovern AI agent tool access with Amazon Bedrock AgentCore Gateway · AWS · How-to
  19. How-toBuild a multi-account AI agent with AgentCore Gateway and MCP · AWS · How-to
  20. Update to an existing featureAgentCore Gateway supports private TLS certificates for VPC endpoints · AWS · Announcement
  21. Blog postHow Eon built multi-cloud investigation with an MCP Gateway on Amazon Bedrock AgentCore · AWS · Blog post
  22. New featureAgentCore Gateway now supports Bedrock InvokeModel APIs and model fallback · AWS · Announcement
  23. New featureAWS Step Functions workflows now available as AI agent tools · AWS · Announcement
  24. Customer storyHow MoEngage turned over 400 APIs into agent tools with AgentCore Gateway · AWS · Customer story
  25. How-toServiceNow on-behalf-of token exchange with Bedrock AgentCore Gateway · AWS · How-to
  26. How-toGovern AI agent access with Okta Cross App Access and Amazon Bedrock AgentCore – Part 2 · AWS · How-to
  27. How-toConnect Amazon Bedrock AgentCore Gateway to private APIs in a hub-and-spoke network with centralized inspection · AWS · How-to
  28. Blog postProtect agent tool calls with Skyflow and Amazon Bedrock AgentCore Gateway · AWS · Blog post

Go deeper