example-remote-server/auth-server
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Basil Hosmer b32d638c87
Consolidate TypeScript build configuration
Use single tsconfig.json for both main server and auth-server to avoid
nested directory issues during build. Update e2e test scripts to run
directly instead of using concurrently.
2025-09-15 02:10:52 -04:00
..
index.ts Consolidate TypeScript build configuration 2025-09-15 02:10:52 -04:00
README.md Fix endpoint consistency and documentation accuracy 2025-09-11 21:08:29 -04:00

MCP Standalone Authorization Server

This is a demonstration OAuth 2.0 authorization server for MCP's separate authentication mode.

Purpose

This server demonstrates how MCP servers can delegate authentication to a separate authorization server. See the main README Authentication Modes section for a complete overview of integrated vs separate modes.

In production environments, you would typically use established OAuth providers like:

  • Auth0, Okta
  • Google OAuth, GitHub OAuth
  • Microsoft Azure AD, AWS Cognito

Architecture

For detailed architecture information and OAuth flow analysis, see:

This auth server specifically implements the "Auth Server" component in the separate mode architecture diagram.

Endpoints

  • /.well-known/oauth-authorization-server - OAuth 2.0 server metadata
  • /authorize - Authorization endpoint
  • /token - Token endpoint
  • /register - Dynamic client registration
  • /introspect - Token introspection (for MCP server validation)
  • /fakeupstreamauth/authorize - Fake upstream auth page (demo only)
  • /fakeupstreamauth/callback - Fake upstream callback (demo only)
  • /health - Health check endpoint

Development

This server shares Redis with the MCP server for development convenience. In production, these would typically be separate.

Running the Auth Server

Standalone

# From the repository root
npm run dev:auth-server

With MCP Server (Separate Mode)

# Start both servers together
npm run dev:with-separate-auth

Testing

Health Check

curl http://localhost:3001/health

OAuth Metadata

curl http://localhost:3001/.well-known/oauth-authorization-server

With MCP Inspector

See the main Testing with MCP Inspector section for complete testing instructions for both modes.

Quick test for this auth server:

  1. Start this auth server: npm run dev:auth-server
  2. Start MCP server in separate mode: AUTH_MODE=separate npm run dev
  3. Follow the separate mode testing steps in the main README

Configuration

The auth server uses the same configuration system as the main server. See Configuration in the main README for complete environment variable documentation.

Auth server specific variables:

  • AUTH_SERVER_PORT - Port to run on (default: 3001)
  • AUTH_SERVER_URL - Base URL (default: http://localhost:3001)
  • REDIS_URL - Redis connection (shared with MCP server)

Production Considerations

This server is for demonstration only. In production, use established OAuth providers.

For comprehensive security and deployment guidance, see:

Production replacement options:

  • Corporate SSO (Auth0, Okta)
  • Cloud providers (AWS Cognito, Azure AD)
  • Social providers (Google OAuth, GitHub OAuth)