| Methods |
public
|
__construct()
|
#
|
public
|
setServerInfo(
non-empty-string $name,
non-empty-string $version,
null|non-empty-string $title = null,
null|non-empty-string $description = null,
null|non-empty-string $websiteUrl = null,
null|list<Icon> $icons = null,
): self
|
#
|
public
|
setMaxInFlightDispatches(?int $max): self
Caps how many inbound messages the server processes at once, defaulting to DEFAULT_MAX_IN_FLIGHT, with
null lifting the cap.
Caps how many inbound messages the server processes at once, defaulting to DEFAULT_MAX_IN_FLIGHT, with
null lifting the cap.
|
#
|
public
|
setServerInfoDisclosure(ServerInfoDisclosure $disclosure): self
|
#
|
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 itself.
Sets how many entries one page of a list result carries, for every store the builder assembles itself.
|
#
|
public
|
setTtlMs(int $ttlMs): self
Sets how many milliseconds a client may treat a list result as fresh (zero re-fetches every time),
for every store the builder assembles itself.
Sets how many milliseconds a client may treat a list result as fresh (zero re-fetches every time),
for every store the builder assembles itself.
|
#
|
public
|
setCacheScope(CacheScope $cacheScope): self
Sets which caches may serve a list result, for every store the builder assembles itself.
Sets which caches may serve a list result, for every store the builder assembles itself.
|
#
|
public
|
addTool(
Tool $tool,
(Closure(?array<array-key, mixed>, ServerContext): (CallToolResult|InputRequiredResult))|ToolExecutorInterface $executor,
): self
|
#
|
public
|
addPrompt(
Prompt $prompt,
(Closure(?array<array-key, string>, ServerContext): (GetPromptResult|InputRequiredResult))|PromptRendererInterface $renderer,
): self
|
#
|
public
|
addResource(
Resource $resource,
(Closure(non-empty-string, ServerContext): (InputRequiredResult|ReadResourceResult))|ResourceReaderInterface $reader,
): self
|
#
|
public
|
addResourceTemplate(
ResourceTemplate $template,
(Closure(non-empty-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. Call it once every tool is
registered, since it holds the store it returns.
The tool store the built server serves, or null when it exposes no tools. Call it once every tool is
registered, since it holds the store it returns.
|
#
|
public
|
setPromptStore(PromptStoreInterface $store): self
|
#
|
public
|
getPromptStore(): ?PromptStoreInterface
The prompt store the built server serves, or null when it exposes no prompts. 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. 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 templates.
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 templates.
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. 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. 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
|
addPromptCompletion(
string $prompt,
string $argument,
(Closure(string, ?array<array-key, string>, ServerContext): CompleteResult)|CompletionProviderInterface $provider,
): self
|
#
|
public
|
addResourceTemplateCompletion(
string $uriTemplate,
string $argument,
(Closure(string, ?array<array-key, string>, ServerContext): CompleteResult)|CompletionProviderInterface $provider,
): self
|
#
|
public
|
getCompletionStore(): ?CompletionStoreInterface
The completion store the built server serves, or null when it serves no completions. Call it once
every completion is registered, since it holds the store it returns.
The completion store the built server serves, or null when it serves no completions. Call it once
every completion is registered, since it holds the store it returns.
|
#
|
public
|
register(object ...$sources): self
Registers each source object's #[AsServer] identity, which an explicit setServerInfo() or
setInstructions() call overrides per field, plus its #[AsTool], #[AsPrompt], #[AsResource],
#[AsResourceTemplate], and #[AsCompletion] methods.
Registers each source object's #[AsServer] identity, which an explicit setServerInfo() or
setInstructions() call overrides per field, plus its #[AsTool], #[AsPrompt], #[AsResource],
#[AsResourceTemplate], and #[AsCompletion] methods.
Throws
|
#
|
public
|
enableExtension(ServerExtensionInterface $extension): self
Enables $extension, advertising its capability identifier and serving its methods
behind the per-request declared-capability gate.
Enables $extension, advertising its capability identifier and serving its methods
behind the per-request declared-capability gate.
Throws
|
#
|
public
|
addRequestHandler(
class-string<JsonRpcRequest<non-empty-string>> $request,
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(
class-string<JsonRpcNotification<non-empty-string>> $notification,
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
|
#
|