Skip to content

PermissionMap

Rasuvaeff\Yii3McpRbacBridge\PermissionMap

ClassRasuvaeff\Yii3McpRbacBridgeSource

tool name → required RBAC permission. Tools absent from the map are unrestricted (no permission needed) — restriction is an explicit, per-tool decision.

Built from an explicit array, from #[RequiredPermission] attributes on the same tool classes the server registers, or both (explicit entries override attribute-derived ones).

Methods

fromToolClasses()

php
static fromToolClasses(array $toolClasses, array $overrides): self

Scans the tool classes for #[McpTool] methods carrying #[RequiredPermission] — the same classes listed in the yii3-mcp tools params.

One tool name mapped to two different permissions by attributes is a configuration bug and throws — the last-one-wins silent overwrite would enforce an arbitrary permission. Explicit $overrides win by design and are exempt.

permissionFor()

php
permissionFor(string $toolName): ?string