MCP PHP SDK

Application

Table of Contents

Interfaces

ProviderInterface
LoaderInterface
ReferenceHandlerInterface
Interface for handling execution of MCP elements.
RegistryInterface
ExceptionInterface
NotFoundExceptionInterface
HasMethodInterface
Interface for all incoming JSON-RPC messages that should be processed by a handler, and are expected to have a method.
MessageInterface
Refers to any valid JSON-RPC object that can be decoded off the wire, or encoded to be sent.
ResultInterface
Base class for all specific MCP result objects (the value of the 'result' field).
ClientAwareInterface
NotificationHandlerInterface
RequestHandlerInterface
SessionFactoryInterface
Factory interface for creating session instances.
SessionInterface
SessionStoreInterface
TransportInterface

Classes

CompletionProvider
McpPrompt
Marks a PHP method as an MCP Prompt generator.
McpResource
Marks a PHP class as representing or handling a specific MCP Resource instance.
McpResourceTemplate
Marks a PHP class definition as representing an MCP Resource Template.
McpTool
Schema
Defines a JSON Schema for a method's input or an individual parameter.
EnumCompletionProvider
ListCompletionProvider
CachedDiscoverer
Cached decorator for the Discoverer class.
Discoverer
DiscoveryState
Represents the state of discovered MCP capabilities.
DocBlockParser
Parses DocBlocks using phpdocumentor/reflection-docblock.
HandlerResolver
Utility class to validate and resolve MCP element handlers.
SchemaGenerator
Generates JSON Schema for method parameters with intelligent Schema attribute handling.
SchemaValidator
Validates data against JSON Schema definitions using opis/json-schema.
Container
A basic PSR-11 container implementation with simple constructor auto-wiring.
ElementReference
ArrayLoader
DiscoveryLoader
PromptReference
ReferenceHandler
ResourceReference
ResourceTemplateReference
ToolReference
Registry
Registry implementation that manages MCP element registration and access.
NameValidator
PromptListChangedEvent
ResourceListChangedEvent
ResourceTemplateListChangedEvent
ToolListChangedEvent
ClientException
ConfigurationException
ContainerException
Exception
HandlerNotFoundException
InvalidArgumentException
InvalidCursorException
InvalidInputMessageException
LogicException
PromptGetException
PromptNotFoundException
RegistryException
ResourceNotFoundException
ResourceReadException
RuntimeException
ServiceNotFoundException
ToolCallException
ToolNotFoundException
MessageFactory
Factory for creating JSON-RPC message objects from raw input.
Annotations
Optional annotations for the client. The client can use annotations to inform how objects are used or displayed.
ClientCapabilities
Capabilities a client may support. Known capabilities are defined here, in this schema, but this is not a closed set: any client can define its own, additional capabilities.
AudioContent
Represents audio content in MCP.
BlobResourceContents
Represents blob resource contents in MCP.
Content
Base class for all content types in MCP.
EmbeddedResource
Represents embedded resource content within a message.
ImageContent
Base class for all content types in MCP.
PromptMessage
Describes a message returned as part of a prompt.
ResourceContents
The contents of a specific resource or sub-resource.
SamplingMessage
Describes a message issued to or received from an LLM API during sampling.
TextContent
Represents text content in MCP.
TextResourceContents
Represents text resource contents in MCP.
Icon
A url pointing to an icon URL or a base64-encoded data URI.
Implementation
Describes the name and version of an MCP implementation.
Error
A response to a request that indicates an error occurred.
Notification
Request
Response
ModelHint
Hints to use for model selection.
ModelPreferences
The server's preferences for model selection, requested of the client during sampling.
CancelledNotification
This notification can be sent by either side to indicate that it is cancelling a previously-issued request.
InitializedNotification
This notification is sent from the client to the server after initialization has finished.
LoggingMessageNotification
ProgressNotification
An out-of-band notification used to inform the receiver of a progress update for a long-running request.
PromptListChangedNotification
An optional notification from the server to the client, informing it that the list of prompts it offers has changed. This may be issued by servers without any previous subscription from the client.
ResourceListChangedNotification
An optional notification from the server to the client, informing it that the list of resources it can read from has changed. This may be issued by servers without any previous subscription from the client.
ResourceUpdatedNotification
RootsListChangedNotification
A notification from the client to the server, informing it that the list of roots has changed.
ToolListChangedNotification
An optional notification from the server to the client, informing it that the list of tools it offers has changed. This may be issued by servers without any previous subscription from the client.
Page
Prompt
A prompt or prompt template that the server offers.
PromptArgument
Describes an argument that a prompt can accept.
PromptReference
Identifies a prompt.
CallToolRequest
Used by the client to invoke a tool provided by the server.
CompletionCompleteRequest
A request from the client to the server, to ask for completion options.
CreateSamplingMessageRequest
A request from the server to sample an LLM via the client. The client has full discretion over which model to select.
GetPromptRequest
Used by the client to get a prompt provided by the server.
InitializeRequest
This request is sent from the client to the server when it first connects, asking it to begin initialization.
ListPromptsRequest
Sent from the client to request a list of prompts and prompt templates the server has.
ListResourcesRequest
Sent from the client to request a list of resources the server has.
ListResourceTemplatesRequest
Sent from the client to request a list of resource templates the server has.
ListRootsRequest
Sent from the server to request a list of root URIs from the client. Roots allow servers to ask for specific directories or files to operate on. A common example for roots is providing a set of repositories or directories a server should operate on.
ListToolsRequest
Sent from the client to request a list of tools the server has.
PingRequest
A ping, issued by either the server or the client, to check that the other party is still alive. The receiver must promptly respond, or else may be disconnected.
ReadResourceRequest
Sent from the client to the server, to read a specific resource URI.
ResourceSubscribeRequest
Sent from the client to request resources/updated notifications from the server whenever a particular resource changes.
ResourceUnsubscribeRequest
Sent from the client to request cancellation of resources/updated notifications from the server. This should follow a previous resources/subscribe request.
SetLogLevelRequest
A request from the client to the server, to enable or adjust logging.
Resource
A known resource that the server is capable of reading.
ResourceReference
A reference to a resource or resource template definition.
ResourceTemplate
A template description for resources available on the server.
CallToolResult
The server's response to a tool call.
CompletionCompleteResult
The server's response to a completion/complete request.
CreateSamplingMessageResult
The client's response to a sampling/create_message request from the server. The client should inform the user before returning the sampled message, to allow them to inspect the response (human in the loop) and decide whether to allow the server to see it.
EmptyResult
A generic empty result that indicates success but carries no data.
GetPromptResult
InitializeResult
After receiving an initialize request from the client, the server sends this response.
ListPromptsResult
The server's response to a prompts/list request from the client.
ListResourcesResult
The server's response to a resources/list request from the client.
ListResourceTemplatesResult
The server's response to a resources/templates/list request from the client.
ListRootsResult
The client's response to a roots/list request from the server.
ListToolsResult
The server's response to a tools/list request from the client.
ReadResourceResult
The server's response to a resources/read request from the client.
Root
Represents a root directory or file that the server can operate on.
ServerCapabilities
Capabilities that a server may support. Known capabilities are defined here, in this schema, but this is not a closed set: any server can define its own, additional capabilities.
Tool
Definition for a tool the client can call.
ToolAnnotations
Additional properties describing a Tool to clients.
Builder
ClientGateway
Helper class for tools to communicate with the client.
Configuration
Value Object holding core configuration and shared dependencies for the MCP Server instance.
InitializedHandler
CallToolHandler
CompletionCompleteHandler
Handles completion/complete requests.
GetPromptHandler
InitializeHandler
ListPromptsHandler
ListResourcesHandler
ListResourceTemplatesHandler
ListToolsHandler
PingHandler
ReadResourceHandler
NativeClock
Protocol
FileSessionStore
File-based session store.
InMemorySessionStore
Psr16StoreSession
PSR-16 compliant cache-based session store.
Session
SessionFactory
Default implementation of SessionFactoryInterface.
BaseTransport
Provides a skeletal implementation of the TransportInterface to minimize the effort required to implement this interface.
CallbackStream
A PSR-7 StreamInterface that executes a callback when read.
InMemoryTransport
Provides a skeletal implementation of the TransportInterface to minimize the effort required to implement this interface.
StdioTransport
Provides a skeletal implementation of the TransportInterface to minimize the effort required to implement this interface.
StreamableHttpTransport
Provides a skeletal implementation of the TransportInterface to minimize the effort required to implement this interface.
Server

Traits

ClientAwareTrait
ManagesTransportCallbacks
A trait for managing the various callbacks provided by the Protocol layer.

Enums

LoggingLevel
The severity of a log message.
ProtocolVersion
Available protocol versions for MCP.
Role
The sender or recipient of messages and data in a conversation.
SamplingContext

        
On this page

Search results