AA

alejandro-ao/mcp-fastapi-auth

Developer tools

이 페이지는 AI로 자동 번역되었습니다. 기술적인 세부 사항은 원문을 확인하세요. 원문 보기

17 stars 18 forks 품질 43 트렌드 21

OAuth 2.1 및 ScaleKit로 FastAPI에서 MCP Auth 데모

개요

이것은 OAuth 2.1 인증을 구현하는 안전한 Model Context Protocol (MCP) 서버입니다. 서버는 Tavily API를 통해 웹 검색 기능을 제공하여 적절한 인증 및 인증을 보장합니다. MCP (Model Context Protocol)는 LLM 및 도구 또는 리소스 간의 통신을 위해 설계된 프로토콜입니다. 이 구현은 OAuth 2.1 인증을 통해 엔터프라이즈급 보안을 추가하고 액세스 제어가 중요한 생산 배포에 적합합니다. - : Scalekit 인증 서버를 사용하여 보안 액세스 - : MCP 인증 사양 구현 - : Tavily API를 통해 웹 검색 기능을 제공합니다 - : 자동 클라이언트 등록 지원 - : 적절한 청중 검사로 액세스 토큰 유효성 검사 - : PKCE, 적절한 오류 처리 및 토큰 청중 유효성 검사 1. : Scalekit 2. : Tavily 3.에서 API 키 받기.

개요(AI 번역)

이것은 OAuth 2.1 인증을 구현하는 안전한 Model Context Protocol (MCP) 서버입니다. 서버는 Tavily API를 통해 웹 검색 기능을 제공하여 적절한 인증 및 인증을 보장합니다.

MCP는 무엇입니까?

MCP (Model Context Protocol)는 LLM 및 도구 또는 리소스 간의 통신을 위해 설계된 프로토콜입니다. 이 구현은 OAuth 2.1 인증을 통해 엔터프라이즈급 보안을 추가하고 액세스 제어가 중요한 생산 배포에 적합합니다.

특징

-OAuth 2.1 인증: Scalekit 인증 서버를 사용하여 보안 액세스

  • MCP Compliance: MCP 인증 사양 구현
  • 웹 검색: Tavily API를 통해 웹 검색 기능을 제공합니다.
  • Dynamic Client 등록: 자동 고객 등록 지원
  • ** 토큰 유효성**: 적당한 청중 검사를 가진 접근 토큰을 유효하게 합니다
  • Security Best Practices: PKCE, 적절한 오류 처리 및 토큰 청중 검증을 구현

필수품

  1. Scalekit 계정: Scalekit에 가입 2.Tavily API Key: Tavily에서 API 키 받기
  2. ** 푸틴 3.

이 페이지는 AI로 자동 번역되었습니다. 기술적인 세부 사항은 원문을 확인하세요.

README

원문 README의 일부입니다. 원문 보기.

MCP Server with OAuth 2.1 Authentication

This is a secure Model Context Protocol (MCP) server that implements OAuth 2.1 authentication using Scalekit as the authorization server. The server provides web search capabilities through the Tavily API while ensuring proper authentication and authorization.

What is MCP?

MCP (Model Context Protocol) is a protocol designed for communication between LLMs and tools or resources. This implementation adds enterprise-grade security through OAuth 2.1 authentication, making it suitable for production deployments where access control is critical.

Features

  • OAuth 2.1 Authentication: Secure access using Scalekit authorization server
  • MCP Compliance: Implements the MCP authorization specification
  • Web Search: Provides web search functionality via Tavily API
  • Dynamic Client Registration: Supports automatic client registration
  • Token Validation: Validates access tokens with proper audience checking
  • Security Best Practices: Implements PKCE, proper error handling, and token audience validation

Prerequisites

  1. Scalekit Account: Sign up at Scalekit
  2. Tavily API Key: Get your API key from Tavily
  3. Python 3.11+: Required for running the server

Setup

1. Install Dependencies

pip install -e .

2. Configure Environment Variables

Copy the example environment file and configure your settings:

cp .env.example .env

Edit .env with your actual values:

# Your Scalekit environment URL
SCALEKIT_ENVIRONMENT_URL=https://your-company.scalekit.com

# Your MCP server's resource identifier
RESOURCE_IDENTIFIER=https://your-mcp-server.com

# Server port (optional)
PORT=10000

# Tavily API key
TAVILY_API_KEY=your_tavily_api_key_here

3. Configure Scalekit

In the Scalekit dashboard:

  1. Navigate to MCP servers and click Add MCP server
  2. Configure your server:
    • Server name: “Web Search MCP Server”
    • Resource identifier: Your server URL (e.g., https://your-mcp-server.com)
    • Allow dynamic client registration: Enable this
    • Access token lifetime: 300-3600 seconds
    • Scopes: web-search:read, web-search:write

Running the Server

python src/server.py

The server will start on http://localhost:10000 (or your configured port).

API Endpoints

OAuth Discovery Endpoints

  • GET /.well-known/oauth-protected-resource - Resource metadata for MCP client discovery
  • GET /.well-known/oauth-authorization-server - Authorization server metadata (proxied from Scalekit)

OAuth Endpoints

  • POST /oauth/register - Dynamic client registration (proxied to Scalekit)

MCP Endpoints

  • POST /web-search/mcp - Main MCP endpoint (requires authentication)

Authentication Flow

GitHub에서 전체 README 보기

설치

This server does not publish a one-line install command.

Open the repository installation guide MCP 초보자라면? mcpskill.org 가이드부터 시작하세요 →