Prerequisites:
- Understanding of FrontMCP plugins (see Create a Plugin)
- Understanding of tool hooks (see Customize Flow Stages)
What You’ll Build
A site authorization plugin that:- Validates users can only access their authorized sites
- Supports admin-only tools within sites
- Works with tools that have a
siteIdinput parameter
Step 1: Define Types and Metadata Extension
Step 2: Create the Site Authorization Plugin
Step 3: Register the Plugin
Step 4: Mark Tools as Site-Scoped
Basic Site-Scoped Tool
Tools with asiteId input are automatically site-scoped:
Admin-Only Site Tool
Custom Site Field Name
Explicit Site Scoping
Force site validation even without a siteId field:User Claims Structure
The plugin expects user claims in this format:How It Works
Check user access
Plugin extracts user’s allowed sites from
authInfo.user.sites or authInfo.user.tenants.Combining with Role-Based Authorization
You can use both plugins together:- Role-based filtering - Users only see tools for their roles
- Site-based validation - Users can only access their authorized sites
Testing Site Authorization
Best Practices
Always include siteId in tool inputs
Always include siteId in tool inputs
Make site context explicit in every site-scoped operation:
Use demo mode carefully
Use demo mode carefully
The
demoAllowAllIfNoClaims option is convenient for development but should be disabled in production:Log authorization failures
Log authorization failures
Consider caching site access
Consider caching site access
For high-traffic applications, cache site access checks:
Next Steps
Role-Based Authorization
Filter tools by user roles
Create a Plugin
Full plugin development guide
Customize Flow Stages
Learn more about hooks
Authentication
Configure authentication providers