| 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
|
setInstructions(?string $instructions): self
|
#
|
public
|
setLogger(LoggerInterface $logger): self
|
#
|
public
|
setSchemaValidator(SchemaValidatorInterface $validator): self
|
#
|
public
|
addTool(
Tool $tool,
(Closure(?array<string, mixed>, ServerContext): CallToolResult)|ToolExecutorInterface $executor,
): self
|
#
|
public
|
addPrompt(
Prompt $prompt,
(Closure(?array<string, string>, ServerContext): GetPromptResult)|PromptRendererInterface $renderer,
): self
|
#
|
public
|
addResource(
Resource $resource,
(Closure(string, ServerContext): ReadResourceResult)|ResourceReaderInterface $reader,
): self
|
#
|
public
|
addResourceTemplate(
ResourceTemplate $template,
(Closure(string, array<string, string>, ServerContext): ReadResourceResult)|TemplatedResourceReaderInterface $reader,
): self
|
#
|
public
|
setToolStore(ToolStoreInterface $store): self
|
#
|
public
|
setPromptStore(PromptStoreInterface $store): self
|
#
|
public
|
setResourceStore(ResourceStoreInterface $store): self
|
#
|
public
|
setResourceTemplateStore(ResourceTemplateStoreInterface $store): self
|
#
|
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
|
#
|