Skip to content
v2.274.0

SchemaDefinition Struct ​

Schema definition for tool input/output.

Example ​

ts
// Create a gateway first
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!' })
      };
    };
  `),
});

const lambdaTarget = gateway.addLambdaTarget("MyLambdaTarget", {
  gatewayTargetName: "my-lambda-target",
  description: "Lambda function target",
  lambdaFunction: lambdaFunction,
  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"],
      },
    },
  ]),
});

Properties ​

descriptionoptionalstringdescriptionoptionalstrdescriptionoptionalStringDescriptionoptionalstringDescriptionoptional*string#
The description of the schema definition.

Default: No description

This description provides information about the purpose and usage of the schema.

itemsoptionalSchemaDefinitionitemsoptionalSchemaDefinitionitemsoptionalSchemaDefinitionItemsoptionalSchemaDefinitionItemsoptionalSchemaDefinition#
The items in the schema definition.

Default: No items definition

This field is used for array types to define the structure of the array elements.

propertiesoptional{ [key: string]: SchemaDefinition }propertiesoptionaltyping.Mapping[str, SchemaDefinition]propertiesoptionalMap<String, SchemaDefinition>PropertiesoptionalIDictionary<string, SchemaDefinition>Propertiesoptional*map[string]SchemaDefinition#
The properties of the schema definition.

Default: No properties

These properties define the fields in the schema.

requiredoptionalstring[]requiredoptionaltyping.List[str]requiredoptionalList<String>Requiredoptionalstring[]Requiredoptional*[]*string#
The required fields in the schema definition.

Default: No required fields

These fields must be provided when using the schema.

The type of the schema definition.

This field specifies the data type of the schema.