Define the gateway target configuration
The target configuration depends on the target type that you’re adding to the gateway. For more information about supported gateway target types, see Supported targets for Amazon Bedrock AgentCore gateways.
Select a topic to see examples of adding a target type:
Add a Lambda target
You can add a Lambda target to your gateway using the AgentCore CLI by passing a --target-configuration with "targetType": "lambdaFunctionArn", the Lambda ARN, and a tool schema file.
Target configuration
The target configuration (or payload) for a Lambda function contains the following fields:
-
lambdaArn – The ARN of the Lambda function to use as your target.
-
toolSchema – The tool schema for the gateway target.
For more information about Lambda targets, see Amazon Lambda function targets.
Select one of the following methods:
Example
Add an API Gateway stage target
To add a stage of an API Gateway REST API as a target, specify the REST API ID and stage name, and define settings to filter tools in the API gateway or to override names and descriptions of tools in the gateway:
The following examples show how to add an API Gateway target. The following configurations are also applied:
-
The tools filtered for are the GET and POST methods for the
/productspath. -
GET /products is renamed as
get_items.
Select one of the following methods:
Example
Add an OpenAPI target
Select one of the following methods:
Example
Add a Smithy target
Select one of the following methods:
Example
Add an HTTP runtime target
You can add an Amazon Bedrock AgentCore Runtime agent as an HTTP target to your gateway. The gateway sends traffic directly to the runtime agent without aggregation or protocol translation.
For more information about HTTP targets, see Amazon Bedrock AgentCore Runtime targets.
Select one of the following methods:
Example
Add an MCP server target
You can add an MCP server target using the AgentCore CLI or Amazon Python SDK (Boto3). The following examples show how to create an MCP server target with different outbound authorization types.
MCP server with IAM (SigV4) authorization
The following example creates an MCP server target with IAM authorization. The gateway signs requests to the MCP server using SigV4 with the gateway service role’s credentials. You must specify the service name for signing. The region is optional and defaults to the gateway’s Region.
The value of service depends on where your MCP server is hosted. The following are common values:
-
bedrock-agentcore– For MCP servers hosted on Amazon Bedrock AgentCore, such as the runtime (see Deploy MCP servers in AgentCore Runtime ) or another gateway. -
execute-api– For MCP servers behind Amazon API Gateway. -
lambda– For MCP servers behind Lambda Function URLs.
Select one of the following methods:
Example
MCP server with OAuth authorization
The following example creates an MCP server target with OAuth (client credentials) authorization.
The OAuth application must support the client_credentials grant. An application configured only for the authorization code (code) grant cannot be used for gateway outbound authorization. For Amazon Cognito, create a resource server scope and configure the app client with --allowed-o-auth-flows client_credentials and that custom scope:
aws cognito-idp create-user-pool-client \ --user-pool-id <USER_POOL_ID> \ --client-name gateway-client \ --generate-secret \ --allowed-o-auth-flows client_credentials \ --allowed-o-auth-scopes "<RESOURCE_SERVER_IDENTIFIER>/<SCOPE_NAME>" \ --allowed-o-auth-flows-user-pool-client \ --supported-identity-providers COGNITO
Select one of the following methods:
Example
MCP server with API key authorization
The following example creates an MCP server target with API key authorization.
Select one of the following methods:
Example
Add a Connector target with Amazon Bedrock Managed Knowledge Bases
You can add the Amazon Bedrock Managed Knowledge Bases connector as a target to your gateway.
For more information about the Amazon Bedrock Managed Knowledge Bases connector, see Amazon Bedrock Managed Knowledge Bases.
Set up a managed knowledge base
The connector exposes two tools, each named after its backend operation: AgenticRetrieveStream (multi-step, streaming agentic retrieval) and Retrieve (a single hybrid search). You add a configuration entry per tool.
For AgenticRetrieveStream, set retrievers (the managed knowledge bases to query) and agenticRetrieveConfiguration in parameterValues. Both are required — omitting agenticRetrieveConfiguration causes a runtime error. It can be an empty object ({}) to accept service-managed defaults, but specifying foundationModelType and rerankingModelType makes the configuration explicit. The agent does not supply knowledge base IDs at call time. For Retrieve, set the knowledgeBaseId in parameterValues; it is required.
The connector supports only managed knowledge bases. Connector targets support only the GATEWAY_IAM_ROLE credential provider type.
Example
After you call CreateGatewayTarget, the Gateway validates the configuration asynchronously (typically within about 30 seconds), which includes a GetKnowledgeBase check on each bound knowledge base. Poll GetGatewayTarget until status is READY; a FAILED status includes a reason describing the problem.
To customize agentic retrieval — for example, to cap planning iterations or attach a guardrail — add the optional fields to agenticRetrieveConfiguration. If you omit them, service-managed defaults apply. For all accepted values, see Configuration reference.
{ "name": "AgenticRetrieveStream", "parameterValues": { "retrievers": [ { "configuration": { "knowledgeBase": { "knowledgeBaseId": "<KB_ID>" } } } ], "agenticRetrieveConfiguration": { "maxAgentIteration": 5, "policyConfiguration": { "guardrailConfiguration": { "guardrailId": "<GUARDRAIL_ID>", "guardrailVersion": "1" } } } } }
Control which parameters the agent can set
Each tool configuration entry accepts two parameter controls that determine what the calling agent sees and what the Gateway sends to the knowledge base:
-
parameterValues— administrator-set values sent to the knowledge base on every call, such as the boundknowledgeBaseIdor a defaultnumberOfResults. These are used unless the agent overrides a field you have exposed. -
parameterOverrides— a list that controls which request fields the agent can see and set at call time. Each entry has:-
path— the field in theRetrieverequest, for example$.retrievalQuery.textor$.retrievalConfiguration.managedSearchConfiguration.numberOfResults. -
description— optional text shown to the agent describing the field. -
visible— set totrueto expose the field to the agent, orfalseto hide it while still sending any administrator-configured default.
-
Bind knowledgeBaseId in parameterValues and do not expose it.
The following configuration entry binds the knowledge base, sets a default of 10 results, and exposes the query text and result count to the agent:
{ "name": "Retrieve", "description": "Search the knowledge base for relevant documents.", "parameterValues": { "knowledgeBaseId": "<KB_ID>", "retrievalConfiguration": { "managedSearchConfiguration": { "numberOfResults": 10 } } }, "parameterOverrides": [ { "path": "$.retrievalQuery.text", "description": "The search query. Use specific keywords for best results.", "visible": true }, { "path": "$.retrievalConfiguration.managedSearchConfiguration.numberOfResults", "description": "Number of results to retrieve (1-100).", "visible": true } ] }
Configure the Gateway Service Role
This connector uses the gateway execution role — the IAM role ARN you pass to CreateGateway, which the AgentCore service assumes to call the backend on your behalf. This is a role you create, not a service-linked role. For the Amazon Bedrock Managed Knowledge Bases connector, it needs the following permissions:
-
bedrock:GetKnowledgeBase— to validate the bound knowledge base when the target is created. Scoped to the managed knowledge base resource. -
bedrock:Retrieve— for theRetrievetool. Scoped to the managed knowledge base resource. -
bedrock:AgenticRetrieveStream— for theAgenticRetrieveStreamtool. This action is not scoped to a managed knowledge base resource, so grant it on*.
The Gateway signs the backend calls as the bedrock service. Include bedrock:GetKnowledgeBase regardless of which tools you add; if you add only one tool, include only that tool’s retrieval action.
Note
bedrock-agentcore:InvokeGateway is not part of the execution role. That permission belongs to the caller — the agent or application invoking the Gateway — not to the role the Gateway assumes.
Add a policy with the following content to the execution role attached to the Gateway:
{ "Version": "2012-10-17", "Statement": [ { "Sid": "ValidateKnowledgeBase", "Effect": "Allow", "Action": "bedrock:GetKnowledgeBase", "Resource": "arn:aws:bedrock:<REGION>:<ACCOUNT_ID>:knowledge-base/<KB_ID>" }, { "Sid": "RetrieveFromKnowledgeBase", "Effect": "Allow", "Action": "bedrock:Retrieve", "Resource": "arn:aws:bedrock:<REGION>:<ACCOUNT_ID>:knowledge-base/<KB_ID>" }, { "Sid": "AgenticRetrieveStream", "Effect": "Allow", "Action": "bedrock:AgenticRetrieveStream", "Resource": "*" } ] }
The service role must also trust the AgentCore service so that it can assume the role. Attach the following trust policy, scoping it to your account and Gateway with the aws:SourceAccount and aws:SourceArn conditions:
{ "Version": "2012-10-17", "Statement": [ { "Sid": "AllowAgentCoreToAssumeRole", "Effect": "Allow", "Principal": { "Service": "bedrock-agentcore.amazonaws.com" }, "Action": "sts:AssumeRole", "Condition": { "StringEquals": { "aws:SourceAccount": "<ACCOUNT_ID>" }, "ArnLike": { "aws:SourceArn": "arn:aws:bedrock-agentcore:<REGION>:<ACCOUNT_ID>:gateway/*" } } } ] }
Add a Connector target with Web Search Tool
You can add a built-in connector as a target to your gateway. The Web Search Tool connector provides managed web search capabilities without requiring custom infrastructure or API keys.
For more information about the Web Search Tool connector, see Web Search Tool.
Set up Web Search Tool
You can optionally pin the target to a specific connector version by including version in the source field. If you omit version, the target uses the connector’s current default version. For more information about connector versions, see Connector versions.
Example
Configure domain filtering
You can restrict which domains the Web Search Tool is allowed to query by configuring a domain include or an exclude list. This is useful for administrators who want to prevent agents from returning results from specific websites.
-
Target-level domain exclude list — A list of domains excluded from all searches on a target, set at target creation using
parameterValues.domainFilter.exclude. The exclude list is enforced server-side and hidden from the calling agent. -
Target-level domain include list (connector version
1.2.0and later) — In addition to the exclude list, you can configureparameterValues.domainFilter.includeto restrict searches to a specific set of domains.
Request-level filters (domain include/exclude and published-date range) are available to the calling agent in connector version 1.2.0 and later. Request-level filters compose with the target-level exclude and include lists: the target-level exclusions and inclusions always apply, and the agent cannot relax them.
The following examples create a Web Search Tool target pinned to version 1.2.0 with both domain include and exclude lists:
Example
You can also update an existing target to add or modify domain filtering using UpdateGatewayTarget.
Configure the Gateway Service Role
The Gateway needs a service role that allows the AgentCore service to perform actions on your behalf. For the Web Search Tool, the role needs the following permissions:
-
bedrock-agentcore:InvokeGateway— to invoke the Gateway -
bedrock-agentcore:InvokeWebSearch— to authorize web search invocations, checked per-request against the service-owned ARNarn:aws:bedrock-agentcore:<region>:aws:tool/web-search.v1
Add a policy with the following content to the service role attached to the Gateway:
{ "Version": "2012-10-17", "Statement": [ { "Sid": "InvokeGateway", "Effect": "Allow", "Action": "bedrock-agentcore:InvokeGateway", "Resource": "arn:aws:bedrock-agentcore:<REGION>:<ACCOUNT_ID>:gateway/*" }, { "Sid": "InvokeWebSearch", "Effect": "Allow", "Action": "bedrock-agentcore:InvokeWebSearch", "Resource": "arn:aws:bedrock-agentcore:<REGION>:aws:tool/web-search.v1" } ] }
Add a Connector target with Web Answer
You can add a built-in connector as a target to your gateway. With the Web Answer connector, your agent can ask a question and get a synthesized answer with citations to web sources, without custom infrastructure, model endpoints, or API keys.
For more information about the Web Answer connector, see Web Answer.
Set up Web Answer
Web Answer is available in US East (N. Virginia) us-east-1. Create the gateway in that Region.
Web Answer uses the connector’s current default version. For more information about connector versions, see Connector versions.
In the following examples, replace <GATEWAY_ID> with the identifier of your gateway.
Example
Wait until GetGatewayTarget reports the target status as READY before you call the tool. The tool appears in tools/list as <target-name>_WebAnswer_WebAnswer.
Configure domain filtering
In connector version 1.1.0 and later, you can restrict the domains that Web Answer uses as sources:
-
Target-level domain exclude list –
parameterValues.domainFilter.exclude, up to 50 domains. Web Answer doesn’t use sources from these domains for any request on the target. -
Target-level domain include list –
parameterValues.domainFilter.include, up to 50 domains. Web Answer uses only sources from these domains.
Web Answer enforces both lists server-side, and your agent can’t see them. Request-level filters from your agent compose with these lists, and your agent can’t relax them. For the merge rules, see Configure domain filtering on the Web Answer page.
The following examples create a Web Answer target with both domain include and exclude lists. Replace <GATEWAY_ID> with the identifier of your gateway, and replace the example domains with your own.
Example
You can also update an existing target to add or modify domain filtering using UpdateGatewayTarget.
Configure the Gateway Service Role
The Gateway needs a service role that allows the AgentCore service to perform actions on your behalf. For Web Answer, the role needs the following permissions:
-
bedrock-agentcore:InvokeGateway— to invoke the Gateway -
bedrock-agentcore:InvokeWebAnswer— to authorize Web Answer invocations, checked per-request against the service-owned ARNarn:aws:bedrock-agentcore:<region>:aws:tool/web-answer.v1
The role doesn’t need bedrock:InvokeModel. Web Answer runs its own model, and your agent’s model runs under your agent’s identity.
The following policy grants the permissions that Web Answer requires. Add it to the service role attached to the Gateway, and replace <ACCOUNT_ID> with your Amazon account ID:
{ "Version": "2012-10-17", "Statement": [ { "Sid": "InvokeGateway", "Effect": "Allow", "Action": "bedrock-agentcore:InvokeGateway", "Resource": "arn:aws:bedrock-agentcore:us-east-1:<ACCOUNT_ID>:gateway/*" }, { "Sid": "InvokeWebAnswer", "Effect": "Allow", "Action": "bedrock-agentcore:InvokeWebAnswer", "Resource": "arn:aws:bedrock-agentcore:us-east-1:aws:tool/web-answer.v1" } ] }
Add a Connector target with Amazon Step Functions
You can add a built-in connector as a target to your gateway. With the Step Functions connector, agents can start, monitor, and stop state machine executions and complete task-token callbacks without any integration code.
For more information about the Step Functions connector, see Amazon Step Functions as Connector Target.
Set up a Step Functions target
In configurations, list each operation you want to expose as a tool. For the four operations that act on a state machine — StartExecution, StartSyncExecution, ListExecutions, and DescribeStateMachine — set parameterValues.stateMachineArn to pin the state machine. Always set this pin. An entry without parameterValues can pass target creation, but its tool fails on every call. The remaining operations take an execution Amazon Resource Name (ARN) or a task token from the agent and have no parameterValues.
You can optionally pin the target to a specific connector version by including version in the source field. If you omit version, the target uses the connector’s current default version. For more information about connector versions, see Connector versions.
The following examples expose a Standard state machine for starting and inspecting executions, and the execution-level operations the agent needs to follow up. In the examples, replace the following values:
-
<ACCOUNT_ID> -
The Amazon account ID that owns the state machine.
-
<GATEWAY_ID> -
The identifier of your gateway.
-
<REGION> -
The Amazon Region of your gateway.
Example
After the target reaches READY, call tools/list on the Gateway. The pinned stateMachineArn doesn’t appear in any tool schema. For example, orders___StartExecution advertises only input.
You can add an Express state machine to the same target for synchronous calls. Add a StartSyncExecution entry pinned to the Express state machine’s ARN. You set pins for each operation, so one target can mix Standard and Express state machines. For which operations work with each workflow type, see Standard and Express workflows.
To expose the task-token operations, add SendTaskSuccess, SendTaskFailure, and SendTaskHeartbeat entries without parameterValues. These operations aren’t scoped to a state machine. Add them once for each gateway, on a separate target, instead of on every target.
To change the pinned state machines or the exposed operations later, call UpdateGatewayTarget with the new configurations list. Existing targets also pick up updated tool descriptions and schemas when you update them.
Configure the Gateway Service Role
The Gateway needs a service role that allows the AgentCore service to call Step Functions on your behalf. Scope the role to the state machines you expose. The policy needs three statements because the Step Functions resource types differ:
-
State-machine operations (
StartExecution,StartSyncExecution,ListExecutions,DescribeStateMachine) are authorized on the state machine ARN. -
Execution operations (
DescribeExecution,StopExecution,GetExecutionHistory) are authorized on the execution ARN, which is a separate resource type. These operations work only with Standard executions. -
Task-token operations (
SendTaskSuccess,SendTaskFailure,SendTaskHeartbeat) have no resource-level permissions in IAM and must be granted on"*".
Each statement in the following policy uses the minimal scope that IAM supports for its operations, following least-privilege guidance:
-
The execution ARN ends in a
*wildcard because Step Functions generates execution names when each execution starts, so you can’t list them in advance. The wildcard covers only executions ofOrderWorkflow, not executions of other state machines. -
The task-token operations are granted on
"*"because IAM doesn’t support resource-level permissions for these actions. A caller also needs a valid task token from one of your executions.
The following JSON policy grants the permissions for all ten connector operations. Attach it to the Gateway’s service role:
{ "Version": "2012-10-17", "Statement": [ { "Sid": "StateMachineOperations", "Effect": "Allow", "Action": [ "states:StartExecution", "states:StartSyncExecution", "states:ListExecutions", "states:DescribeStateMachine" ], "Resource": [ "arn:aws:states:<REGION>:<ACCOUNT_ID>:stateMachine:OrderWorkflow", "arn:aws:states:<REGION>:<ACCOUNT_ID>:stateMachine:OrderLookupExpress" ] }, { "Sid": "ExecutionOperations", "Effect": "Allow", "Action": [ "states:DescribeExecution", "states:StopExecution", "states:GetExecutionHistory" ], "Resource": [ "arn:aws:states:<REGION>:<ACCOUNT_ID>:execution:OrderWorkflow:*" ] }, { "Sid": "TaskTokenOperations", "Effect": "Allow", "Action": [ "states:SendTaskSuccess", "states:SendTaskFailure", "states:SendTaskHeartbeat" ], "Resource": "*" } ] }
In the policy, replace the following values:
-
<ACCOUNT_ID> -
The Amazon account ID that owns the state machines.
-
OrderLookupExpress -
The name of your Express state machine. If you don’t expose an Express state machine, remove its ARN from the policy.
-
OrderWorkflow -
The name of your Standard state machine.
-
<REGION> -
The Amazon Region of your gateway and state machines.
Only the four state-machine operations can be pinned on the target. For the other six, this policy is the only boundary on which executions the agent can inspect, stop, or complete. Don’t grant states:* on Resource: "*". If different workflows need different IAM boundaries, use separate Gateways, because all targets on a Gateway share its service role.
The service role’s trust policy must allow the bedrock-agentcore.amazonaws.com service principal to assume it, as for any Gateway service role. For more information, see Trust permissions.