ResourceTemplateReference extends ElementReference
Tags
Table of Contents
Properties
- $completionProviders : array<string|int, mixed>
- $handler : Closure|array<string|int, mixed>|string
- $isManual : bool
- $resourceTemplate : ResourceTemplate
- $uriTemplateRegex : string
- $variableNames : array<int, string>
Methods
- __construct() : mixed
- extractVariables() : array<string, mixed>
- formatResult() : array<int, ResourceContents>
- Formats the raw result of a resource read operation into MCP ResourceContent items.
- getVariableNames() : array<int, string>
- matches() : bool
- compileTemplate() : void
Properties
$completionProviders read-only
public
array<string|int, mixed>
$completionProviders
= []
$handler read-only
public
Closure|array<string|int, mixed>|string
$handler
$isManual read-only
public
bool
$isManual
= false
$resourceTemplate read-only
public
ResourceTemplate
$resourceTemplate
$uriTemplateRegex
private
string
$uriTemplateRegex
$variableNames
private
array<int, string>
$variableNames
Methods
__construct()
public
__construct(ResourceTemplate $resourceTemplate, Handler $handler[, bool $isManual = false ][, array<string, class-string|object> $completionProviders = [] ]) : mixed
Parameters
- $resourceTemplate : ResourceTemplate
- $handler : Handler
- $isManual : bool = false
- $completionProviders : array<string, class-string|object> = []
extractVariables()
public
extractVariables(string $uri) : array<string, mixed>
Parameters
- $uri : string
Return values
array<string, mixed>formatResult()
Formats the raw result of a resource read operation into MCP ResourceContent items.
public
formatResult(mixed $readResult, string $uri[, string|null $mimeType = null ]) : array<int, ResourceContents>
Parameters
- $readResult : mixed
-
the raw result from the resource handler method
- $uri : string
-
the URI of the resource that was read
- $mimeType : string|null = null
Return values
array<int, ResourceContents> —array of ResourceContents objects
Supported result types:
- ResourceContents: Used as-is
- EmbeddedResource: Resource is extracted from the EmbeddedResource
- string: Converted to text content with guessed or provided MIME type
- stream resource: Read and converted to blob with provided MIME type
- array with 'blob' key: Used as blob content
- array with 'text' key: Used as text content
- SplFileInfo: Read and converted to blob
- array: Converted to JSON if MIME type is application/json or contains 'json' For other MIME types, will try to convert to JSON with a warning
getVariableNames()
public
getVariableNames() : array<int, string>
Return values
array<int, string>matches()
public
matches(string $uri) : bool
Parameters
- $uri : string
Return values
boolcompileTemplate()
private
compileTemplate() : void