InlineToolSchema Class
Class to define a Tool Schema from an inline string.
The schema can be provided directly as a string in either JSON or YAML format.
Example
ts
const toolSchema = agentcore.ToolSchema.fromInline([{
name: "hello_world",
description: "A simple hello world tool",
inputSchema: {
type: agentcore.SchemaDefinitionType.OBJECT,
properties: {
name: {
type: agentcore.SchemaDefinitionType.STRING,
description: "The name to greet",
},
},
required: ["name"],
},
}]);
python
tool_schema = agentcore.ToolSchema.from_inline([
name="hello_world",
description="A simple hello world tool",
input_schema=agentcore.SchemaDefinition(
type=agentcore.SchemaDefinitionType.OBJECT,
properties={
"name": agentcore.SchemaDefinition(
type=agentcore.SchemaDefinitionType.STRING,
description="The name to greet"
)
},
required=["name"]
)
])
java
InlineToolSchema toolSchema = ToolSchema.fromInline(List.of(ToolDefinition.builder()
.name("hello_world")
.description("A simple hello world tool")
.inputSchema(SchemaDefinition.builder()
.type(SchemaDefinitionType.OBJECT)
.properties(Map.of(
"name", SchemaDefinition.builder()
.type(SchemaDefinitionType.STRING)
.description("The name to greet")
.build()))
.required(List.of("name"))
.build())
.build()));
csharp
// Install: dotnet add package Amazon.CDK.Lib
var toolSchema = ToolSchema.FromInline(new [] { new ToolDefinition {
Name = "hello_world",
Description = "A simple hello world tool",
InputSchema = new SchemaDefinition {
Type = SchemaDefinitionType.OBJECT,
Properties = new Dictionary<string, SchemaDefinition> {
{ "name", new SchemaDefinition {
Type = SchemaDefinitionType.STRING,
Description = "The name to greet"
} }
},
Required = new [] { "name" }
}
} });
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
toolSchema := agentcore.ToolSchema_FromInline([]ToolDefinition{
&ToolDefinition{
Name: jsii.String("hello_world"),
Description: jsii.String("A simple hello world tool"),
InputSchema: &SchemaDefinition{
Type: agentcore.SchemaDefinitionType_OBJECT(),
Properties: map[string]SchemaDefinition{
"name": &SchemaDefinition{
"type": agentcore.SchemaDefinitionType_STRING(),
"description": jsii.String("The name to greet"),
},
},
Required: []*string{
jsii.String("name"),
},
},
},
})
Initializer
ts
new InlineToolSchema(schema: ToolDefinition[])
python
InlineToolSchema(schema: typing.List[ToolDefinition])
java
new InlineToolSchema(List<ToolDefinition> schema)
csharp
new InlineToolSchema(ToolDefinition[] schema)
go
NewInlineToolSchema(Schema *[]ToolDefinition)
Properties
bucketOwnerAccountIdmay be undefinedstringbucket_owner_account_idmay be undefinedstrbucketOwnerAccountIdmay be undefinedStringBucketOwnerAccountIdmay be undefinedstringBucketOwnerAccountIdmay be undefined*string#The account ID of the S3 bucket owner for cross-account access.
inlineSchemamay be undefinedToolDefinition[]inline_schemamay be undefinedtyping.List[ToolDefinition]inlineSchemamay be undefinedList<ToolDefinition>InlineSchemamay be undefinedToolDefinition[]InlineSchemamay be undefined*[]ToolDefinition#The inline tool schema definition as a string, if using an inline schema.
Can be in JSON or YAML format.
Methods
bind(scope: Construct): voiddef bind(self, scope: Construct) -> Nonepublic void bind(Construct scope)public void Bind(Construct scope)func Bind(Scope Construct)#Bind the schema to a construct.
fromInline(schema: ToolDefinition[]): InlineToolSchema // chainable@staticmethod def from_inline(schema: typing.List[ToolDefinition]) -> InlineToolSchemapublic static InlineToolSchema fromInline(List<ToolDefinition> schema)public static InlineToolSchema FromInline(ToolDefinition[] schema)func FromInline(Schema *[]ToolDefinition) InlineToolSchemastatic#Creates a Tool Schema from an inline string.
1 parameter
Parameters
schemaschemaschemaschemaSchema— - the JSON or YAML payload defining the OpenAPI schema for the action group.
fromLocalAsset(path: string): ToolSchema@staticmethod def from_local_asset(path: str) -> ToolSchemapublic static ToolSchema fromLocalAsset(String path)public static ToolSchema FromLocalAsset(string path)func FromLocalAsset(Path *string) ToolSchemastatic#Creates a tool Schema from a local file.
1 parameter
Parameters
pathpathpathpathPath— - the path to the local file containing the function schema for the tool.
fromS3File(bucket: IBucket, objectKey: string, bucketOwnerAccountId?: string): S3ToolSchema@staticmethod def from_s3_file(bucket: IBucket, object_key: str, bucket_owner_account_id: typing.Optional[str] = None) -> S3ToolSchemapublic static S3ToolSchema fromS3File(IBucket bucket, String objectKey, String bucketOwnerAccountId)public static S3ToolSchema FromS3File(IBucket bucket, string objectKey, string? bucketOwnerAccountId = null)func FromS3File(Bucket IBucket, ObjectKey *string, BucketOwnerAccountId *string) S3ToolSchemastatic#Creates a Tool Schema from an S3 File.
3 parameters
Parameters
bucketbucketbucketbucketBucket— - the bucket containing the local file containing the OpenAPI schema for the action group.objectKeyobject_keyobjectKeyobjectKeyObjectKey— - object key in the bucket.bucketOwnerAccountIdbucket_owner_account_idbucketOwnerAccountIdbucketOwnerAccountIdBucketOwnerAccountId— - optional The account ID of the Amazon S3 bucket owner.