MCP PHP SDK

ResourceTemplate implements JsonSerializable

A template description for resources available on the server.

Tags
phpstan-import-type

AnnotationsData from Annotations

author

Kyrian Obikwelu koshnawaza@gmail.com

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_TEMPLATE_PATTERN  = '/^[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.

Properties

$annotations  : Annotations|null
$description  : string|null
$meta  : array<string|int, mixed>|null
$mimeType  : string|null
$name  : string
$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.

private mixed URI_TEMPLATE_PATTERN = '/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\/.*{[^{}]+}.*/'

Example patterns: config://{key}, file://{path}/contents.txt, db://{table}/{id}, etc.

Properties

Methods

__construct()

public __construct(string $uriTemplate, string $name[, 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 human-readable name for the type of resource this template refers to. This can be used by clients to populate UI elements.

$description : string|null = null

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 for all resources that match this template. This should only be included if all resources matching this template have the same type.

$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
self

jsonSerialize()

public jsonSerialize() : Annotations, _meta?: array}
Return values
Annotations, _meta?: array}

        
On this page

Search results