MCP auth setup
This guide configures Casdoor as the authorization server for an MCP server: application, scopes, and consent in Casdoor, then Protected Resource Metadata and token validation on the MCP server.
Prerequisites
- A running Casdoor instance (Server installation or Casdoor Cloud)
- Admin access to Casdoor
- Your MCP server’s public URL (e.g.
https://your-mcp-server.com)
Part 1: Casdoor configuration
Step 1: Create an application
- Go to Applications → Add Application
- Fill in the basic details:
- Name: Choose a descriptive name (e.g., "My Files MCP Server")
- Organization: Select the organization that will own this application
- Category: Select Agent (this unlocks MCP-specific features)
- Type: Select MCP (automatically set when Category is Agent)
The Agent category with MCP type optimizes the application for programmatic access and enables custom scope configuration.
Reference: See Application Categories for more details on Agent vs Default applications.
Step 2: Configure Redirect URIs
Redirect URIs are where Casdoor sends users after authorization. For MCP servers, add URIs for both development and production.
- In the application settings, find Redirect URIs
- Add development URIs for local testing:
http://localhost:*(wildcard for any local port)http://127.0.0.1:*
- Add production URIs for deployment:
https://your-mcp-server.com/oauth/callback- Any other callback URLs your server uses
Example configuration:
http://localhost:*
http://127.0.0.1:*
https://mcp.example.com/oauth/callback
Security note: Wildcard URIs (*) are convenient for development but should be restricted in production. Consider using exact URLs for production deployments.
Step 3: Set Grant Types
Configure which OAuth grant types your application supports.
- Find the Grant types setting
- Enable these grant types:
- ✅ authorization_code: The primary OAuth flow for MCP
- ✅ refresh_token: Allows long-lived access without re-authentication
Do not enable:
- ❌ implicit: Deprecated and insecure for MCP use
- ❌ password: Not compatible with MCP's authorization flow
Step 4: Define Custom Scopes
Custom scopes represent the permissions your MCP server's tools require. Each scope should map to a logical capability.
- Scroll to Custom Scopes section
- Click Add Scope for each permission you want to define
- For each scope, provide:
- Name: Use
resource:actionformat (e.g.,files:read,db:query) - Display Name: Short, user-friendly name (e.g., "Read Files")
- Description: Explain what the scope allows (e.g., "View and download files from your storage")
- Name: Use
Example scopes for a file management MCP server:
| Name | Display Name | Description |
|---|---|---|
files:read | Read Files | View and download files from your storage |
files:write | Write Files | Create, modify, and delete files in your storage |
files:list | List Files | See file names and metadata in directories |
Example scopes for a database MCP server:
| Name | Display Name | Description |
|---|---|---|
db:query | Query Database | Execute read-only database queries |
db:modify | Modify Database | Create, update, and delete database records |
db:admin | Database Admin | Manage schemas, tables, and database settings |
Best practices:
- Keep scopes granular—users should be able to grant partial access
- Use consistent naming (e.g.,
resource:actionpattern) - Write clear descriptions—users see these during authorization
- Start with fewer scopes, add more as your tools evolve
Reference: See Custom Scopes for detailed guidance.
Step 5: Configure Consent Policy
The consent screen shows users what permissions they're granting.
- Find Consent Policy setting
- Choose one of:
- Always: Show consent screen on every authorization (recommended for sensitive data)
- Once: Show consent only on first authorization (better UX for frequent access)
- Never: Skip consent (only for trusted first-party applications)
For MCP servers with powerful tools (file access, database modifications), we recommend Always or Once to ensure users understand what they're authorizing.