Skip to content

[feature] mcp 토큰 발급 router 추가#54

Merged
GoGangH merged 1 commit intomainfrom
dev
Feb 24, 2026
Merged

[feature] mcp 토큰 발급 router 추가#54
GoGangH merged 1 commit intomainfrom
dev

Conversation

@GoGangH
Copy link
Collaborator

@GoGangH GoGangH commented Feb 24, 2026

#️⃣연관된 이슈

ex) #이슈번호, #이슈번호

📝작업 내용

이번 PR에서 작업한 내용을 간략히 설명해주세요(이미지 첨부 가능)

스크린샷 (선택)

💬리뷰 요구사항(선택)

리뷰어가 특별히 봐주었으면 하는 부분이 있다면 작성해주세요

ex) 메서드 XXX의 이름을 더 잘 짓고 싶은데 혹시 좋은 명칭이 있을까요?

Summary by CodeRabbit

릴리스 노트

  • 새로운 기능

    • MCP 토큰 엔드포인트 추가로 사용자가 토큰을 발급받고 관리할 수 있습니다.
    • 신규 사용자에게 30일 유효 기간의 무료 체험 구독 자동 생성 기능 추가.
  • 버그 수정

    • 휴면 계정에 대한 계정 활동 검증 강화.
    • 만료된 구독 자동 비활성화 처리 추가.
  • 개선 사항

    • 구독 시스템의 데이터 모델 확장으로 토큰 관리 지원.
    • 사용자 계정 관리 로직 개선.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 24, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8e5ecc8 and f5d4663.

📒 Files selected for processing (5)
  • alembic/versions/e2f3a4b5c6d7_add_mcp_token_to_subscriptions.py
  • src/auth/service.py
  • src/subscription/models.py
  • src/subscription/router.py
  • src/users/service.py

Walkthrough

구독 시스템에 MCP 토큰 관리 기능을 추가합니다. 새로운 토큰 필드를 Subscription 모델에 추가하고, 토큰 발급 엔드포인트를 구현하며, 사용자 삭제를 soft delete로 변경합니다.

Changes

Cohort / File(s) Summary
데이터베이스 마이그레이션
alembic/versions/e2f3a4b5c6d7_add_mcp_token_to_subscriptions.py
subscriptions 테이블에 nullable token 컬럼을 추가하는 새로운 Alembic 리비전을 정의합니다.
구독 모델 확장
src/subscription/models.py
Subscription 모델에 nullable string 타입의 token 필드를 추가합니다.
MCP 토큰 엔드포인트
src/subscription/router.py
새로운 GET /me/mcp-token 엔드포인트를 추가하여 토큰 발급/재사용 로직을 구현하고, 만료된 구독을 자동으로 비활성 처리합니다.
인증 서비스 정리
src/auth/service.py
Subscription 관련 import를 제거하고, 새 사용자에 대한 자동 MCP free-trial 구독 생성을 제거하며, 비활성 OAuth 사용자에 대한 검증을 추가합니다.
사용자 삭제 로직 변경
src/users/service.py
delete_user 함수를 hard delete에서 soft delete로 변경하여 사용자 정보를 유지하면서 비활성 처리합니다.

Sequence Diagram(s)

sequenceDiagram
    actor Client
    participant Server
    participant DB
    participant TokenService

    Client->>Server: GET /me/mcp-token
    Server->>DB: 사용자의 활성 구독 조회
    
    alt 활성 구독이 없는 경우
        Server->>DB: FREE_TRIAL 구독 생성
        Server->>TokenService: 새 토큰 생성
        TokenService-->>Server: 토큰 반환
        Server->>DB: 토큰 저장
    else 활성 구독이 있는 경우
        alt 토큰이 존재하는 경우
            Server->>Server: 기존 토큰 재사용
        else 토큰이 없는 경우
            Server->>TokenService: 새 토큰 생성
            TokenService-->>Server: 토큰 반환
            Server->>DB: 토큰 저장
        end
    else 구독이 만료된 경우
        Server-->>Client: 403 Forbidden 응답
    end
    
    Server-->>Client: McpTokenResponse (토큰 포함)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • [Feature] MCP 서버 로직 추가 #50 #51: 동일한 구독 관련 코드 경로(src/subscription/models.py, src/subscription/router.py, src/auth/service.py)를 수정하며 MCP 구독/토큰 동작을 다룹니다.

Suggested labels

feature

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dev

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@GoGangH GoGangH merged commit 296b1ad into main Feb 24, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant