Download the PHP package rasuvaeff/yii3-mcp-rbac-bridge without Composer

On this page you can find all versions of the php package rasuvaeff/yii3-mcp-rbac-bridge. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package yii3-mcp-rbac-bridge

rasuvaeff/yii3-mcp-rbac-bridge

Stable Version Total Downloads Build Static analysis Psalm level PHP Русская версия

Per-user authorization for rasuvaeff/yii3-mcp servers over the Yii3 auth stack — the application-facing alternative to OAuth 2.1: RBAC permissions enforced on every tools/call, permission-aware tools/list filtering, and session-identity binding against session hijacking.

Using an AI coding assistant? llms.txt contains a compact API reference you can share with the model. Contributors: see AGENTS.md.

Requirements

Requirement Version
PHP 8.3 – 8.5
rasuvaeff/yii3-mcp ^1.1
yiisoft/access ^2.0 (bind AccessCheckerInterface to your RBAC manager)
yiisoft/user ^2.0 (identity of the current request)

Installation

The model: two auth layers

SharedSecretMiddleware (yii3-mcp) stays — it is machine auth: may this MCP client talk to this endpoint at all. This bridge adds user auth: what may the authenticated user behind the call actually do. Both layers run; removing the shared secret does not follow from adding RBAC.

Usage

1. Declare permissions on tools

Restriction is explicit and per-tool: tools without a permission stay open (behind the shared secret). #[RequiredPermission] on a method without #[McpTool] fails the build — a permission that would never be enforced is a bug, not a default. One tool name mapped to two different permissions by attributes fails the build too (a silent last-one-wins would enforce an arbitrary one); explicit overrides win by design.

Tool names: what the map keys must be

PermissionMap keys are tool names, and the bridge derives each one exactly as yii3-mcp registers it — so list and call can never key off different names:

Tool declaration Registered name = map key
#[McpTool(name: 'order.status')] order.status — the explicit name wins
#[McpTool] on public function status() status — the method name
#[McpTool] on public function __invoke() the class short name (e.g. RefundTool), not __invoke

fromToolClasses() computes these keys for you. Only an explicit map (the $overrides argument, or new PermissionMap([...])) is yours to key correctly — for an invokable tool that key is the class short name:

A key that matches no registered tool is inert (the tool stays unrestricted), so keep explicit keys in sync with the tool names above.

2. Wire the bridge

AccessCheckerInterface comes from your RBAC setup (yiisoft/rbac manager with rbac-php/rbac-db storage — see suggest).

What each piece does

Class Role
RbacToolCallInterceptor rejects tools/call without the mapped permission (regular MCP tool error, fail-closed for guests)
RbacToolVisibility hides the same tools from tools/list — list and call can never disagree (one PermissionMap)
SessionIdentityInterceptor binds the MCP session to its first identity; a leaked Mcp-Session-Id presented with another user's token is rejected
PermissionMap tool name → permission: #[RequiredPermission] scan + explicit overrides
CurrentUserIdentitySource identity id from yiisoft/user CurrentUser (null = guest); implement IdentitySourceInterface for stdio/custom setups

Security notes

Examples

See examples/ — runs offline.

Script Shows Needs server?
rbac.php Filtered listing, allowed/denied calls, session binding no

Development

No PHP/Composer on the host — run in Docker via the composer:2 image:

Or with Make: make build, make cs-fix, make psalm, make test.

License

BSD-3-Clause. See LICENSE.md.


All versions of yii3-mcp-rbac-bridge with dependencies

PHP Build Version
Package Version
Requires php Version 8.3 - 8.5
mcp/sdk Version ~0.6.0 || ~0.7.0
rasuvaeff/yii3-mcp Version ^1.1 || ^2.0
yiisoft/access Version ^2.0
yiisoft/user Version ^2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package rasuvaeff/yii3-mcp-rbac-bridge contains the following files

Loading the files please wait ...