ResourceTemplate implements JsonSerializable
A template description for resources available on the server.
Tags
Table of Contents
Interfaces
- JsonSerializable
Constants
- RESOURCE_NAME_PATTERN : mixed = '/^[a-zA-Z0-9_-]+$/'
- Resource name pattern regex - must contain only alphanumeric characters, underscores, and hyphens.
- URI_TEMPLATE_PATTERN : mixed = '/^[a-zA-Z][a-zA-Z0-9+.-]*:.*{[^{}]+}.*/'
- URI Template pattern regex - requires a valid scheme followed by colon and path with at least one placeholder (RFC 3986).
Properties
- $annotations : Annotations|null
- $description : string|null
- $meta : array<string|int, mixed>|null
- $mimeType : string|null
- $name : string
- $title : string|null
- $uriTemplate : string
Methods
- __construct() : mixed
- fromArray() : self
-
jsonSerialize()
: Annotations, _meta?: array
}
Constants
RESOURCE_NAME_PATTERN
Resource name pattern regex - must contain only alphanumeric characters, underscores, and hyphens.
private
mixed
RESOURCE_NAME_PATTERN
= '/^[a-zA-Z0-9_-]+$/'
URI_TEMPLATE_PATTERN
URI Template pattern regex - requires a valid scheme followed by colon and path with at least one placeholder (RFC 3986).
private
mixed
URI_TEMPLATE_PATTERN
= '/^[a-zA-Z][a-zA-Z0-9+.-]*:.*{[^{}]+}.*/'
Example patterns: file://{path}/contents.txt, db://{table}/{id}, config:{key}, etc.
Properties
$annotations read-only
public
Annotations|null
$annotations
= null
$description read-only
public
string|null
$description
= null
$meta read-only
public
array<string|int, mixed>|null
$meta
= null
$mimeType read-only
public
string|null
$mimeType
= null
$name read-only
public
string
$name
$title read-only
public
string|null
$title
= null
$uriTemplate read-only
public
string
$uriTemplate
Methods
__construct()
public
__construct(string $uriTemplate, string $name[, string|null $title = null ][, string|null $description = null ][, string|null $mimeType = null ][, Annotations|null $annotations = null ][, array<string, mixed>|null $meta = null ]) : mixed
Parameters
- $uriTemplate : string
-
a URI template (according to RFC 6570) that can be used to construct resource URIs
- $name : string
-
a short identifier for this resource template type
- $title : string|null = null
-
optional human-readable title for display in UI
- $description : string|null = null
-
a description to help the LLM understand available resources
- $mimeType : string|null = null
-
the MIME type for all resources that match this template, if uniform
- $annotations : Annotations|null = null
-
optional annotations for the client
- $meta : array<string, mixed>|null = null
-
optional metadata
fromArray()
public
static fromArray(ResourceTemplateData $data) : self
Parameters
- $data : ResourceTemplateData
Return values
selfjsonSerialize()
public
jsonSerialize() : Annotations, _meta?: array}