DM

danvega/mcps

Developer tools

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

16 stars 8 forks 품질 46 트렌드 21

A demonstration of securing a Model Context Protocol (MCP) server using Spring Authorization Server and GitHub OAuth2.

개요

A demonstration of securing a Model Context Protocol (MCP) server using Spring Authorization Server and GitHub OAuth2. Users authenticate with GitHub, receive a JWT token, and use it to call secured MCP tools. https://spring.io/blog/2025/09/30/spring-ai-mcp-server-security - Java 21+ - Maven 3.6+ - GitHub account 1. Go to GitHub Developer Settings 2. Create a : - : MCP Authorization Server - : http://localhost:9000 - : http://localhost:9000/login/oauth2/code/github 3. Save the and The authorization server runs on port 9000, MCP server on port 8080. The MCP Inspector tool provides an easy way to test the complete OAuth2 flow and interact with your secured MCP server. = - GitHub OAuth2 federated login - Issues JWT access tokens (15-minute lifetime) - Refresh tokens (1-day lifetime) - Standard OAuth2/OIDC endpoints - JWT validation using JWKS from auth server - Audience claim validation - Two secured MCP tools - Stateless architecture

README

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

Secured MCP Server with Spring AI

A demonstration of securing a Model Context Protocol (MCP) server using Spring Authorization Server and GitHub OAuth2. Users authenticate with GitHub, receive a JWT token, and use it to call secured MCP tools.

Based on the article by Daniel Garnier-Moiroux: https://spring.io/blog/2025/09/30/spring-ai-mcp-server-security

Architecture

┌─────────────┐
│   GitHub    │ (Identity Provider)
└──────┬──────┘
       │
       ▼
┌────────────────────────┐
│  Authorization Server  │ (Port 9000)
│  - GitHub OAuth Login  │
│  - Issues JWT tokens   │
└──────┬─────────────────┘
       │
       ▼
┌─────────────┐  Authorization: Bearer    ┌──────────────┐
│ MCP Client  │──────────────────────────────► │  MCP Server  │ (Port 8080)
└─────────────┘                                │  - 2 Tools   │
                                               └──────────────┘

Project Structure

mcps/
├── pom.xml                                   # Parent POM
├── mvnw                                      # Maven wrapper
│
├── authorization-server/                     # Port 9000
│   └── src/main/java/dev/danvega/authserver/
│       ├── AuthServerApplication.java        # Main application
│       ├── SecurityConfig.java               # OAuth2 + GitHub login
│       └── application.yml                   # Configuration
│
└── mcp-server/                               # Port 8080
    └── src/main/java/dev/danvega/mcps/
        ├── Application.java                  # Main application
        ├── McpServerSecurityConfig.java      # JWT validation
        └── McpToolsService.java              # MCP tools (echo, getCurrentUser)

Quick Start

1. Prerequisites

  • Java 21+
  • Maven 3.6+
  • GitHub account

2. Create a GitHub OAuth App

  1. Go to GitHub Developer Settings
  2. Create a New OAuth App:
    • Application name: MCP Authorization Server
    • Homepage URL: http://localhost:9000
    • Callback URL: http://localhost:9000/login/oauth2/code/github
  3. Save the Client ID and Client Secret

3. Set Environment Variables

export GITHUB_CLIENT_ID="your-github-client-id"
export GITHUB_CLIENT_SECRET="your-github-client-secret"

4. Build and Run

# Build both modules
./mvnw clean install

# Terminal 1: Start Authorization Server (must start first!)
./mvnw spring-boot:run -pl authorization-server

# Terminal 2: Start MCP Server
./mvnw spring-boot:run -pl mcp-server

The authorization server runs on port 9000, MCP server on port 8080.

Testing with MCP Inspector

The MCP Inspector tool provides an easy way to test the complete OAuth2 flow and interact with your secured MCP server.

Available MCP Tools

GitHub에서 전체 README 보기

설치

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

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