MCP PHP SDK

DiscoveryState

FinalYes

Represents the state of discovered MCP capabilities.

This class encapsulates all discovered elements (tools, resources, prompts, resource templates) and provides methods to apply this state to a registry.

Tags
author

Xentixar xentixar@gmail.com

Table of Contents

Properties

$prompts  : array<string|int, mixed>
$resources  : array<string|int, mixed>
$resourceTemplates  : array<string|int, mixed>
$tools  : array<string|int, mixed>

Methods

__construct()  : mixed
getElementCount()  : int
Get the total count of discovered elements.
getElementCounts()  : array{tools: int, resources: int, prompts: int, resourceTemplates: int}
Get a breakdown of discovered elements by type.
getPrompts()  : array<string, PromptReference>
getResources()  : array<string, ResourceReference>
getResourceTemplates()  : array<string, ResourceTemplateReference>
getTools()  : array<string, ToolReference>
isEmpty()  : bool
Check if this state contains any discovered elements.
obsoletedBy()  : self
Returns the subset of this state whose keys are absent from $next.

Properties

$prompts read-only

private array<string|int, mixed> $prompts = []

$resources read-only

private array<string|int, mixed> $resources = []

$resourceTemplates read-only

private array<string|int, mixed> $resourceTemplates = []

Methods

__construct()

public __construct([array<string, ToolReference$tools = [] ][, array<string, ResourceReference$resources = [] ][, array<string, PromptReference$prompts = [] ][, array<string, ResourceTemplateReference$resourceTemplates = [] ]) : mixed
Parameters
$tools : array<string, ToolReference> = []
$resources : array<string, ResourceReference> = []
$prompts : array<string, PromptReference> = []
$resourceTemplates : array<string, ResourceTemplateReference> = []

getElementCount()

Get the total count of discovered elements.

public getElementCount() : int
Return values
int

getElementCounts()

Get a breakdown of discovered elements by type.

public getElementCounts() : array{tools: int, resources: int, prompts: int, resourceTemplates: int}
Return values
array{tools: int, resources: int, prompts: int, resourceTemplates: int}

isEmpty()

Check if this state contains any discovered elements.

public isEmpty() : bool
Return values
bool

obsoletedBy()

Returns the subset of this state whose keys are absent from $next.

public obsoletedBy(self $next) : self

Asymmetric by design: entries whose keys exist in both states are excluded regardless of value. Used to identify owned entries that a fresh discovery no longer produces.

Parameters
$next : self
Return values
self
On this page

Search results