Builder
Tags
Table of Contents
Properties
- $container : ContainerInterface|null
- $discoverer : DiscovererInterface|null
- $discoveryBasePath : string|null
- $discoveryCache : CacheInterface|null
- $discoveryExcludeDirs : array<string|int, mixed>|array<string|int, string>
- $discoveryScanDirs : array<string|int, string>
- $eventDispatcher : EventDispatcherInterface|null
- $instructions : string|null
- $loaders : array<string|int, LoaderInterface>
- $logger : LoggerInterface|null
- $notificationHandlers : array<int, NotificationHandlerInterface>
- $paginationLimit : int
-
$prompts
: array<string|int, Icon[], meta: ?array
} > - $protocolVersion : ProtocolVersion|null
- $registry : RegistryInterface
- $requestHandlers : array<int, RequestHandlerInterface<string|int, mixed>>
-
$resources
: array<string|int, Icon[], meta: ?array
} > -
$resourceTemplates
: array<string|int, Annotations, meta: ?array
} > - $schemaGenerator : SchemaGeneratorInterface|null
- $serverCapabilities : ServerCapabilities|null
- $serverInfo : Implementation|null
- $sessionFactory : SessionFactoryInterface|null
- $sessionStore : SessionStoreInterface|null
- $sessionTtl : int
- $subscriptionManager : SubscriptionManagerInterface|null
-
$tools
: array<string|int, Icon[], meta: ?array
, outputSchema: ?array >}
Methods
- addLoader() : self
- Register a single custom loader.
- addLoaders() : self
- addNotificationHandler() : self
- Register a single custom notification handler.
- addNotificationHandlers() : self
- Register multiple custom notification handlers.
- addPrompt() : self
- Manually registers a prompt handler.
- addRequestHandler() : self
- Register a single custom method handler.
- addRequestHandlers() : self
- Register multiple custom method handlers.
- addResource() : self
- Manually registers a resource handler.
- addResourceTemplate() : self
- Manually registers a resource template handler.
- addTool() : self
- Manually registers a tool handler.
- build() : Server
- Builds the fully configured Server instance.
- setCapabilities() : self
- Explicitly set server capabilities. If set, this overrides automatic detection.
- setContainer() : self
- Provides a PSR-11 DI container, primarily for resolving user-defined handler classes.
- setDiscoverer() : self
- setDiscovery() : self
- setEventDispatcher() : self
- setInstructions() : self
- Configures the instructions describing how to use the server and its features.
- setLogger() : self
- Provides a PSR-3 logger instance. Defaults to NullLogger.
- setPaginationLimit() : self
- Configures the server's pagination limit.
- setProtocolVersion() : self
- setRegistry() : self
- setResourceSubscriptionManager() : self
- setSchemaGenerator() : self
- setServerInfo() : self
- Sets the server's identity. Required.
- setSession() : self
- createDiscoverer() : DiscovererInterface
Properties
$container
private
ContainerInterface|null
$container
= null
$discoverer
private
DiscovererInterface|null
$discoverer
= null
$discoveryBasePath
private
string|null
$discoveryBasePath
= null
$discoveryCache
private
CacheInterface|null
$discoveryCache
= null
$discoveryExcludeDirs
private
array<string|int, mixed>|array<string|int, string>
$discoveryExcludeDirs
= []
$discoveryScanDirs
private
array<string|int, string>
$discoveryScanDirs
= []
$eventDispatcher
private
EventDispatcherInterface|null
$eventDispatcher
= null
$instructions
private
string|null
$instructions
= null
$loaders
private
array<string|int, LoaderInterface>
$loaders
= []
$logger
private
LoggerInterface|null
$logger
= null
$notificationHandlers
private
array<int, NotificationHandlerInterface>
$notificationHandlers
= []
$paginationLimit
private
int
$paginationLimit
= 50
$prompts
private
array<string|int, Icon[], meta: ?array} >
$prompts
= []
$protocolVersion
private
ProtocolVersion|null
$protocolVersion
= null
$registry
private
RegistryInterface
$registry
$requestHandlers
private
array<int, RequestHandlerInterface<string|int, mixed>>
$requestHandlers
= []
$resources
private
array<string|int, Icon[], meta: ?array} >
$resources
= []
$resourceTemplates
private
array<string|int, Annotations, meta: ?array} >
$resourceTemplates
= []
$schemaGenerator
private
SchemaGeneratorInterface|null
$schemaGenerator
= null
$serverCapabilities
private
ServerCapabilities|null
$serverCapabilities
= null
$serverInfo
private
Implementation|null
$serverInfo
= null
$sessionFactory
private
SessionFactoryInterface|null
$sessionFactory
= null
$sessionStore
private
SessionStoreInterface|null
$sessionStore
= null
$sessionTtl
private
int
$sessionTtl
= 3600
$subscriptionManager
private
SubscriptionManagerInterface|null
$subscriptionManager
= null
$tools
private
array<string|int, Icon[], meta: ?array, outputSchema: ?array} >
$tools
= []
Methods
addLoader()
Register a single custom loader.
public
addLoader(LoaderInterface $loader) : self
Parameters
- $loader : LoaderInterface
Return values
selfaddLoaders()
public
addLoaders(iterable<string|int, LoaderInterface> $loaders) : self
Parameters
- $loaders : iterable<string|int, LoaderInterface>
Return values
selfaddNotificationHandler()
Register a single custom notification handler.
public
addNotificationHandler(NotificationHandlerInterface $handler) : self
Parameters
- $handler : NotificationHandlerInterface
Return values
selfaddNotificationHandlers()
Register multiple custom notification handlers.
public
addNotificationHandlers(iterable<int, NotificationHandlerInterface> $handlers) : self
Parameters
- $handlers : iterable<int, NotificationHandlerInterface>
Return values
selfaddPrompt()
Manually registers a prompt handler.
public
addPrompt(Handler $handler[, string|null $name = null ][, string|null $description = null ][, array<string|int, Icon>|null $icons = null ][, array<string, mixed>|null $meta = null ]) : self
Parameters
- $handler : Handler
- $name : string|null = null
- $description : string|null = null
- $icons : array<string|int, Icon>|null = null
- $meta : array<string, mixed>|null = null
Return values
selfaddRequestHandler()
Register a single custom method handler.
public
addRequestHandler(RequestHandlerInterface<string|int, mixed> $handler) : self
Parameters
- $handler : RequestHandlerInterface<string|int, mixed>
Return values
selfaddRequestHandlers()
Register multiple custom method handlers.
public
addRequestHandlers(iterable<string|int, RequestHandlerInterface<string|int, mixed>> $handlers) : self
Parameters
- $handlers : iterable<string|int, RequestHandlerInterface<string|int, mixed>>
Return values
selfaddResource()
Manually registers a resource handler.
public
addResource(Handler $handler, string $uri[, string|null $name = null ][, string|null $description = null ][, string|null $mimeType = null ][, int|null $size = null ][, Annotations|null $annotations = null ][, array<string|int, Icon>|null $icons = null ][, array<string, mixed>|null $meta = null ]) : self
Parameters
- $handler : Handler
- $uri : string
- $name : string|null = null
- $description : string|null = null
- $mimeType : string|null = null
- $size : int|null = null
- $annotations : Annotations|null = null
- $icons : array<string|int, Icon>|null = null
- $meta : array<string, mixed>|null = null
Return values
selfaddResourceTemplate()
Manually registers a resource template handler.
public
addResourceTemplate(Handler $handler, string $uriTemplate[, string|null $name = null ][, string|null $description = null ][, string|null $mimeType = null ][, Annotations|null $annotations = null ][, array<string, mixed>|null $meta = null ]) : self
Parameters
- $handler : Handler
- $uriTemplate : string
- $name : string|null = null
- $description : string|null = null
- $mimeType : string|null = null
- $annotations : Annotations|null = null
- $meta : array<string, mixed>|null = null
Return values
selfaddTool()
Manually registers a tool handler.
public
addTool(Handler $handler[, string|null $name = null ][, string|null $description = null ][, ToolAnnotations|null $annotations = null ][, array<string, mixed>|null $inputSchema = null ][, array<string|int, Icon>|null $icons = null ][, array<string, mixed>|null $meta = null ][, array<string, mixed>|null $outputSchema = null ]) : self
Parameters
- $handler : Handler
- $name : string|null = null
- $description : string|null = null
- $annotations : ToolAnnotations|null = null
- $inputSchema : array<string, mixed>|null = null
- $icons : array<string|int, Icon>|null = null
- $meta : array<string, mixed>|null = null
- $outputSchema : array<string, mixed>|null = null
Return values
selfbuild()
Builds the fully configured Server instance.
public
build() : Server
Return values
ServersetCapabilities()
Explicitly set server capabilities. If set, this overrides automatic detection.
public
setCapabilities(ServerCapabilities $serverCapabilities) : self
Parameters
- $serverCapabilities : ServerCapabilities
Return values
selfsetContainer()
Provides a PSR-11 DI container, primarily for resolving user-defined handler classes.
public
setContainer(ContainerInterface $container) : self
Defaults to a basic internal container.
Parameters
- $container : ContainerInterface
Return values
selfsetDiscoverer()
public
setDiscoverer(DiscovererInterface $discoverer) : self
Parameters
- $discoverer : DiscovererInterface
Return values
selfsetDiscovery()
public
setDiscovery(string $basePath[, array<string|int, string> $scanDirs = ['.', 'src'] ][, array<string|int, string> $excludeDirs = [] ][, CacheInterface|null $cache = null ]) : self
Parameters
- $basePath : string
- $scanDirs : array<string|int, string> = ['.', 'src']
- $excludeDirs : array<string|int, string> = []
- $cache : CacheInterface|null = null
Return values
selfsetEventDispatcher()
public
setEventDispatcher(EventDispatcherInterface $eventDispatcher) : self
Parameters
- $eventDispatcher : EventDispatcherInterface
Return values
selfsetInstructions()
Configures the instructions describing how to use the server and its features.
public
setInstructions(string|null $instructions) : self
This can be used by clients to improve the LLM's understanding of available tools, resources, etc. It can be thought of like a "hint" to the model. For example, this information MAY be added to the system prompt.
Parameters
- $instructions : string|null
Return values
selfsetLogger()
Provides a PSR-3 logger instance. Defaults to NullLogger.
public
setLogger(LoggerInterface $logger) : self
Parameters
- $logger : LoggerInterface
Return values
selfsetPaginationLimit()
Configures the server's pagination limit.
public
setPaginationLimit(int $paginationLimit) : self
Parameters
- $paginationLimit : int
Return values
selfsetProtocolVersion()
public
setProtocolVersion(ProtocolVersion $protocolVersion) : self
Parameters
- $protocolVersion : ProtocolVersion
Return values
selfsetRegistry()
public
setRegistry(RegistryInterface $registry) : self
Parameters
- $registry : RegistryInterface
Return values
selfsetResourceSubscriptionManager()
public
setResourceSubscriptionManager(SubscriptionManagerInterface $subscriptionManager) : self
Parameters
- $subscriptionManager : SubscriptionManagerInterface
Return values
selfsetSchemaGenerator()
public
setSchemaGenerator(SchemaGeneratorInterface $schemaGenerator) : self
Parameters
- $schemaGenerator : SchemaGeneratorInterface
Return values
selfsetServerInfo()
Sets the server's identity. Required.
public
setServerInfo(string $name, string $version[, string|null $description = null ][, array<string|int, Icon>|null $icons = null ][, string|null $websiteUrl = null ]) : self
Parameters
- $name : string
- $version : string
- $description : string|null = null
- $icons : array<string|int, Icon>|null = null
- $websiteUrl : string|null = null
Return values
selfsetSession()
public
setSession(SessionStoreInterface $sessionStore[, SessionFactoryInterface $sessionFactory = new SessionFactory() ][, int $ttl = 3600 ]) : self
Parameters
- $sessionStore : SessionStoreInterface
- $sessionFactory : SessionFactoryInterface = new SessionFactory()
- $ttl : int = 3600
Return values
selfcreateDiscoverer()
private
createDiscoverer(LoggerInterface $logger) : DiscovererInterface
Parameters
- $logger : LoggerInterface