Describe the JSON schema of a value: a parameter of a tool in
@mcpType, the structured result of a tool in @mcpOutput, or a field
of a form in input_form(). Forms take strings, numbers, integers,
booleans and choices, single or as an array.
Usage
type_string(
pattern = NULL,
format = NULL,
min_length = NULL,
max_length = NULL,
required = TRUE,
description = NULL
)
type_integer(min = NULL, max = NULL, required = TRUE, description = NULL)
type_number(min = NULL, max = NULL, required = TRUE, description = NULL)
type_boolean(required = TRUE, description = NULL)
type_enum(
values,
titles = NULL,
required = TRUE,
description = NULL,
enum_names = FALSE
)
type_array(
items,
min_items = NULL,
max_items = NULL,
required = TRUE,
description = NULL
)
type_object(..., .required = TRUE, .description = NULL)Arguments
- pattern
A regular expression the string must match.
- format
"email","uri","date"or"date-time".- min_length, max_length
Bounds on the number of characters.
- required
Whether the value must be given.
- description
The description of the value, for the model or the user.
- min, max
Bounds on the value.
- values
The values to choose from.
- titles
The titles shown for the values, one per value.
- enum_names
Whether to write the titles in the deprecated
enumNamesrather thanoneOf, for the clients that read only it.- items
The type of each item.
- min_items, max_items
Bounds on the number of items.
- ...
The fields of the object, named, made by the
type_*()functions.- .required, .description
requiredanddescriptionof the object.
Examples
type_string(
max_length = 80
)$schema
#> $type
#> [1] "string"
#>
#> $maxLength
#> [1] 80
#>
type_object(
year = type_integer(
min = 2015
),
type = type_enum(
c(
"long",
"interval"
),
required = FALSE
)
)$schema
#> $type
#> [1] "object"
#>
#> $properties
#> $properties$year
#> $properties$year$type
#> [1] "integer"
#>
#> $properties$year$minimum
#> [1] 2015
#>
#>
#> $properties$type
#> $properties$type$type
#> [1] "string"
#>
#> $properties$type$enum
#> $properties$type$enum[[1]]
#> [1] "long"
#>
#> $properties$type$enum[[2]]
#> [1] "interval"
#>
#>
#>
#>
#> $required
#> $required[[1]]
#> [1] "year"
#>
#>
#> $additionalProperties
#> [1] FALSE
#>