MCP PHP SDK

ReferenceHandler implements ReferenceHandlerInterface

FinalYes
Tags
author

Kyrian Obikwelu koshnawaza@gmail.com

Table of Contents

Interfaces

ReferenceHandlerInterface
Interface for handling execution of MCP elements.

Properties

$container  : ContainerInterface|null

Methods

__construct()  : mixed
handle()  : mixed
Handles execution of an MCP element reference.
castArgumentType()  : mixed
Attempts type casting based on ReflectionParameter type hints.
castToArray()  : array<int, mixed>
Helper to cast strictly to array.
castToBoolean()  : bool
Helper to cast strictly to boolean.
castToFloat()  : float
Helper to cast strictly to float.
castToInt()  : int
Helper to cast strictly to integer.
getClassInstance()  : object
getReflectionForCallable()  : ReflectionMethod|ReflectionFunction
Gets a ReflectionMethod or ReflectionFunction for a callable.
prepareArguments()  : array<int, mixed>

Properties

Methods

__construct()

public __construct([ContainerInterface|null $container = null ]) : mixed
Parameters
$container : ContainerInterface|null = null

handle()

Handles execution of an MCP element reference.

public handle(ElementReference $reference, array<string, mixed> $arguments) : mixed
Parameters
$reference : ElementReference

the element reference to execute

$arguments : array<string, mixed>
Return values
mixed

the result of the element execution

castArgumentType()

Attempts type casting based on ReflectionParameter type hints.

private castArgumentType(mixed $argument, ReflectionParameter $parameter) : mixed
Parameters
$argument : mixed
$parameter : ReflectionParameter
Tags
throws
InvalidArgumentException

if casting is impossible for the required type

castToArray()

Helper to cast strictly to array.

private castToArray(mixed $argument) : array<int, mixed>
Parameters
$argument : mixed
Return values
array<int, mixed>

castToBoolean()

Helper to cast strictly to boolean.

private castToBoolean(mixed $argument) : bool
Parameters
$argument : mixed
Return values
bool

castToFloat()

Helper to cast strictly to float.

private castToFloat(mixed $argument) : float
Parameters
$argument : mixed
Return values
float

castToInt()

Helper to cast strictly to integer.

private castToInt(mixed $argument) : int
Parameters
$argument : mixed
Return values
int

getClassInstance()

private getClassInstance(string $className) : object
Parameters
$className : string
Return values
object

getReflectionForCallable()

Gets a ReflectionMethod or ReflectionFunction for a callable.

private getReflectionForCallable(callable $handler, SessionInterface $session) : ReflectionMethod|ReflectionFunction
Parameters
$handler : callable
$session : SessionInterface
Return values
ReflectionMethod|ReflectionFunction

prepareArguments()

private prepareArguments(ReflectionFunctionAbstract $reflection, array<string, mixed> $arguments) : array<int, mixed>
Parameters
$reflection : ReflectionFunctionAbstract
$arguments : array<string, mixed>
Return values
array<int, mixed>

        
On this page

Search results