MCP PHP SDK

ToolCatalog

FinalYes

What the client remembers from `tools/list` in order to send correct headers.

Mirroring an argument into Mcp-Param-* needs the tool's x-mcp-header annotations, which only the listing carries — by the time tools/call is built the schema is gone unless something kept it.

Keeping it here is also where SEP-2243's client-side obligation lands: a tool whose annotations are malformed is dropped rather than called, because the client cannot produce the headers such a tool demands. One bad definition removes that tool and nothing else — a server with ten good tools and one broken one stays usable.

Tags
author

Christopher Hertel mail@christopher-hertel.de

Table of Contents

Properties

$logger  : LoggerInterface
$rejected  : array<string, string>
$schemas  : array<string, array<string, mixed>>

Methods

__construct()  : mixed
headersFor()  : array<string, string>
The `Mcp-Param-*` headers a call to $name must carry, given its arguments.
isRejected()  : bool
Whether the client refuses to call this tool.
reasonFor()  : string|null
record()  : array<int, array<string, mixed>>
Records a listing page and returns the tools a caller may actually use.
annotations()  : array<string, array<int, string>>
Every `x-mcp-header` annotation in $schema, as header name to the property path it mirrors.
valueAt()  : mixed

Properties

$logger read-only

private LoggerInterface $logger = new NullLogger()

$rejected

private array<string, string> $rejected = []

tool name to the reason it was refused

$schemas

private array<string, array<string, mixed>> $schemas = []

tool name to input schema

Methods

__construct()

public __construct([LoggerInterface $logger = new NullLogger() ]) : mixed
Parameters
$logger : LoggerInterface = new NullLogger()

headersFor()

The `Mcp-Param-*` headers a call to $name must carry, given its arguments.

public headersFor(string $name, array<string, mixed> $arguments) : array<string, string>

An argument that is absent or null contributes no header — the specification reads a missing header as a missing value, so sending an empty one would assert something different.

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

isRejected()

Whether the client refuses to call this tool.

public isRejected(string $name) : bool

Only a tool that was listed and failed validation is refused; an unknown name is not, since the client may legitimately call a tool it never listed and the server is the authority on whether it exists.

Parameters
$name : string
Return values
bool

reasonFor()

public reasonFor(string $name) : string|null
Parameters
$name : string
Return values
string|null

record()

Records a listing page and returns the tools a caller may actually use.

public record(array<int, array<string, mixed>> $tools) : array<int, array<string, mixed>>

A tool whose annotations are malformed is dropped from the result, which is how the client "rejects" it: it never reaches the caller, so it cannot be called, and the tools listed beside it are untouched.

Parameters
$tools : array<int, array<string, mixed>>

raw tools/list entries

Return values
array<int, array<string, mixed>>

annotations()

Every `x-mcp-header` annotation in $schema, as header name to the property path it mirrors.

private static annotations(array<string, mixed> $schema[, array<int, string> $path = [] ]) : array<string, array<int, string>>

Only statically reachable properties count, matching the server's reader: a chain through items, a composition keyword or a $ref cannot be resolved without the instance, so an annotation there is out of bounds.

Parameters
$schema : array<string, mixed>
$path : array<int, string> = []
Return values
array<string, array<int, string>>

valueAt()

private static valueAt(array<string, mixed> $arguments, array<int, string> $path) : mixed
Parameters
$arguments : array<string, mixed>
$path : array<int, string>
On this page

Search results