ExtensionInterface
An MCP protocol extension advertised during capability negotiation.
Implementations are typically zero-config — they expose a stable identifier and the
capability payload announced under capabilities.extensions[<id>]. The same
extension object can be enabled on a server (initialize response) and on a client
(initialize request); the side that enables it decides which.
An extension that only announces a capability, without adding RPC methods of its own, can extend AbstractExtension and skip self::getMessages() and self::getRequestHandlers() entirely.
Tags
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 those methods.
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>getId()
The reverse-DNS identifier used as the key under `capabilities.extensions`.
public
getId() : ExtensionIdentifier
Return values
ExtensionIdentifiergetMessages()
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>>getRequestHandlers()
The handlers serving those methods.
public
getRequestHandlers() : iterable<string|int, RequestHandlerInterface<string|int, ResultInterface>>