Skip to main content
Use the github strategy to authenticate users with their GitHub accounts. This is a preset of the generic OAuth flow with GitHub’s endpoints pre-configured.

Creating a GitHub OAuth App

  1. Go to your GitHub account Settings > Developer settings
  2. Select OAuth Apps > New OAuth App
  3. Fill in the application details:
    • Application name: Choose a descriptive name (e.g., “My MCP Server”)
    • Homepage URL: Your server’s homepage URL (e.g., https://my-mcp.example.com)
    • Authorization callback URL:
      • For production: https://your-domain.com/oauth/provider-callback
      • For local development: http://localhost:3000/oauth/provider-callback
  4. Click Register application
  5. On the next page, click Generate a new client secret
  6. Copy the Client ID and Client Secret

Environment Setup

Preset Values

Available Scopes

GitHub OAuth scopes you may need:

Example: GitHub API Access

Tool Context

When AUTH_STRATEGY=github, successful authentication populates the tool context with:
  • context.providerToken — the GitHub access token
  • context.resolvedHeaders{ Authorization: "Bearer <github-access-token>" }
  • context.provider — provider info object with accessToken, refreshToken (if granted), expiresAt, scopes
  • context.authStrategy"github"

Example Tool

Self-Hosted GitHub Enterprise

If you’re using GitHub Enterprise (self-hosted), override the preset endpoints:

Getting User Info

Use context.getUser() to fetch the authenticated user’s profile from GitHub:
Or use the standalone getUser helper with USERINFO_ENDPOINTS: