Skip to content

McpServerFactory ​

Rasuvaeff\Yii3Mcp\McpServerFactory

Class — Rasuvaeff\Yii3Mcp — Source

Builds an SDK Server from a list of application tool classes.

Capability methods are declared with the SDK's own attributes (#[McpTool], #[McpResource], #[McpResourceTemplate], #[McpPrompt]) on public methods; handlers are registered as [class, method] references, so instances are resolved lazily through the DI container and receive their dependencies the normal Yii3 way. Classes implementing ConditionalToolInterface may opt out of registration at build time.

Methods ​

create() ​

php
create(
    array $toolClasses,
    iterable $configurators,
    iterable $interceptors,
    ?Visibility\ToolVisibilityInterface $toolVisibility,
    iterable $promptInterceptors,
    iterable $resourceInterceptors,
    ?Visibility\PromptVisibilityInterface $promptVisibility,
    ?Visibility\ResourceVisibilityInterface $resourceVisibility,
    iterable $resultDecorators,
): Mcp\Server
  • $interceptors — tool-call chain, first = outermost
  • $toolVisibility — per-session filter for tools/list + fail-closed tools/call
  • $promptInterceptors — prompts/get chain, first = outermost
  • $resourceInterceptors — resources/read chain (static + templates), first = outermost
  • $promptVisibility — per-session filter for prompts/list + fail-closed prompts/get
  • $resourceVisibility — per-session filter for resources/list, resources/templates/list + fail-closed resources/read
  • $resultDecorators — applied in order to the formatted result of every successful tools/call, after the whole interceptor chain