What Is User Management?
User Management allows enterprise applications to serve multiple users through a single MCP server instance. Instead of creating separate servers for each user, you can dynamically switch user context using thex-alloy-userid
header.
Think of it as a multi-tenant system where:
- One server serves all your users
- Each request can specify which user it’s for
- Data and credentials remain isolated per user
- Permissions are enforced at the user level
How User Management Works
When you make a request with thex-alloy-userid
header, the system switches context to that specific user:
The user management system operates at multiple levels:
- Authentication - Validates the enterprise API key has permission to override users
- Context Switching - Loads the specified user’s context, credentials, and permissions
- Data Isolation - Ensures each user only sees their own credentials and data
- Execution - Runs the request in the user’s context
- Response - Returns results specific to that user
Why Use User Management?
Multi-Tenant SaaS Applications
- Single Integration: One MCP server for all your customers
- Customer Isolation: Each customer’s data and credentials stay separate
- Easy Scaling: Add users without creating new servers
Team Collaboration
- Department Access: Sales uses CRM tools, Marketing uses email tools
- Individual Credentials: Each team member has their own third-party logins
- Centralized Control: Manage all users from one place
Enterprise Platforms
- User Provisioning: Automatically set up new users
- Compliance: Track actions per user for audit requirements
- Cost Efficiency: One server infrastructure for unlimited users
Visualizing User Management
Without User Management - Multiple Servers:
With User Management - Single Server:
Quick Start
Basic User Override
How to Implement User Management
Step 1: Create an Enterprise MCP Server
Create a server with your enterprise API key:Step 2: Execute Requests for Different Users
For User Alice:
For User Bob:
Understanding the User Flow
Here’s how a typical user management request flows through the system: Each step ensures:- Authentication - Only enterprise keys can override users
- Authorization - User must exist and have permissions
- Isolation - User gets only their data
- Execution - Actions use user’s specific credentials
Integration Examples
Node.js Client
Python Client
Key Concepts
User Context
Each user has their own isolated context containing:- Credentials - OAuth tokens and API keys for third-party services
- Permissions - What actions they can perform
- Data - Their specific configurations and settings
- History - Their action logs and usage
Enterprise Authentication
User management requires enterprise-level authentication:- Standard API Keys - Cannot override user context
- Enterprise API Keys - Can specify any valid user ID
- Security - Prevents unauthorized user impersonation
Common Use Cases
1. SaaS Platform Integration
Serve all your customers through one MCP server:2. Multi-Tenant Applications
Isolate data and credentials per tenant:3. Team Collaboration Tools
Grant team members access to specific integrations:Security Features
- Enterprise-Only - Only enterprise API keys can override users
- Validation - User IDs are sanitized and validated
- Fallback - Invalid users fall back to default context
- Logging - All override attempts are logged
- Isolation - Users cannot access each other’s data
Best Practices
1. User ID Format
Use a consistent format for user IDs:2. Error Handling
Always handle cases where user override might fail:3. Rate Limiting
Implement per-user rate limiting in your application:4. Credential Management
Each user should have their own credentials:Important Considerations
User Prerequisites
- Users must exist in Alloy before you can switch to their context
- Create users via Alloy API or dashboard first
- Invalid user IDs fall back to default context
Permission Model
- Users inherit the server’s restriction settings
- Cannot override server restrictions per user
- For different permissions, create separate servers
Technical Limits
- HTTP header size limit (typically 8KB)
- User ID format restrictions (alphanumeric + limited special characters)
- Rate limits apply per user context