GatewayTarget
- class aws_cdk.aws_bedrock_agentcore_alpha.GatewayTarget(scope, id, *, gateway, target_configuration, credential_provider_configurations=None, gateway_target_name, description=None)
Bases:
GatewayTargetBase(experimental) 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
- See:
- Stability:
experimental
- Resource:
AWS::BedrockAgentCore::GatewayTarget
- ExampleMetadata:
fixture=default infused
Example:
gateway = agentcore.Gateway(self, "MyGateway", gateway_name="my-gateway" ) lambda_function = lambda_.Function(self, "MyFunction", runtime=lambda_.Runtime.NODEJS_22_X, handler="index.handler", code=lambda_.Code.from_inline(""" exports.handler = async (event) => { return { statusCode: 200, body: JSON.stringify({ message: 'Hello from Lambda!' }) }; }; """) ) # Create a gateway target with Lambda and tool schema target = agentcore.GatewayTarget.for_lambda(self, "MyLambdaTarget", gateway_target_name="my-lambda-target", description="Target for Lambda function integration", gateway=gateway, lambda_function=lambda_function, tool_schema=agentcore.ToolSchema.from_local_asset( path.join(__dirname, "schemas", "my-tool-schema.json")) )
- Parameters:
scope (
Construct)id (
str)gateway (
IGateway) – (experimental) The gateway this target belongs to.target_configuration (
ITargetConfiguration) – (experimental) The target configuration (Lambda, OpenAPI, or Smithy) Use one of the configuration helper classes: - LambdaTargetConfiguration.create() - OpenApiTargetConfiguration.create() - SmithyTargetConfiguration.create().credential_provider_configurations (
Optional[Sequence[ICredentialProviderConfig]]) – (experimental) Credential providers for authentication. Default: - [GatewayCredentialProvider.fromIamRole()]gateway_target_name (
str) – (experimental) The name of the gateway target The name must be unique within the gateway Pattern: ^([0-9a-zA-Z][-]?){1,100}$.description (
Optional[str]) – (experimental) Optional description for the gateway target The description can have up to 200 characters. Default: - No description
- Stability:
experimental
Methods
- apply_removal_policy(policy)
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).- Parameters:
policy (
RemovalPolicy)- Return type:
None
- grant(grantee, *actions)
(experimental) Grants IAM actions to the IAM Principal.
- Parameters:
grantee (
IGrantable) – The principal to grant permissions to.actions (
str) – The IAM actions to grant.
- Stability:
experimental
- Return type:
- grant_manage(grantee)
(experimental) Grants
Create,Update, andDeleteactions on the Gateway Target.- Parameters:
grantee (
IGrantable) – The principal to grant manage permissions to.- Stability:
experimental
- Return type:
- grant_read(grantee)
(experimental) Grants
GetandListactions on the Gateway Target.- Parameters:
grantee (
IGrantable) – The principal to grant read permissions to.- Stability:
experimental
- Return type:
- grant_sync(grantee)
(experimental) Grants permission to synchronize this gateway’s targets.
This method grants the
SynchronizeGatewayTargetspermission, which is primarily needed for MCP Server targets when you need to refresh the tool catalog after the MCP server’s tools have changed.- Parameters:
grantee (
IGrantable)- Stability:
experimental
- Return type:
- to_string()
Returns a string representation of this construct.
- Return type:
str
Attributes
- PROPERTY_INJECTION_ID = '@aws-cdk.aws-bedrock-agentcore-alpha.GatewayTarget'
- created_at
(experimental) Timestamp when the gateway target was created.
- Stability:
experimental
- Attribute:
true
- credential_provider_configurations
(experimental) The credential providers for this target.
- Stability:
experimental
- description
(experimental) Optional description for the gateway target.
- Stability:
experimental
- env
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
(experimental) The gateway this target belongs to.
- Stability:
experimental
- name
(experimental) The name of the gateway target.
- Stability:
experimental
- node
The tree node.
- stack
The stack in which this resource is defined.
- status
(experimental) The status of the gateway target.
- Stability:
experimental
- Attribute:
true
- status_reasons
(experimental) The status reasons for the gateway target.
- Stability:
experimental
- Attribute:
true
- target_arn
(experimental) The ARN of the gateway target.
- Stability:
experimental
- Attribute:
true
- target_id
(experimental) The unique identifier of the gateway target.
- Stability:
experimental
- Attribute:
true
- target_protocol_type
(experimental) The protocol type (always MCP for now).
- Stability:
experimental
- target_type
(experimental) The specific MCP target type (Lambda, OpenAPI, Smithy, or MCP Server).
- Stability:
experimental
- updated_at
(experimental) Timestamp when the gateway target was last updated.
- Stability:
experimental
- Attribute:
true
Static Methods
- classmethod for_lambda(scope, id, *, gateway, lambda_function, tool_schema, credential_provider_configurations=None, gateway_target_name, description=None)
(experimental) Create a Lambda-based MCP target Convenience method for creating a target that wraps a Lambda function.
- Parameters:
scope (
Construct) – The construct scope.id (
str) – The construct id.gateway (
IGateway) – (experimental) The gateway this target belongs to.lambda_function (
IFunction) – (experimental) The Lambda function to associate with this target.tool_schema (
ToolSchema) – (experimental) The tool schema defining the available tools.credential_provider_configurations (
Optional[Sequence[ICredentialProviderConfig]]) – (experimental) Credential providers for authentication Lambda targets only support IAM role authentication. Default: - [GatewayCredentialProvider.fromIamRole()]gateway_target_name (
str) – (experimental) The name of the gateway target The name must be unique within the gateway Pattern: ^([0-9a-zA-Z][-]?){1,100}$.description (
Optional[str]) – (experimental) Optional description for the gateway target The description can have up to 200 characters. Default: - No description
- Return type:
- Returns:
A new GatewayTarget instance
- Stability:
experimental
- classmethod for_mcp_server(scope, id, *, credential_provider_configurations, endpoint, gateway, gateway_target_name, description=None)
(experimental) Create an MCP Server-based target Convenience method for creating a target that connects to an external MCP server.
- Parameters:
scope (
Construct) – The construct scope.id (
str) – The construct id.credential_provider_configurations (
Sequence[ICredentialProviderConfig]) – (experimental) Credential providers for authentication.endpoint (
str) – (experimental) The HTTPS endpoint URL of the MCP server. The endpoint must: - Use HTTPS protocol - Be properly URL-encoded - Point to an MCP server that implements tool capabilitiesgateway (
IGateway) – (experimental) The gateway this target belongs to.gateway_target_name (
str) – (experimental) The name of the gateway target The name must be unique within the gateway Pattern: ^([0-9a-zA-Z][-]?){1,100}$.description (
Optional[str]) – (experimental) Optional description for the gateway target The description can have up to 200 characters. Default: - No description
- Return type:
- Returns:
A new GatewayTarget instance
- See:
- Stability:
experimental
- classmethod for_open_api(scope, id, *, api_schema, gateway, credential_provider_configurations=None, validate_open_api_schema=None, gateway_target_name, description=None)
(experimental) Create an OpenAPI-based MCP target Convenience method for creating a target that exposes an OpenAPI/REST API.
- Parameters:
scope (
Construct) – The construct scope.id (
str) – The construct id.api_schema (
ApiSchema) – (experimental) The OpenAPI schema defining the API.gateway (
IGateway) – (experimental) The gateway this target belongs to.credential_provider_configurations (
Optional[Sequence[ICredentialProviderConfig]]) – (experimental) Credential providers for authentication OpenAPI targets support API key and OAuth authentication (not IAM). Default: : If not provided, defaults to IAM role which will fail at runtimevalidate_open_api_schema (
Optional[bool]) – (experimental) Whether to validate the OpenAPI schema (only applies to inline schemas) Note: Validation is only performed for inline schemas during CDK synthesis. S3 and asset-based schemas cannot be validated at synthesis time. Default: truegateway_target_name (
str) – (experimental) The name of the gateway target The name must be unique within the gateway Pattern: ^([0-9a-zA-Z][-]?){1,100}$.description (
Optional[str]) – (experimental) Optional description for the gateway target The description can have up to 200 characters. Default: - No description
- Return type:
- Returns:
A new GatewayTarget instance
- Stability:
experimental
- classmethod for_smithy(scope, id, *, gateway, smithy_model, credential_provider_configurations=None, gateway_target_name, description=None)
(experimental) Create a Smithy-based MCP target Convenience method for creating a target that exposes a Smithy-modeled API.
- Parameters:
scope (
Construct) – The construct scope.id (
str) – The construct id.gateway (
IGateway) – (experimental) The gateway this target belongs to.smithy_model (
ApiSchema) – (experimental) The Smithy model defining the API.credential_provider_configurations (
Optional[Sequence[ICredentialProviderConfig]]) – (experimental) Credential providers for authentication Smithy targets only support IAM role authentication. Default: - [GatewayCredentialProvider.fromIamRole()]gateway_target_name (
str) – (experimental) The name of the gateway target The name must be unique within the gateway Pattern: ^([0-9a-zA-Z][-]?){1,100}$.description (
Optional[str]) – (experimental) Optional description for the gateway target The description can have up to 200 characters. Default: - No description
- Return type:
- Returns:
A new GatewayTarget instance
- Stability:
experimental
- classmethod from_gateway_target_attributes(scope, id, *, gateway, gateway_target_name, target_arn, target_id, created_at=None, status=None, updated_at=None)
(experimental) Import an existing Gateway Target using its attributes This allows you to reference a Gateway Target that was created outside of CDK.
- Parameters:
scope (
Construct) – The construct scope.id (
str) – The construct id.gateway (
IGateway) – (experimental) The gateway this target belongs to.gateway_target_name (
str) – (experimental) The name of the gateway target.target_arn (
str) – (experimental) The ARN of the gateway target.target_id (
str) – (experimental) The ID of the gateway target.created_at (
Optional[str]) – (experimental) Optional creation timestamp. Default: - No creation timestampstatus (
Optional[str]) – (experimental) Optional status of the target. Default: - No statusupdated_at (
Optional[str]) – (experimental) Optional last update timestamp. Default: - No update timestamp
- Return type:
- Returns:
An IGatewayTarget instance representing the imported target
- Stability:
experimental
- classmethod is_construct(x)
Checks if
xis a construct.Use this method instead of
instanceofto properly detectConstructinstances, even when the construct library is symlinked.Explanation: in JavaScript, multiple copies of the
constructslibrary on disk are seen as independent, completely different libraries. As a consequence, the classConstructin each copy of theconstructslibrary is seen as a different class, and an instance of one class will not test asinstanceofthe other class.npm installwill not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of theconstructslibrary can be accidentally installed, andinstanceofwill behave unpredictably. It is safest to avoid usinginstanceof, and using this type-testing method instead.- Parameters:
x (
Any) – Any object.- Return type:
bool- Returns:
true if
xis an object created from a class which extendsConstruct.
- classmethod is_owned_resource(construct)
Returns true if the construct was created by CDK, and false otherwise.
- Parameters:
construct (
IConstruct)- Return type:
bool
- classmethod is_resource(construct)
Check whether the given construct is a Resource.
- Parameters:
construct (
IConstruct)- Return type:
bool