Skip to main content
Role-based authorization lets you control which tools users can see and execute based on their roles (admin, manager, user, etc.). This guide shows you how to build an authorization plugin that filters tools based on user claims.
Prerequisites:
  • Understanding of FrontMCP plugins (see Create a Plugin)
  • A FrontMCP project with authentication configured

What You’ll Build

An authorization plugin that:
  • Extends tool metadata to include required roles
  • Filters the tool list based on user roles
  • Works with any authentication provider

Step 1: Define Types and Metadata Extension

First, extend the tool metadata to include authorization requirements:
By extending ExtendFrontMcpToolMetadata, TypeScript will recognize the authorization field on all tool metadata.

Step 2: Create the Authorization Plugin


Step 3: Apply to Your App

Register the plugin with your app:

Step 4: Add Authorization to Tools

Mark tools with their required roles:

How It Works

1

User requests tool list

Client calls tools/list to get available tools.
2

Plugin hook intercepts

The ListToolsHook.Did('findTools') hook runs after tools are found but before the response is sent.
3

Filter by roles

The plugin checks each tool’s authorization.requiredRoles against the user’s roles from authInfo.
4

Return filtered list

Only tools the user is authorized to see are returned.

Advanced: Multiple Roles

Require multiple roles for sensitive operations:

Advanced: OR Logic for Roles

Modify the plugin to support OR logic:
Usage:

Testing Authorization


Best Practices

This plugin hides unauthorized tools from the list. Users won’t see tools they can’t use, providing a cleaner UX. For additional security, also validate roles during tool execution.
Use clear, consistent role names:
For sensitive applications, flip the default:
For defense in depth, also check roles during execution:

Next Steps

Site-Scoped Authorization

Multi-tenant authorization patterns

Authentication Modes

Configure authentication for your server

Plugin Development

Build more custom plugins

Testing Guide

Test authorization scenarios