Resource implements JsonSerializable
A known resource that the server is capable of reading.
Tags
Table of Contents
Interfaces
- JsonSerializable
Constants
- RESOURCE_NAME_PATTERN = '/^[a-zA-Z0-9_-]+$/'
- Resource name pattern regex - must contain only alphanumeric characters, underscores, and hyphens.
- URI_PATTERN = '/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\/[^\s]*$/'
- URI pattern regex - requires a valid scheme, followed by colon and optional path.
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
- $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.
private
mixed
URI_PATTERN
= '/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\/[^\s]*$/'
Example patterns: config://, file://path, db://table, 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
$uri read-only
public
string
$uri
Methods
__construct()
public
__construct(string $uri, string $name[, 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 human-readable name for this resource. This can be used by clients to populate UI elements.
- $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. It can be thought of like a "hint" to the model.
- $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 (i.e., 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
This can be used by Hosts to display file sizes and estimate context window usage
fromArray()
public
static fromArray(ResourceData $data) : self
Parameters
- $data : ResourceData
Return values
selfjsonSerialize()
public
jsonSerialize() : Icon[], _meta?: array}