OAuth MCP Server
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@OAuth MCP Serverauthenticate with client credentials and get a token"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
OAuth MCP Server
A Model Context Protocol (MCP) server for OAuth 2.0 authentication operations.
Overview
This server provides comprehensive OAuth 2.0 authentication support for MCP applications, implementing both:
OAuth 2.0 Device Authorization Grant Flow (RFC 8628) - User-delegated authentication
OAuth 2.0 Client Credentials Flow (RFC 6749) - App-only authentication
Related MCP server: HTTP OAuth MCP Server
Features
Dual Authentication Flows - Support for both Device Code and Client Credentials flows
Token Management - Automatic token caching and expiry handling
MCP Integration - Compatible with Claude Desktop and other MCP clients
Comprehensive Logging - File and console logging with configurable levels
Secure Configuration - Environment-based configuration via .env file
Prerequisites
Python 3.8 or higher
pip (Python package manager)
Azure AD tenant (or other OAuth 2.0 provider)
Installation
Navigate to the project directory:
cd oauth_mcp_serverCreate a virtual environment (recommended):
python -m venv venv
# Activate on Windows
venv\Scripts\activate
# Activate on Linux/Mac
source venv/bin/activateInstall dependencies:
pip install -r requirements.txtConfigure environment variables:
Copy
.envfile and update with your configurationSet authentication credentials (TENANT_ID, CLIENT_ID, CLIENT_SECRET)
Choose authentication method (CLIENT_CREDENTIALS or DEVICE_CODE)
Configuration
.env File
# =============================================================================
# OAuth MCP Server Configuration
# =============================================================================
# Logging Configuration
LOG_LEVEL=DEBUG
LOG_FILE=oauth_mcp_server.log
# Azure OAuth2 Authentication Configuration
TENANT_ID=your-tenant-id-here
CLIENT_ID=your-client-id-here
CLIENT_SECRET=your-client-secret-here
ACCESS_TOKEN_URL=https://login.microsoftonline.com/{TENANT_ID}/oauth2/v2.0/token
# OAuth2 Scope
OAUTH2_SCOPE=api://your-api-id/.default
# Authentication Method (CLIENT_CREDENTIALS or DEVICE_CODE)
AUTH_METHOD=CLIENT_CREDENTIALSAuthentication Methods
Client Credentials Flow
Best for server-to-server automation with no user interaction.
AUTH_METHOD=CLIENT_CREDENTIALSRequired environment variables:
TENANT_IDCLIENT_IDCLIENT_SECRETOAUTH2_SCOPE
Device Code Flow
Best for interactive use with user authentication.
AUTH_METHOD=DEVICE_CODERequired environment variables:
TENANT_IDCLIENT_IDOAUTH2_SCOPE
Claude Desktop Configuration
Add to your Claude Desktop config file:
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"oauth-server": {
"command": "C:\\Users\\YourUser\\AppData\\Local\\Programs\\Python\\Python313\\python.exe",
"args": ["C:\\Users\\YourUser\\Documents\\Code\\oauth_mcp_server\\server.py"],
"env": {
"PYTHONPATH": "C:\\Users\\YourUser\\Documents\\Code\\oauth_mcp_server"
}
}
}
}Available Tools
Utility Functions
ping- Health check endpoint to verify server is runningget_server_info- Get server information and configuration
Device Code Flow Functions
start_device_auth- Initiate device authentication flow (Step 1)complete_device_auth- Complete authentication and retrieve token (Step 2)device_auth_flow- One-step device authentication (blocking)read_bearer_token- Read saved bearer token from file
Client Credentials Flow Functions
get_azure_token- Get bearer token using Client Credentials flowget_azure_token_info- Get detailed token informationtest_azure_token- Test token by making authenticated API callcheck_auth_config- Check and validate authentication configuration
Usage Examples
Using Client Credentials Flow
# In Claude Desktop, tokens are acquired automatically
# Just call the function and it handles authentication
# Get a token
token = get_azure_token()
# Get token details
info = get_azure_token_info()
# Test the token
result = test_azure_token()Using Device Code Flow
# Step 1: Start device authentication
auth_info = start_device_auth()
# Follow the displayed instructions to complete authentication in browser
# Step 2: Complete authentication after user signs in
token_info = complete_device_auth()
# Token is returned in the response
# Use the token in subsequent API calls
bearer_token = token_info['access_token']Running the Server
Standalone
python server.pyVia Claude Desktop
The server will start automatically when Claude Desktop launches.
Logging
Logs are written to both file and console:
Default log file:
oauth_mcp_server.login project directoryFormat:
timestamp - logger_name - level - messageConfigurable: Set
LOG_LEVELin.envfile
Project Structure
oauth_mcp_server/
├── server.py # Main MCP server implementation
├── .env # Environment configuration (not in git)
├── .gitignore # Git ignore rules
├── README.md # This file
├── test_token.bat # Token testing utility (Windows)
└── requirements.txt # Python dependenciesIntegration with Omada MCP Server
This server is designed to work alongside the omada_mcp_server. The OAuth token acquisition functions have been migrated from omada_mcp_server to this dedicated OAuth server.
Workflow:
Use
oauth_mcp_serverto obtain authentication tokensPass tokens to
omada_mcp_serverfunctions asbearer_tokenparameter
Example:
# Get token from oauth_mcp_server
token = get_azure_token()
# Use token with omada_mcp_server
get_pending_approvals(
impersonate_user='user@domain.com',
bearer_token=token
)Security Notes
Never commit
.envfile - contains sensitive credentialsLog files (
.log) are excluded from gitStore all secrets in environment variables
Tokens are cached in memory only - not saved to disk by default
Tokens are automatically refreshed when expired (Client Credentials flow)
Testing
Test Token Acquisition (Windows)
test_token.batThis script uses curl to test OAuth token acquisition directly.
Development
Adding New Tools
Add the tool function in
server.pywith@mcp.tool()decoratorAdd type hints for parameters and return value
Add comprehensive docstring
Test the tool using Claude Desktop or MCP Inspector
Migration Notes
OAuth token functions have been migrated from omada_mcp_server to this dedicated OAuth server:
Migrated Functions:
AzureOAuth2Clientclassget_cached_token()functionget_token_from_device_code_file()functionget_azure_token()MCP toolget_azure_token_info()MCP tooltest_azure_token()MCP toolcheck_auth_config()MCP tool (nowcheck_auth_config())
Preserved in omada_mcp_server:
_prepare_graphql_request()- now requires bearer_token parameter_execute_graphql_request()- now requires bearer_token parameter
Troubleshooting
Token Acquisition Fails
Check
.envfile has correct credentialsVerify
TENANT_ID,CLIENT_ID, andCLIENT_SECRETare setCheck
OAUTH2_SCOPEmatches your API configurationReview logs in
oauth_mcp_server.log
Device Code Flow Times Out
Default timeout is 5 minutes - complete authentication quickly
Use
start_device_auth()+complete_device_auth()for better controlCheck network connectivity to Azure endpoints
License
[Add your license information here]
Support
For issues or questions, please open an issue on GitHub or contact the development team.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/walkerpauldavid/oauth_mcp_server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server