GM

gocallum/mcp-auth-demo

Developer tools

Эта страница переведена автоматически. Технические детали смотрите в оригинале. Открыть оригинал

0 stars 14 forks Качество 57 Тренд 0

A production-ready server with built using Next.js 15 and Google OAuth.

Обзор

A production-ready server with built using Next.js 15 and Google OAuth. - Fully implements OAuth 2.1 authorization code flow with PKCE, removing deprecated implicit flow patterns. - ✅ - Secure Google OAuth with PKCE support - ✅ - Seamless MCP authentication in VS Code - ✅ - Full compatibility with mcp-remote for both local and remote servers - ✅ - No token exposure in URLs, proper error handling - ✅ - RFC 9728 OAuth Protected Resource Metadata : When using mcp-remote with remote servers, specify a unique port number (e.g., 59908) to avoid conflicts with other MCP servers. This server has been designed to handle both local and remote OAuth flows seamlessly. : This server resolves an architectural limitation in mcp-remote's port detection by implementing intelligent redirect URI management that supports both OAuth 2.1 compliance and client compatibility requirements. : See detailed analysis: mcp-remote Port Detection Issue Analysis - Node.js 18+ - Google OAuth 2.

README

Показан фрагмент оригинального README. Открыть оригинал.

MCP Authentication Demo

A production-ready Model Context Protocol (MCP) server with OAuth 2.1 authentication built using Next.js 15 and Google OAuth.

🎯 Status: Production Ready ✅

OAuth 2.1 Compliant - Fully implements OAuth 2.1 authorization code flow with PKCE, removing deprecated implicit flow patterns.

Key Features

  • ✅ OAuth 2.1 Authentication - Secure Google OAuth with PKCE support
  • ✅ VS Code Integration - Seamless MCP authentication in VS Code
  • ✅ MCP Remote Support - Full compatibility with mcp-remote for both local and remote servers
  • ✅ Security First - No token exposure in URLs, proper error handling
  • ✅ Standards Compliant - RFC 9728 OAuth Protected Resource Metadata

📋 Important Notice: mcp-remote Compatibility

💡 TIP: When using mcp-remote with remote servers, specify a unique port number (e.g., 59908) to avoid conflicts with other MCP servers. This server has been designed to handle both local and remote OAuth flows seamlessly.

Technical Background: This server resolves an architectural limitation in mcp-remote’s port detection by implementing intelligent redirect URI management that supports both OAuth 2.1 compliance and client compatibility requirements.

Usage Examples:

# Local development (no port needed)
npx mcp-remote http://localhost:3000/api/mcp

# Remote server (specify unique port)
npx mcp-remote https://your-server.vercel.app/api/mcp 59908

See detailed analysis: mcp-remote Port Detection Issue Analysis

🚀 Quick Start

Prerequisites

  • Node.js 18+
  • Google OAuth 2.0 credentials (Setup Guide)

Installation

# Clone and install
git clone 
cd mcp-auth-demo
pnpm install

Configuration

Create .env.local:

GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret

Development

pnpm dev
# Server runs at http://localhost:3000

🔧 Usage

VS Code Integration

  1. Configure MCP in .vscode/mcp.json:

    {
      "servers": {
        "hello-mcp": {
          "type": "http",
          "url": "http://localhost:3000/api/mcp"
        }
      }
    }
    
  2. Start MCP Server in VS Code - Click the “Start” button and complete OAuth in browser

Command Line Testing

# Test with mcp-remote (handles OAuth automatically)
npx mcp-remote http://localhost:3000/api/mcp

# Works with remote servers too! (including Vercel deployments)
npx mcp-remote https://mcp-auth-demo-rust.vercel.app/api/mcp

📁 Project Structure

Core Application Files

app/api/[transport]/route.ts

Main MCP endpoint with OAuth 2.1 authentication middleware. Handles all MCP protocol messages with bearer token validation.

Открыть полный README на GitHub

Установка

npx mcp-remote http://localhost:3000/api/mcp
Новичок в MCP? Начните с руководства на mcpskill.org →