Overview
MCP Server with LangGraph uses OpenFGA for fine-grained, relationship-based authorization (Google Zanzibar model). This enables you to define complex permissions like “who can access what” with precision.OpenFGA provides the same authorization model used by Google, Airbnb, and GitHub for billions of authorization decisions per day.
Key Concepts
Users
Entities that perform actions (users, service accounts)
Objects
Resources being accessed (tools, documents, organizations)
Relations
Relationships between users and objects (owner, viewer, executor)
Authorization Model
The default model supports:Quick Start
1
Deploy OpenFGA
2
Initialize Authorization Model
- OpenFGA store
- Authorization model with types and relations
- Default permissions for development users
3
Configure Environment
4
Test Authorization
Authorization Model
Default Model Structure
Relationship Examples
- User → Tool
- User → Organization
- Organization → Tool
Grant user access to specific tools:
Common Patterns
Multi-Tenancy
Isolate resources by organization:Hierarchical Permissions
Admins inherit all member permissions:Document Access Control
Fine-grained document permissions:Keycloak Integration 🆕
NEW in v2.1.0: Automatic role synchronization from Keycloak to OpenFGA.Automatic Sync
When users authenticate via Keycloak, their roles and groups are synced to OpenFGA:Role Mapping
Configure role mapping inconfig/role_mappings.yaml:
API Operations
Check Permission
Grant Permission
Revoke Permission
List User Permissions
Monitoring & Debugging
Enable Authorization Logging
View Authorization Decisions
Check application logs for authorization events:OpenFGA Metrics
Monitor authorization performance:Production Best Practices
Use PostgreSQL Backend
Use PostgreSQL Backend
Never use in-memory store in production!Deploy PostgreSQL with:
- Replication for high availability
- Regular backups
- SSL/TLS encryption
Separate Stores per Environment
Separate Stores per Environment
Use different stores for dev/staging/production:Prevents accidental permission changes across environments.
Enable Audit Logging
Enable Audit Logging
Track all authorization changes:Monitor for:
- Unexpected permission grants
- Failed authorization attempts
- Permission revocations
Implement Fail-Safe Mode
Implement Fail-Safe Mode
Configure failure behavior:In production, always fail-closed to prevent unauthorized access.
Regular Permission Audits
Regular Permission Audits
Periodically review permissions:Run monthly or after major changes.
Troubleshooting
Connection refused to OpenFGA
Connection refused to OpenFGA
Store or model not found
Store or model not found
Re-initialize:
Next Steps
Permission Model
Customize the authorization model
Relationship Tuples
Manage permissions programmatically
OpenFGA Setup
Advanced OpenFGA configuration
Keycloak Integration
Sync Keycloak roles to OpenFGA
Production Ready: OpenFGA provides Google-grade authorization for your MCP server!