MCP PHP SDK

ServerExtensionInterface extends ExtensionInterface

An extension that answers the methods it defines when enabled on a server.

Tags
author

Christopher Hertel mail@christopher-hertel.de

Table of Contents

Methods

getCapabilities()  : array<string, mixed>
The capability payload announced for this extension.
getId()  : ExtensionIdentifier
The reverse-DNS identifier used as the key under `capabilities.extensions`.
getMessages()  : array<int, Request>|Notification>>
Every message class this extension defines.
getRequestHandlers()  : iterable<string|int, RequestHandlerInterface<string|int, ResultInterface>>
The handlers serving the methods of {@see self::getMessages()}.

Methods

getCapabilities()

The capability payload announced for this extension.

public getCapabilities() : array<string, mixed>

The returned array is cast to an object and embedded under capabilities.extensions[<id>], so every value must be JSON-serializable (scalars, arrays, or JsonSerializable objects).

Return values
array<string, mixed>

getMessages()

Every message class this extension defines.

public getMessages() : array<int, Request>|Notification>>

These are registered with the MessageFactory, without which an extension's method cannot be decoded off the wire at all, and their method names are what let a server distinguish an extension it does not serve from a method that does not exist. An extension with no methods of its own returns an empty array.

Return values
array<int, Request>|Notification>>
On this page

Search results