ResourceDefinition implements JsonSerializable
A known resource that the server is capable of reading.
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_PATTERN : mixed = '/^[a-zA-Z][a-zA-Z0-9+.-]*:[^\s]*$/'
- URI pattern regex - requires a valid scheme followed by colon and optional path (RFC 3986).
Properties
- $annotations : Annotations|null
- $description : string|null
- $icons : array<string|int, mixed>|null
- $meta : array<string|int, mixed>|null
- $mimeType : string|null
- $name : string
- $size : int|null
- $title : string|null
- $uri : string
Methods
- __construct() : mixed
- fromArray() : self
-
jsonSerialize()
: Icon[], _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_PATTERN
URI pattern regex - requires a valid scheme followed by colon and optional path (RFC 3986).
private
mixed
URI_PATTERN
= '/^[a-zA-Z][a-zA-Z0-9+.-]*:[^\s]*$/'
Example patterns: file://path, db://table, urn:isbn:123, config:key, etc.
Properties
$annotations read-only
public
Annotations|null
$annotations
= null
$description read-only
public
string|null
$description
= null
$icons read-only
public
array<string|int, mixed>|null
$icons
= 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
$size read-only
public
int|null
$size
= null
$title read-only
public
string|null
$title
= null
$uri read-only
public
string
$uri
Methods
__construct()
public
__construct(string $uri, string $name[, string|null $title = null ][, string|null $description = null ][, string|null $mimeType = null ][, Annotations|null $annotations = null ][, int|null $size = null ][, array<string|int, Icon>|null $icons = null ][, array<string, mixed>|null $meta = null ]) : mixed
Parameters
- $uri : string
-
the URI of this resource
- $name : string
-
a short identifier for this resource
- $title : string|null = null
-
optional human-readable title for display in UI
- $description : string|null = null
-
A description of what this resource represents. This can be used by clients to improve the LLM's understanding of available resources.
- $mimeType : string|null = null
-
the MIME type of this resource, if known
- $annotations : Annotations|null = null
-
optional annotations for the client
- $size : int|null = null
-
the size of the raw resource content, in bytes (before base64 encoding or any tokenization), if known
- $icons : array<string|int, Icon>|null = null
-
optional icons representing the resource
- $meta : array<string, mixed>|null = null
-
optional metadata
fromArray()
public
static fromArray(ResourceDefinitionData $data) : self
Parameters
- $data : ResourceDefinitionData
Return values
selfjsonSerialize()
public
jsonSerialize() : Icon[], _meta?: array}