| Methods |
public
|
__construct()
|
#
|
public
|
setServerInfo(
string $name,
string $version,
?string $title = null,
?string $description = null,
?string $websiteUrl = null,
null|list<Icon> $icons = null,
): self
|
#
|
public
|
setMaxInFlightDispatches(?int $max): self
Caps how many inbound messages the server processes at once. Past the cap a request is
answered -32000 and a notification is dropped, until running handlers finish. Null lifts
the cap, which is the default. A subscriptions/listen is exempt: it opens a subscription rather
than being processed, and the subscription store bounds how many streams may be open.
Caps how many inbound messages the server processes at once. Past the cap a request is
answered -32000 and a notification is dropped, until running handlers finish. Null lifts
the cap, which is the default. A subscriptions/listen is exempt: it opens a subscription rather
than being processed, and the subscription store bounds how many streams may be open.
|
#
|
public
|
setServerInfoDisclosure(ServerInfoDisclosure $disclosure): self
Controls how much of the server's identity rides the _meta of the results it sends.
Controls how much of the server's identity rides the _meta of the results it sends.
|
#
|
public
|
setInstructions(?string $instructions): self
|
#
|
public
|
setLogger(LoggerInterface $logger): self
|
#
|
public
|
setSchemaValidator(SchemaValidatorInterface $validator): self
|
#
|
public
|
setPageSize(int $pageSize): self
Sets how many entries one page of a list result carries, for every store the builder assembles
from its add*() entries. A store supplied through setToolStore() and its siblings keeps its own.
Sets how many entries one page of a list result carries, for every store the builder assembles
from its add*() entries. A store supplied through setToolStore() and its siblings keeps its own.
|
#
|
public
|
setTtlMs(int $ttlMs): self
Sets how many milliseconds a client may treat a list result as fresh, for every store the builder
assembles from its add*() entries. Zero asks the client to re-fetch every time.
Sets how many milliseconds a client may treat a list result as fresh, for every store the builder
assembles from its add*() entries. Zero asks the client to re-fetch every time.
|
#
|
public
|
setCacheScope(CacheScope $cacheScope): self
Sets which caches may serve a list result, for every store the builder assembles from its
add*() entries.
Sets which caches may serve a list result, for every store the builder assembles from its
add*() entries.
|
#
|
public
|
addTool(
Tool $tool,
(Closure(?array<string, mixed>, ServerContext): (CallToolResult|InputRequiredResult))|ToolExecutorInterface $executor,
): self
|
#
|
public
|
addPrompt(
Prompt $prompt,
(Closure(?array<string, string>, ServerContext): (GetPromptResult|InputRequiredResult))|PromptRendererInterface $renderer,
): self
|
#
|
public
|
addResource(
Resource $resource,
(Closure(string, ServerContext): (InputRequiredResult|ReadResourceResult))|ResourceReaderInterface $reader,
): self
|
#
|
public
|
addResourceTemplate(
ResourceTemplate $template,
(Closure(string, array<string, string>, ServerContext): (InputRequiredResult|ReadResourceResult))|TemplatedResourceReaderInterface $reader,
): self
|
#
|
public
|
setToolStore(ToolStoreInterface $store): self
|
#
|
public
|
getToolStore(): ?ToolStoreInterface
The tool store the built server serves, or null when it exposes no tools. Assembled from the
addTool() and register() entries unless setToolStore() supplied one. Call it once every tool is registered, since it holds the store it returns. Pass the result to
SecuredHttpEndpoint so Mcp-Param-{Name} validation reads the same tools the handlers serve.
The tool store the built server serves, or null when it exposes no tools. Assembled from the
addTool() and register() entries unless setToolStore() supplied one. Call it once every tool is registered, since it holds the store it returns. Pass the result to
SecuredHttpEndpoint so Mcp-Param-{Name} validation reads the same tools the handlers serve.
|
#
|
public
|
setPromptStore(PromptStoreInterface $store): self
|
#
|
public
|
getPromptStore(): ?PromptStoreInterface
The prompt store the built server serves, or null when it exposes no prompts. Assembled from the
addPrompt() and register() entries unless setPromptStore() supplied one. Call it once every prompt is registered, since it holds the store it returns.
The prompt store the built server serves, or null when it exposes no prompts. Assembled from the
addPrompt() and register() entries unless setPromptStore() supplied one. Call it once every prompt is registered, since it holds the store it returns.
|
#
|
public
|
setResourceStore(ResourceStoreInterface $store): self
|
#
|
public
|
getResourceStore(): ?ResourceStoreInterface
The resource store the built server serves, or null when it exposes neither resources nor resource
templates. Assembled from the addResource() and register() entries unless setResourceStore()
supplied one. Call it once every resource is registered, since it holds the store it returns.
The resource store the built server serves, or null when it exposes neither resources nor resource
templates. Assembled from the addResource() and register() entries unless setResourceStore()
supplied one. Call it once every resource is registered, since it holds the store it returns.
|
#
|
public
|
setResourceTemplateStore(ResourceTemplateStoreInterface $store): self
|
#
|
public
|
getResourceTemplateStore(): ?ResourceTemplateStoreInterface
The resource template store the built server serves, or null when it exposes no templates. Assembled
from the addResourceTemplate() and register() entries unless setResourceTemplateStore() supplied
one. Call it once every template is registered, since it holds the store it returns.
The resource template store the built server serves, or null when it exposes no templates. Assembled
from the addResourceTemplate() and register() entries unless setResourceTemplateStore() supplied
one. Call it once every template is registered, since it holds the store it returns.
|
#
|
public
|
setSubscriptionStore(SubscriptionStoreInterface $store): self
Serves subscriptions/listen from $store, and lights up the listChanged capability of every
feature whose store can report its changes.
Serves subscriptions/listen from $store, and lights up the listChanged capability of every
feature whose store can report its changes.
|
#
|
public
|
setCompletionStore(CompletionStoreInterface $store): self
|
#
|
public
|
register(object ...$sources): self
Registers the server identity (#[AsServer]) plus the tools, prompts, resources, and
resource templates discovered from #[AsTool], #[AsPrompt], #[AsResource], and
#[AsResourceTemplate] methods on each source object. An explicit setServerInfo() or
setInstructions() call takes precedence over the matching #[AsServer] field, and at
most one registered source may declare #[AsServer].
Registers the server identity (#[AsServer]) plus the tools, prompts, resources, and
resource templates discovered from #[AsTool], #[AsPrompt], #[AsResource], and
#[AsResourceTemplate] methods on each source object. An explicit setServerInfo() or
setInstructions() call takes precedence over the matching #[AsServer] field, and at
most one registered source may declare #[AsServer].
Throws
|
#
|
public
|
addRequestHandler(
non-empty-string $method,
RequestHandlerInterface<non-empty-string, Result, ServerContext> $handler,
): self
Registers a handler for a vendor-extension request method.
Registers a handler for a vendor-extension request method.
Throws
|
#
|
public
|
replaceRequestHandler(
non-empty-string $method,
RequestHandlerInterface<non-empty-string, Result, ServerContext> $handler,
): self
Overrides the SDK's built-in handler for $method.
Overrides the SDK's built-in handler for $method.
Throws
|
#
|
public
|
addNotificationHandler(non-empty-string $method, NotificationHandlerInterface<non-empty-string> $handler): self
Registers a handler for a vendor-extension notification method.
Registers a handler for a vendor-extension notification method.
Throws
|
#
|
public
|
replaceNotificationHandler(non-empty-string $method, NotificationHandlerInterface<non-empty-string> $handler): self
Overrides any built-in handler for $method, including spec notifications.
Overrides any built-in handler for $method, including spec notifications.
Throws
|
#
|
public
|
build(): Server
|
#
|