By Abhijith N M · Reviewed 24 October 2026 · Editorial standards
You have an agent that needs to call tools. Those tools live behind a Lambda or SaaS API. You need a way to expose them to the agent, control who can call them, and handle authentication in both directions. That's what a gateway does.
First, create the gateway with an inbound authorizer—who's allowed to call it. Second, add targets—typically Lambdas—with tool schemas describing what each tool accepts. Third, point your agent's MCP client at the gateway URL and let it discover and invoke tools.
The field names and shapes below come from the bedrock-agentcore-control API. Check the API reference for your SDK version to confirm they haven't shifted.
import boto3
ctl = boto3.client("bedrock-agentcore-control", region_name="us-west-2")
gw = ctl.create_gateway(
name="support-gateway",
roleArn="arn:aws:iam::123456789012:role/GatewayRole",
protocolType="MCP",
authorizerType="CUSTOM_JWT", # inbound auth via your IdP
authorizerConfiguration={"customJWTAuthorizer": {
"discoveryUrl": "https://idp.example.com/.well-known/openid-configuration",
"allowedClients": ["my-web-app"],
}},
)
ctl.create_gateway_target(
gatewayIdentifier=gw["gatewayId"],
name="OrderTools",
targetConfiguration={"mcp": {"lambda": {
"lambdaArn": "arn:aws:lambda:us-west-2:123456789012:function:orders",
"toolSchema": {"inlinePayload": [{
"name": "get_order_status",
"description": "Look up the status of an order by id",
"inputSchema": {"type": "object",
"properties": {"order_id": {"type": "string"}},
"required": ["order_id"]},
}]},
}}},
credentialProviderConfigurations=[{"credentialProviderType": "GATEWAY_IAM_ROLE"}],
)
The gateway uses MCP (Model Context Protocol) and requires an inbound authorizer. In this example, that's a custom JWT from your identity provider. You specify the discovery URL so the gateway can fetch public keys and validate tokens from callers.
The target is a Lambda function. You give it a tool schema inline—the name, description, and input shape for each tool it exposes. The gateway will use the IAM role attached to it to invoke the Lambda when an agent makes a tool call.
Multiple targets can coexist on one gateway. If two targets both have a tool called 'search', the gateway namespaces them so there's no collision.
Under the hood, agents communicate with the gateway using JSON-RPC over MCP. They first discover what tools are available, then call specific tools by name with arguments.
// discover tools
{"jsonrpc": "2.0", "id": 1, "method": "tools/list"}
// call one
{"jsonrpc": "2.0", "id": 2, "method": "tools/call",
"params": {"name": "OrderTools___get_order_status",
"arguments": {"order_id": "4521"}}}
Notice the tool name includes the target name: 'OrderTools___get_order_status'. This prevents naming collisions across targets. Most frameworks—Strands, LangGraph, the MCP Python SDK—hide this detail. You just give them the gateway URL and a bearer token, and they handle the JSON-RPC plumbing.
Inbound authentication answers: who is allowed to call the gateway. This can be JWT from your identity provider or IAM credentials. Outbound authentication answers: how does the gateway call the target. For Lambda, it's the IAM role attached to the gateway. For SaaS APIs, it's OAuth or an API key stored in the token vault.
These are separate concerns. Your agent might authenticate with JWT, but the gateway authenticates to Lambda with IAM. Each link in the chain has its own credentials.
Written and edited by the nexGenCoders team. Spotted a mistake? Tell us and we will fix it.
Don't lose this lesson
Create a free account to save your progress, keep your streak, and work toward a shareable certificate.