class GatewayTarget (construct)
| Language | Type name |
|---|---|
.NET | Amazon.CDK.AWS.Bedrock.Agentcore.Alpha.GatewayTarget |
Go | github.com/aws/aws-cdk-go/awsbedrockagentcorealpha/v2#GatewayTarget |
Java | software.amazon.awscdk.services.bedrock.agentcore.alpha.GatewayTarget |
Python | aws_cdk.aws_bedrock_agentcore_alpha.GatewayTarget |
TypeScript (source) | @aws-cdk/aws-bedrock-agentcore-alpha ยป GatewayTarget |
Implements
IConstruct, IDependable, IResource, IEnvironment, IGateway, IMcp
Defines tools that your gateway will host.
Supports multiple target types:
- Lambda: Wraps a Lambda function as MCP tools
- OpenAPI: Exposes an OpenAPI/REST API as MCP tools
- Smithy: Exposes a Smithy-modeled API as MCP tools
Example
const gateway = new agentcore.Gateway(this, "MyGateway", {
gatewayName: "my-gateway",
});
const lambdaFunction = new lambda.Function(this, "MyFunction", {
runtime: lambda.Runtime.NODEJS_22_X,
handler: "index.handler",
code: lambda.Code.fromInline(`
exports.handler = async (event) => {
return {
statusCode: 200,
body: JSON.stringify({ message: 'Hello from Lambda!' })
};
};
`),
});
// Create a gateway target with Lambda and tool schema
const target = agentcore.GatewayTarget.forLambda(this, "MyLambdaTarget", {
gatewayTargetName: "my-lambda-target",
description: "Target for Lambda function integration",
gateway: gateway,
lambdaFunction: lambdaFunction,
toolSchema: agentcore.ToolSchema.fromLocalAsset(
path.join(__dirname, "schemas", "my-tool-schema.json")
),
});
Initializer
new GatewayTarget(scope: Construct, id: string, props: GatewayTargetProps)
Parameters
- scope
Construct - id
string - props
GatewayTarget Props
Construct Props
| Name | Type | Description |
|---|---|---|
| gateway | IGateway | The gateway this target belongs to. |
| gateway | string | The name of the gateway target The name must be unique within the gateway Pattern: ^([0-9a-zA-Z][-]?){1,100}$. |
| target | ITarget | The target configuration (Lambda, OpenAPI, or Smithy) Use one of the configuration helper classes: - LambdaTargetConfiguration.create() - OpenApiTargetConfiguration.create() - SmithyTargetConfiguration.create(). |
| credential | ICredential[] | Credential providers for authentication. |
| description? | string | Optional description for the gateway target The description can have up to 200 characters. |
gateway
Type:
IGateway
The gateway this target belongs to.
gatewayTargetName
Type:
string
The name of the gateway target The name must be unique within the gateway Pattern: ^([0-9a-zA-Z][-]?){1,100}$.
targetConfiguration
Type:
ITarget
The target configuration (Lambda, OpenAPI, or Smithy) Use one of the configuration helper classes: - LambdaTargetConfiguration.create() - OpenApiTargetConfiguration.create() - SmithyTargetConfiguration.create().
credentialProviderConfigurations?
Type:
ICredential[]
(optional, default: [GatewayCredentialProvider.fromIamRole()])
Credential providers for authentication.
description?
Type:
string
(optional, default: No description)
Optional description for the gateway target The description can have up to 200 characters.
Properties
| Name | Type | Description |
|---|---|---|
| env | Resource | The environment this resource belongs to. |
| gateway | IGateway | The gateway this target belongs to. |
| name | string | The name of the gateway target. |
| node | Node | The tree node. |
| stack | Stack | The stack in which this resource is defined. |
| target | string | The ARN of the gateway target. |
| target | string | The unique identifier of the gateway target. |
| target | Gateway | The protocol type (always MCP for now). |
| target | Mcp | The specific MCP target type (Lambda, OpenAPI, Smithy, or MCP Server). |
| created | string | Timestamp when the gateway target was created. |
| credential | ICredential[] | The credential providers for this target. |
| description? | string | Optional description for the gateway target. |
| status? | string | The status of the gateway target. |
| status | string[] | The status reasons for the gateway target. |
| updated | string | Timestamp when the gateway target was last updated. |
| static PROPERTY_INJECTION_ID | string | Uniquely identifies this class. |
env
Type:
Resource
The environment this resource belongs to.
For resources that are created and managed in a Stack (those created by
creating new class instances like new Role(), new Bucket(), etc.), this
is always the same as the environment of the stack they belong to.
For referenced resources (those obtained from referencing methods like
Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be
different than the stack they were imported into.
gateway
Type:
IGateway
The gateway this target belongs to.
name
Type:
string
The name of the gateway target.
node
Type:
Node
The tree node.
stack
Type:
Stack
The stack in which this resource is defined.
targetArn
Type:
string
The ARN of the gateway target.
targetId
Type:
string
The unique identifier of the gateway target.
targetProtocolType
Type:
Gateway
The protocol type (always MCP for now).
targetType
Type:
Mcp
The specific MCP target type (Lambda, OpenAPI, Smithy, or MCP Server).
createdAt?
Type:
string
(optional)
Timestamp when the gateway target was created.
credentialProviderConfigurations?
Type:
ICredential[]
(optional)
The credential providers for this target.
description?
Type:
string
(optional)
Optional description for the gateway target.
status?
Type:
string
(optional)
The status of the gateway target.
statusReasons?
Type:
string[]
(optional)
The status reasons for the gateway target.
updatedAt?
Type:
string
(optional)
Timestamp when the gateway target was last updated.
static PROPERTY_INJECTION_ID
Type:
string
Uniquely identifies this class.
Methods
| Name | Description |
|---|---|
| apply | Apply the given removal policy to this resource. |
| grant(grantee, ...actions) | Grants IAM actions to the IAM Principal. |
| grant | Grants Create, Update, and Delete actions on the Gateway Target. |
| grant | Grants Get and List actions on the Gateway Target. |
| grant | Grants permission to synchronize this gateway's targets. |
| to | Returns a string representation of this construct. |
| static for | Create a Lambda-based MCP target Convenience method for creating a target that wraps a Lambda function. |
| static for | Create an MCP Server-based target Convenience method for creating a target that connects to an external MCP server. |
| static for | Create an OpenAPI-based MCP target Convenience method for creating a target that exposes an OpenAPI/REST API. |
| static for | Create a Smithy-based MCP target Convenience method for creating a target that exposes a Smithy-modeled API. |
| static from | Import an existing Gateway Target using its attributes This allows you to reference a Gateway Target that was created outside of CDK. |
applyRemovalPolicy(policy)
public applyRemovalPolicy(policy: RemovalPolicy): void
Parameters
- policy
RemovalPolicy
Apply the given removal policy to this resource.
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.
The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS
account for data recovery and cleanup later (RemovalPolicy.RETAIN).
grant(grantee, ...actions)
public grant(grantee: IGrantable, ...actions: string[]): Grant
Parameters
- grantee
IGrantableโ The principal to grant permissions to. - actions
stringโ The IAM actions to grant.
Returns
Grants IAM actions to the IAM Principal.
grantManage(grantee)
public grantManage(grantee: IGrantable): Grant
Parameters
- grantee
IGrantableโ The principal to grant manage permissions to.
Returns
Grants Create, Update, and Delete actions on the Gateway Target.
grantRead(grantee)
public grantRead(grantee: IGrantable): Grant
Parameters
- grantee
IGrantableโ The principal to grant read permissions to.
Returns
Grants Get and List actions on the Gateway Target.
grantSync(grantee)
public grantSync(grantee: IGrantable): Grant
Parameters
- grantee
IGrantable
Returns
Grants permission to synchronize this gateway's targets.
This method grants the SynchronizeGatewayTargets permission, which is primarily
needed for MCP Server targets when you need to refresh the tool catalog after the
MCP server's tools have changed.
toString()
public toString(): string
Returns
string
Returns a string representation of this construct.
static forLambda(scope, id, props)
public static forLambda(scope: Construct, id: string, props: GatewayTargetLambdaProps): GatewayTarget
Parameters
- scope
Constructโ The construct scope. - id
stringโ The construct id. - props
Gatewayโ The properties for the Lambda target.Target Lambda Props
Returns
Create a Lambda-based MCP target Convenience method for creating a target that wraps a Lambda function.
static forMcpServer(scope, id, props)
public static forMcpServer(scope: Construct, id: string, props: GatewayTargetMcpServerProps): GatewayTarget
Parameters
- scope
Constructโ The construct scope. - id
stringโ The construct id. - props
Gatewayโ The properties for the MCP server target.Target Mcp Server Props
Returns
Create an MCP Server-based target Convenience method for creating a target that connects to an external MCP server.
static forOpenApi(scope, id, props)
public static forOpenApi(scope: Construct, id: string, props: GatewayTargetOpenApiProps): GatewayTarget
Parameters
- scope
Constructโ The construct scope. - id
stringโ The construct id. - props
Gatewayโ The properties for the OpenAPI target.Target Open Api Props
Returns
Create an OpenAPI-based MCP target Convenience method for creating a target that exposes an OpenAPI/REST API.
static forSmithy(scope, id, props)
public static forSmithy(scope: Construct, id: string, props: GatewayTargetSmithyProps): GatewayTarget
Parameters
- scope
Constructโ The construct scope. - id
stringโ The construct id. - props
Gatewayโ The properties for the Smithy target.Target Smithy Props
Returns
Create a Smithy-based MCP target Convenience method for creating a target that exposes a Smithy-modeled API.
static fromGatewayTargetAttributes(scope, id, attrs)
public static fromGatewayTargetAttributes(scope: Construct, id: string, attrs: GatewayTargetAttributes): IGatewayTarget
Parameters
- scope
Constructโ The construct scope. - id
stringโ The construct id. - attrs
Gatewayโ The attributes of the existing Gateway Target.Target Attributes
Returns
Import an existing Gateway Target using its attributes This allows you to reference a Gateway Target that was created outside of CDK.

.NET
Go
Java
Python
TypeScript (