ToolSchema

class aws_cdk.aws_bedrockagentcore.ToolSchema(s3_file=None, bucket_owner_account_id=None, inline_schema=None)

Bases: object

************************************************************************ TOOL SCHEMA CLASS ***********************************************************************.

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:
  • s3_file (Union[Location, Dict[str, Any], None])

  • bucket_owner_account_id (Optional[str])

  • inline_schema (Optional[Sequence[Union[ToolDefinition, Dict[str, Any]]]])

Methods

abstractmethod bind(scope)

Bind the schema to a construct.

Parameters:

scope (Construct)

Return type:

None

abstractmethod grant_permissions_to_role(role)

Grant permissions to the role.

Parameters:

role (IRole)

Return type:

None

Attributes

bucket_owner_account_id

The account ID of the S3 bucket owner for cross-account access.

inline_schema

The inline tool schema definition as a string, if using an inline schema.

Can be in JSON or YAML format.

s3_file

The S3 location of the tool schema file, if using an S3-based schema.

Contains the bucket name and object key information.

Static Methods

classmethod from_inline(schema)

Creates a Tool Schema from an inline string.

Parameters:

schema (Sequence[Union[ToolDefinition, Dict[str, Any]]]) –

  • the JSON or YAML payload defining the OpenAPI schema for the action group.

Return type:

InlineToolSchema

classmethod from_local_asset(path)

Creates a tool Schema from a local file.

Parameters:

path (str) –

  • the path to the local file containing the function schema for the tool.

Return type:

ToolSchema

classmethod from_s3_file(bucket, object_key, bucket_owner_account_id=None)

Creates a Tool Schema from an S3 File.

Parameters:
  • bucket (IBucket) –

    • the bucket containing the local file containing the OpenAPI schema for the action group.

  • object_key (str) –

    • object key in the bucket.

  • bucket_owner_account_id (Optional[str]) –

    • optional The account ID of the Amazon S3 bucket owner. This ID is used for cross-account access to the bucket.

Return type:

S3ToolSchema