Skip to content

ActionToolScanner

Discovers #[Route] action classes that are also decorated with the SDK’s own #[McpTool] attribute — “add one attribute to an existing action” is the headline feature.

Modeled on AttributeRouteScanner: reuses it to find every #[Route] action, then resolves each one’s class the same way Controller::createActionInstance() does and inspects it for #[McpTool].

A no-op (empty result) when mcp/sdk isn’t installed — guarded the same way the ORM adapters guard on their optional dependency.

final class ActionToolScanner

SourceCompiler/ActionToolScanner.php
MethodDescription
[`scan(Controller $controller, iterablenull $moduleDirs = null): list`](#scan)

public function scan(Controller $controller, iterable<string>|null $moduleDirs = null): list<ActionToolDefinition>

Defaults to AttributeRouteScanner’s own default.

ParameterTypeDescription
$controllerController
$moduleDirs`iterable<string>“null`

Returns list``<ActionToolDefinition>