Configuration
Prerequisites
Before you begin, you will need:- A Discord Account with access to create applications
- Your FastMCP server’s URL (can be localhost for development, e.g.,
http://localhost:8000)
Step 1: Create a Discord Application
Create an application in the Discord Developer Portal to get the credentials needed for authentication:1
Navigate to Discord Developer Portal
Go to the Discord Developer Portal.Click “New Application” and give it a name users will recognize (e.g., “My FastMCP Server”).
2
Configure OAuth2 Settings
In the left sidebar, click “OAuth2”.In the Redirects section, click “Add Redirect” and enter your callback URL:
- For development:
http://localhost:8000/auth/callback - For production:
https://your-domain.com/auth/callback
3
Save Your Credentials
On the same OAuth2 page, you’ll find:
- Client ID: A numeric string like
12345 - Client Secret: Click “Reset Secret” to generate one
Step 2: FastMCP Configuration
Create your FastMCP server using theDiscordProvider, which handles Discord’s OAuth flow automatically:
server.py
Testing
Running the Server
Start your FastMCP server with HTTP transport to enable OAuth flows:Testing with a Client
Create a test client that authenticates with your Discord-protected server:test_client.py
- Your browser will open to Discord’s authorization page
- Sign in with your Discord account and authorize the app
- After authorization, you’ll be redirected back
- The client receives the token and can make authenticated requests
The client caches tokens locally, so you won’t need to re-authenticate for subsequent runs unless the token expires or you explicitly clear the cache.
Discord Scopes
Discord OAuth supports several scopes for accessing different types of user data:
To request additional scopes:
Production Configuration
For production deployments with persistent token management across server restarts, configurejwt_signing_key and client_storage:
server.py
Parameters (
jwt_signing_key and client_storage) work together to ensure tokens and client registrations survive server restarts. Wrap your storage in FernetEncryptionWrapper to encrypt sensitive OAuth tokens at rest - without it, tokens are stored in plaintext. Store secrets in environment variables and use a persistent storage backend like Redis for distributed deployments.For complete details on these parameters, see the OAuth Proxy documentation.
