Skip to content

rasuvaeff/yii3-mcp-rbac-bridge

Per-user authorization for yii3-mcp servers over the Yii3 auth stack: RBAC permissions enforced on every tools/call, permission-aware tools/list filtering, and session-identity binding against session hijacking. See the bridge guide for full usage.

bash
composer require rasuvaeff/yii3-mcp-rbac-bridge
NamespaceRasuvaeff\Yii3McpRbacBridge
Repositorygithub.com/rasuvaeff/yii3-mcp-rbac-bridge
RequirementsPHP 8.3 – 8.5, rasuvaeff/yii3-mcp ^1.1 || ^2.0, yiisoft/access ^2.0, yiisoft/user ^2.0

Public API

ClassRole
RequiredPermissionAttribute: maps a #[McpTool] method to a permission.
PermissionMapTool name → permission, built from attributes and/or explicit overrides.
RbacToolCallInterceptorRejects tools/call without the mapped permission.
RbacToolVisibilityHides the same tools from tools/list.
SessionIdentityInterceptorBinds the MCP session to its first identity.
IdentitySourceInterfacePort for "who is the current user."
CurrentUserIdentitySourceAdapter over yiisoft/user's CurrentUser.
StaticIdentitySourceFixed config/env identity for console/stdio.

See Bridges: RBAC for the two-auth-layers model, tool-name key derivation, and the two-session-bindings security model.