MCP PHP SDK

Schema

Defines a JSON Schema for a method's input or an individual parameter.

When used at the method level, it describes an object schema where properties correspond to the method's parameters.

When used at the parameter level, it describes the schema for that specific parameter. If 'type' is omitted at the parameter level, it will be inferred.

Tags
author

Kyrian Obikwelu koshnawaza@gmail.com

Attributes
#[Attribute]
\Attribute::TARGET_METHOD | \Attribute::TARGET_PARAMETER

Table of Contents

Properties

$additionalProperties  : bool|array<string, mixed>|null
$default  : mixed
$definition  : array<string, mixed>|null
The complete JSON schema array.
$description  : string|null
$enum  : array<int, float|string|int>|null
$exclusiveMaximum  : bool|null
$exclusiveMinimum  : bool|null
$format  : string|null
$items  : array<string, mixed>|null
$maximum  : int|float|null
$maxItems  : int|null
$maxLength  : int|null
$minimum  : int|float|null
$minItems  : int|null
$minLength  : int|null
$multipleOf  : int|float|null
$pattern  : string|null
$properties  : array<string, mixed>|null
$required  : array<int, string>|null
$type  : string|null
Alternatively, provide individual top-level schema keywords.
$uniqueItems  : bool|null

Methods

__construct()  : mixed
toArray()  : SchemaAttributeData
Converts the attribute's definition to a JSON schema array.

Properties

$additionalProperties

public bool|array<string, mixed>|null $additionalProperties = null

$default

public mixed $default = null

$definition

The complete JSON schema array.

public array<string, mixed>|null $definition = null

If provided, it takes precedence over individual properties like $type, $properties, etc.

$description

public string|null $description = null

$enum

public array<int, float|string|int>|null $enum = null

$exclusiveMaximum

public bool|null $exclusiveMaximum = null

$exclusiveMinimum

public bool|null $exclusiveMinimum = null

$format

public string|null $format = null

$items

public array<string, mixed>|null $items = null

$maximum

public int|float|null $maximum = null

$maxItems

public int|null $maxItems = null

$maxLength

public int|null $maxLength = null

$minimum

public int|float|null $minimum = null

$minItems

public int|null $minItems = null

$minLength

public int|null $minLength = null

$multipleOf

public int|float|null $multipleOf = null

$pattern

public string|null $pattern = null

$properties

public array<string, mixed>|null $properties = null

$required

public array<int, string>|null $required = null

$type

Alternatively, provide individual top-level schema keywords.

public string|null $type = null

These are used if $definition is null.

$uniqueItems

public bool|null $uniqueItems = null

Methods

__construct()

public __construct([array<string, mixed>|null $definition = null ][, string|null $type = null ][, string|null $description = null ][, array<int, float|string|int>|null $enum = null ][, string|null $format = null ][, int|null $minLength = null ][, int|null $maxLength = null ][, string|null $pattern = null ][, int|float|null $minimum = null ][, int|float|null $maximum = null ][, bool|null $exclusiveMinimum = null ][, bool|null $exclusiveMaximum = null ][, int|float|null $multipleOf = null ][, array<string, mixed>|null $items = null ][, int|null $minItems = null ][, int|null $maxItems = null ][, bool|null $uniqueItems = null ][, array<string, mixed>|null $properties = null ][, array<int, string>|null $required = null ][, bool|array<string, mixed>|null $additionalProperties = null ]) : mixed
Parameters
$definition : array<string, mixed>|null = null

A complete JSON schema array. If provided, other parameters are ignored.

$type : string|null = null

the JSON schema type

$description : string|null = null

description of the element

$enum : array<int, float|string|int>|null = null

allowed enum values

$format : string|null = null

String format (e.g., 'date-time', 'email').

$minLength : int|null = null

minimum length for strings

$maxLength : int|null = null

maximum length for strings

$pattern : string|null = null

regex pattern for strings

$minimum : int|float|null = null

minimum value for numbers/integers

$maximum : int|float|null = null

maximum value for numbers/integers

$exclusiveMinimum : bool|null = null

exclusive minimum

$exclusiveMaximum : bool|null = null

exclusive maximum

$multipleOf : int|float|null = null

must be a multiple of this value

$items : array<string, mixed>|null = null

JSON Schema for items if type is 'array'

$minItems : int|null = null

minimum items for an array

$maxItems : int|null = null

maximum items for an array

$uniqueItems : bool|null = null

whether array items must be unique

$properties : array<string, mixed>|null = null

Property definitions if type is 'object'. [name => schema_array].

$required : array<int, string>|null = null

list of required properties for an object

$additionalProperties : bool|array<string, mixed>|null = null

policy for additional properties in an object

toArray()

Converts the attribute's definition to a JSON schema array.

public toArray() : SchemaAttributeData
Return values
SchemaAttributeData

        
On this page

Search results