class ToolSchema
| Language | Type name |
|---|---|
.NET | Amazon.CDK.AWS.Bedrock.Agentcore.Alpha.ToolSchema |
Go | github.com/aws/aws-cdk-go/awsbedrockagentcorealpha/v2#ToolSchema |
Java | software.amazon.awscdk.services.bedrock.agentcore.alpha.ToolSchema |
Python | aws_cdk.aws_bedrock_agentcore_alpha.ToolSchema |
TypeScript (source) | @aws-cdk/aws-bedrock-agentcore-alpha ยป ToolSchema |
Implemented by
Asset, Inline, S3
**************************************************************************** TOOL SCHEMA CLASS ***************************************************************************.
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 (protected)
super(s3File?: Location, bucketOwnerAccountId?: string, inlineSchema?: ToolDefinition[])
Parameters
- s3File
Location - bucketOwnerAccountId
string - inlineSchema
ToolDefinition []
Properties
| Name | Type | Description |
|---|---|---|
| bucket | string | The account ID of the S3 bucket owner for cross-account access. |
| inline | Tool[] | The inline tool schema definition as a string, if using an inline schema. |
| s3 | Location | The S3 location of the tool schema file, if using an S3-based schema. |
bucketOwnerAccountId?
Type:
string
(optional)
The account ID of the S3 bucket owner for cross-account access.
inlineSchema?
Type:
Tool[]
(optional)
The inline tool schema definition as a string, if using an inline schema.
Can be in JSON or YAML format.
s3File?
Type:
Location
(optional)
The S3 location of the tool schema file, if using an S3-based schema.
Contains the bucket name and object key information.
Methods
| Name | Description |
|---|---|
| bind(scope) | Bind the schema to a construct. |
| grant | Grant permissions to the role. |
| static from | Creates a Tool Schema from an inline string. |
| static from | Creates a tool Schema from a local file. |
| static from | Creates a Tool Schema from an S3 File. |
bind(scope)
public bind(scope: Construct): void
Parameters
- scope
Construct
Bind the schema to a construct.
grantPermissionsToRole(role)
public grantPermissionsToRole(role: IRole): void
Parameters
- role
IRole
Grant permissions to the role.
static fromInline(schema)
public static fromInline(schema: ToolDefinition[]): InlineToolSchema
Parameters
- schema
ToolDefinition []โ - the JSON or YAML payload defining the OpenAPI schema for the action group.
Returns
Creates a Tool Schema from an inline string.
static fromLocalAsset(path)
public static fromLocalAsset(path: string): ToolSchema
Parameters
- path
stringโ - the path to the local file containing the function schema for the tool.
Returns
Creates a tool Schema from a local file.
static fromS3File(bucket, objectKey, bucketOwnerAccountId?)
public static fromS3File(bucket: IBucket, objectKey: string, bucketOwnerAccountId?: string): S3ToolSchema
Parameters
- bucket
IBucketโ - the bucket containing the local file containing the OpenAPI schema for the action group. - objectKey
stringโ - object key in the bucket. - bucketOwnerAccountId
stringโ - optional The account ID of the Amazon S3 bucket owner.
Returns
Creates a Tool Schema from an S3 File.

.NET
Go
Java
Python
TypeScript (