@tpmjs/tools-access-control-matrix
Generates an access control matrix from roles, resources, and permissions. Takes role names, resource names, and a permission mapping (role -> resource -> actions), then returns a 2D matrix showing what each role can do with each resource. Useful for RBAC documentation, compliance audits, and security reviews.
Test @tpmjs/tools-access-control-matrix (accessControlMatrix) with AI-powered execution
0/2000 characters
Install this tool and use it with the AI SDK
npm install @tpmjs/tools-access-control-matrixpnpm add @tpmjs/tools-access-control-matrixyarn add @tpmjs/tools-access-control-matrixbun add @tpmjs/tools-access-control-matrixdeno add npm:@tpmjs/tools-access-control-matriximport { accessControlMatrix } from '@tpmjs/tools-access-control-matrix';import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { accessControlMatrix } from '@tpmjs/tools-access-control-matrix';
const result = await generateText({
model: openai('gpt-4o'),
tools: { accessControlMatrix },
prompt: 'Your prompt here...',
});
console.log(result.text);Available configuration options
rolesarrayArray of role names (e.g., ["admin", "editor", "viewer"])
resourcesarrayArray of resource names (e.g., ["documents", "reports", "settings"])
permissionsobjectNested object mapping role -> resource -> actions array. Example: { "admin": { "documents": ["read", "write", "delete"] } }
Schema extracted: 1/1/2026, 8:17:41 AM
Generates access control matrices from roles, resources, and permissions for RBAC (Role-Based Access Control) compliance and documentation.
npm install @tpmjs/tools-access-control-matrix
import { accessControlMatrix } from '@tpmjs/tools-access-control-matrix'; const result = await accessControlMatrix.execute({ roles: ['admin', 'editor', 'viewer'], resources: ['documents', 'reports', 'settings'], permissions: { admin: { documents: ['read', 'write', 'delete'], reports: ['read', 'write', 'delete'], settings: ['read', 'write'], }, editor: { documents: ['read', 'write'], reports: ['read', 'write'], }, viewer: { documents: ['read'], reports: ['read'], }, }, }); console.log(result.visualization); // Output: // | documents | reports | settings | // ------+--------------------+--------------------+--------------------+ // admin | read,write,delete | read,write,delete | read,write | // editor| read,write | read,write | - | // viewer| read | read | - | console.log(result.summary); // { // totalCells: 9, // cellsWithAccess: 7, // cellsWithoutAccess: 2, // totalPermissions: 14, // rolePermissionCounts: { admin: 8, editor: 4, viewer: 2 }, // resourceAccessCounts: { documents: 3, reports: 3, settings: 1 }, // mostPermissiveRole: 'admin', // mostRestrictedResource: 'settings' // }
{ roles: string[]; // Array of role names resources: string[]; // Array of resource names permissions: { // Nested mapping [role: string]: { [resource: string]: string[]; // Array of actions } } }
interface AccessControlMatrix { matrix: MatrixCell[][]; // 2D array of role-resource permissions roles: string[]; // List of roles resources: string[]; // List of resources summary: { totalCells: number; cellsWithAccess: number; cellsWithoutAccess: number; totalPermissions: number; rolePermissionCounts: Record<string, number>; resourceAccessCounts: Record<string, number>; mostPermissiveRole: string; mostRestrictedResource: string; }; visualization: string; // ASCII table representation } interface MatrixCell { role: string; resource: string; actions: string[]; hasAccess: boolean; }
Standard CRUD operations:
read - View or retrieve resourceswrite - Create or update resourcesdelete - Remove resourcesexecute - Run or trigger resourcesExtended actions:
approve - Approve changes or requestspublish - Make resources publicly availableshare - Share resources with othersexport - Download or export dataadmin - Administrative accessThe tool validates:
const appMatrix = await accessControlMatrix.execute({ roles: ['superadmin', 'admin', 'developer', 'analyst', 'guest'], resources: ['users', 'database', 'api', 'reports', 'logs'], permissions: { superadmin: { users: ['read', 'write', 'delete'], database: ['read', 'write', 'delete', 'backup'], api: ['read', 'write', 'delete', 'deploy'], reports: ['read', 'write', 'export'], logs: ['read', 'delete'], }, admin: { users: ['read', 'write'], database: ['read'], api: ['read', 'deploy'], reports: ['read', 'write', 'export'], logs: ['read'], }, developer: { api: ['read', 'write'], logs: ['read'], }, analyst: { reports: ['read', 'export'], logs: ['read'], }, guest: { reports: ['read'], }, }, });
const healthcareMatrix = await accessControlMatrix.execute({ roles: ['physician', 'nurse', 'receptionist', 'billing'], resources: ['patient_records', 'prescriptions', 'appointments', 'billing_info'], permissions: { physician: { patient_records: ['read', 'write'], prescriptions: ['read', 'write', 'approve'], appointments: ['read'], }, nurse: { patient_records: ['read', 'write'], prescriptions: ['read'], appointments: ['read', 'write'], }, receptionist: { patient_records: ['read'], appointments: ['read', 'write'], }, billing: { patient_records: ['read'], billing_info: ['read', 'write'], }, }, });
MIT
Downloads/month
35
Quality Score