Build a multi-account AI agent with AgentCore Gateway and MCP
https://aws.amazon.com/blogs/machine-learning/build-a-multi-account-ai-agent-with-agentcore-gateway-and-mcp/📌 【AWS】多帳戶 AI Agent 怎麼查資料不搬資料?AgentCore Gateway 給出答案
TL;DR:AWS 用 AgentCore Gateway 把各部門帳戶的 MCP 伺服器整合成單一端點,讓 Agent 跨帳戶查詢卻不需複製資料。
企業裡每個團隊都把資料留在自己的 AWS 帳戶裡,理由很直接:權責清楚、範圍隔離、部署節奏各自獨立。問題是,一個只看得到單一帳戶資料的 Agent 用處有限,但要串接分散帳戶的資料,過去往往意味著複製資料或纏鬥複雜的跨帳戶 IAM 設定。AWS 在這篇技術文章中,示範了如何用 Amazon Bedrock AgentCore Gateway 搭配 Model Context Protocol(MCP)解開這個結。
🤔 資料留在原地,只有查詢結果跨帳戶流動
核心設計目標很簡單:資料留在原本擁有它的業務線(LOB)帳戶,一次請求只讓該次查詢需要的特定資料流出,底層資料集本身不離開所屬帳戶。作者以一個中央平臺帳戶負責跑 Agent 與 LLM 推論,各業務線帳戶各自把資料與工具包裝成 MCP 伺服器,平臺帳戶的 AgentCore Gateway 則提供一個統一端點,讓 Agent 能跨已註冊的業務線發現並呼叫工具。
🧩 Hub-and-Spoke 架構:Gateway 是唯一入口
整體架構分三層:中央平臺帳戶、分散的業務線帳戶,以及作為整合層的 AgentCore Gateway。平臺帳戶用 AgentCore Runtime(一個具備 session 隔離、按用量計費、內建驗證的 serverless 環境)跑 Agent,LLM 推論則透過 Amazon Bedrock 執行,讓平臺團隊能統一控管可用模型、套用 Amazon Bedrock Guardrails,並在單一計費邊界追蹤成本。
業務線團隊不會直接暴露 S3 儲存桶或資料庫,而是把資料與工具包裝成 MCP 伺服器:例如零售銀行團隊提供 get_balance、get_profile;貸款團隊提供 get_credit_score、search_lending_policies(後者查詢的是包在 MCP 伺服器裡的 Amazon Bedrock Knowledge Bases,對銀行政策 PDF 做 RAG 檢索)。這些 MCP 伺服器同樣跑在各自帳戶的 AgentCore Runtime 上,業務線團隊因此完全掌握自己要暴露什麼工具、背後跑什麼商業邏輯,只要 MCP 工具介面維持一致,就能自由更換實作而不影響平臺端的 Agent。
📊 一次請求怎麼跨帳戶跑完全程
當 Agent 呼叫工具時,Gateway 會從 AgentCore Identity 取得 OAuth 2.0 machine-to-machine 憑證,附加到外送請求並路由到正確的業務線 MCP 伺服器;該伺服器再對 Okta 的 OIDC 端點驗證這個 token 後才在本地處理請求。業務線的 MCP 伺服器只回傳工具產出的特定結果,不是原始資料集,這個結果再作為推論的上下文流回平臺帳戶,原始資料全程不被複製或搬遷。範例應用程式裡的追蹤面板會顯示這次請求存取了哪些業務線,以及 AgentCore 的 Policy(Cedar)授權是否有拒絕紀錄。
新增一個業務線只需要在 Gateway 加一個 target,Agent 透過 tools/list 方法自動在下一次呼叫時發現新工具,不需要改動 Agent 本身的程式碼。
💡 生產環境的一道關鍵配置
每個業務線的 Runtime 都會驗證進來的 OAuth token,但文章特別提醒,在生產環境中業務線團隊應設定 allowedWorkloadConfiguration,把 Runtime 呼叫限制在身分鏈確實包含 Gateway 的請求,避免有人繞過 Gateway 的 Policy 與 Cedar 授權直接存取。
🎯 實務啟示
這套架構把跨帳戶治理的重擔從「Agent 程式碼裡手刻」搬到「Gateway 層統一設定」:內容安全靠 Guardrails、存取控制靠 Cedar Policy、身分驗證靠 AgentCore Identity,業務線團隊只需要維護好自己的 MCP 工具介面。對已經用多帳戶模型隔離團隊資料的組織來說,這是一條不必先做資料湖整併、就能讓 Agent 跨團隊查詢的實作路徑。
🔗 來源
- 標題:Build a multi-account AI agent with AgentCore Gateway and MCP
- 作者/機構:Senthil Kamala Rathinam,AWS Machine Learning Blog
- 連結:https://aws.amazon.com/blogs/machine-learning/build-a-multi-account-ai-agent-with-agentcore-gateway-and-mcp/
#AWS #AgentCore #MCP #AIAgent #CloudArchitecture #MultiAccount #Bedrock #OAuth #IAM #EnterpriseAI
原始資料 AWS ML · 收集於 2026-09-24
摘要原文
Enterprises increasingly want AI agents that can reason over data spread across many AWS accounts without copying or centralizing it. Each team keeps its data in its own account for good reasons: clear ownership, scope isolation, and independent deployment lifecycles. But an agent that sees only one account’s data delivers limited value, and connecting it to distributed sources usually means replicating data or untangling cross-account AWS Identity and Access Management (IAM) . The goal is to let data stay where it already lives, in each line-of-business (LOB) account. Only the specific data a request needs flows out at query time, so the underlying datasets do not leave their owning account. In this post, you build a multi-account architecture that keeps each team’s data in its own account while giving agents a unified way to query across them, using Amazon Bedrock AgentCore Gateway and Model Context Protocol (MCP) . Amazon Bedrock AgentCore is an agentic service for building, deploying, and operating highly effective agents securely at scale. A central platform account hosts the agent tier and large language model (LLM) inference through Amazon Bedrock. LOB teams expose their data and tools as MCP servers, and the platform account’s AgentCore Gateway gives agents a single endpoint for tool discovery and invocation across registered LOBs. Along the way, you set up cross-account MCP integration, authentication with AgentCore Identity , a capability of Amazon Bedrock AgentCore, and Okta , fine-grained authorization with Policy in Amazon Bedrock AgentCore, and the governance controls that support production readiness. The architecture follows a multi-account model with three layers: a central platform account, distributed LOB accounts, and AgentCore Gateway as the integration layer that connects them. The platform team owns the platform account, which runs the agent on AgentCore Runtime , a capability of Amazon Bedrock AgentCore. AgentCore Runtime is a serverless, framework-agnostic environment with session isolation in dedicated microVMs, consumption-based pricing, and built-in authentication. To keep the walkthrough clear, this post uses a single agent, but the same pattern supports multiple agents in the platform account. The agent connects to the platform account’s Gateway rather than to individual LOB MCP servers. LLM inference runs in the platform account through Amazon Bedrock. The platform team controls available foundation models (FMs), applies Amazon Bedrock Guardrails , and tracks costs through a single billing boundary, avoiding the overhead of managing model quotas across dozens of LOB accounts. As demand grows, some organizations distribute inference across several dedicated inference accounts, placing AgentCore Gateway in front as an Inference Gateway that routes traffic across model providers, selecting the provider based on the request and applying per-team rate limits. AgentCore Gateway in the platform account acts as the single MCP endpoint for the agent. It registers each LOB account’s MCP server as a target and, from that one endpoint, provides unified tool discovery with semantic search, centralized authentication through AgentCore Identity, fine-grained authorization with Policy in AgentCore , and observability . Beyond aggregating MCP servers and acting as an Inference Gateway, AgentCore Gateway supports additional target types that make it a central integration point. HTTP targets bring AgentCore Runtime agents, agent-to-agent (A2A) services, and other HTTP endpoints into the same governed endpoint, each addressable through its own sub-path. The platform team can also apply Amazon Bedrock Guardrails for content safety and configure Policy in AgentCore ( Cedar ) for fine-grained access control, both enforced at the Gateway layer outside the agent’s code. Rather than exposing raw AWS resources ( Amazon Simple Storage Service (Amazon S3) buckets, databases, Amazon Bedrock Knowledge Bases ) directly, each LOB team packages its data and tools as an MCP server. The retail banking team exposes tools like get_balance and get_profile . The lending team offers get_credit_score and search_lending_policies , where the latter queries the fully managed Retrieval Augmented Generation (RAG) capability in Amazon Bedrock Knowledge Bases over bank policy PDFs. This reference architecture wraps a standalone Amazon Bedrock Knowledge Base inside the MCP server for fine-grained control over the retrieval pipeline. For new implementations, you can instead attach an Amazon Bedrock Managed Knowledge Base directly to the Gateway as a native connector, so agents query it with standard MCP calls and you operate no retrieval infrastructure. The MCP server runs on AgentCore Runtime in the LOB account, a serverless, framework-agnostic environment with session isolation in dedicated microVMs, consumption-based pricing, built-in authentication through AgentCore Identity, and agent-specific observability. This gives LOB teams full ownership of their tool surface: they decide what to expose and what business logic runs behind each tool, and can change the implementation without affecting the platform agent, as long as the MCP tool interface stays consistent. This architecture follows a hub-and-spoke pattern: each LOB deploys a standalone MCP server (the spoke) using MCP over Streamable HTTP, while AgentCore Gateway (the hub) aggregates them behind a single endpoint. The agent connects to the Gateway as one MCP server, and the Gateway federates tool invocation across registered LOB targets. When the agent invokes a tool, the Gateway retrieves OAuth 2.0 machine-to-machine (M2M) credentials from AgentCore Identity, attaches them to the outbound request, and routes it to the right LOB MCP server, which authenticates the token against Okta’s OpenID Connect (OIDC) endpoint before processing the request locally. The LOB’s data stays in its own account: the MCP server returns only the specific result the tool produced, not the raw dataset, and that result flows to the platform account as context for inference. The source data isn’t copied or relocated. Figure 1: Multi-account AI agent architecture with AgentCore Gateway and MCP The following walkthrough traces a user’s question as it crosses account boundaries, invokes distributed tools, and returns a unified answer: Results flow back through the same chain (LOB to Gateway to Agent to backend), with a trace panel in the sample application showing which LOBs were accessed and Policy in AgentCore denials. Each LOB runtime validates the inbound OAuth token. In production, the LOB team configures allowedWorkloadConfiguration to restrict runtime invocation to requests whose identity chain includes the Gateway, reducing the risk of direct access that bypasses Gateway policy and Cedar authorization. The Strands Agent discovers LOB tools through the Gateway’s tools/list method, and queries AWS Agent Registry (Preview) at startup to discover registered LOB MCP servers. Onboarding a new LOB involves adding a Gateway target. The agent discovers the new tools on its next tools/list call. The following sections walk through each layer of the architecture: how LOB teams build and deploy MCP servers, how the platform team configures AgentCore Gateway with OAuth outbound authentication and Policy in AgentCore authorization, and how continuous evaluation helps keep the agent reliable as tools and models evolve. For the complete implementation, clone the accompanying repository and run the deployment script, which bootstraps AWS Cloud Development Kit (AWS CDK) across the four accounts, provisions the platform and LOB resources, deploys the MCP servers and Gateway targets, and launches a React web application on Amazon ECS behind CloudFront.
由 claude-code/sonnet 自動生成