Skip to main content
Glama
AmaimaKhalidSethi

Multi-Server FastMCP PR Reviewer

Multi-Server FastMCP PR 리뷰어

제로 비용, 멀티 서버 모델 컨텍스트 프로토콜(MCP) 제품군으로, 통합 게이트웨이와 LangGraph 기반 자동 PR 리뷰 에이전트를 갖추고 있습니다. 사용되는 모든 도구/API는 무료 티어 자격을 충족합니다(GitHub PAT, Groq LLM).

아키텍처

Claude Desktop / Agent
        |
        v
  FastMCP Gateway  (namespaces: code., gh., doc. — dot-separated per MCP tool-naming spec)
   /      |       \
  v       v        v
Code    GitHub   Documentation
Intel   Server   Server (Groq)
(AST+Radon)(PyGithub)
   \       |       /
    Shared Security & Audit Layer
    (API key auth, SQLite WAL, rate limiting)

Related MCP server: orchestrator-mcp

프로젝트 구조

mcp-pr-reviewer/
├── core/
│   └── security.py        # auth + rate limit + SQLite audit decorator
├── servers/
│   ├── code_server.py      # AST/radon static analysis (no external API)
│   ├── github_server.py    # PyGithub-backed PR/issue/commit tools
│   └── doc_server.py       # Groq-backed docstring/README/API doc generation
├── gateway/
│   └── gateway.py          # unifies all three servers under code:/gh:/doc: namespaces
├── agent/
│   └── workflow.py         # LangGraph PR-review pipeline (fetch → analyze → doc → publish)
├── data/                    # SQLite audit_log.db lives here (gitignored)
├── docker-compose.yml
├── Dockerfile
├── requirements.txt
├── .env.example
└── claude_desktop_config.example.json

설정

python -m venv .venv
source .venv/bin/activate        # Windows: .venv\Scripts\activate
pip install -r requirements.txt

cp .env.example .env
# edit .env with your real MCP_API_KEY, GITHUB_TOKEN, GROQ_API_KEY

로컬에서 실행하기 전에 환경 변수를 로드하세요. 예:

export $(grep -v '^#' .env | xargs)   # macOS/Linux

실행

개별 서버 (stdio, 로컬 테스트용)

python servers/code_server.py
python servers/github_server.py
python servers/doc_server.py

게이트웨이

fastmcp run gateway/gateway.py:gateway

Docker

docker compose up --build

Claude Desktop 통합

claude_desktop_config.example.json을 Claude Desktop 설정(claude_desktop_config.json)에 복사하고, gateway/gateway.py의 절대 경로를 수정한 후 실제 자격 증명을 입력하세요. Claude Desktop을 다시 시작하면 적용됩니다.

테스트 체크리스트

1. 스키마 검증

fastmcp inspect servers/code_server.py
fastmcp inspect servers/github_server.py
fastmcp inspect servers/doc_server.py

2. 보안 / 감사 검증

# Should raise 401 Unauthorized
CLIENT_API_KEY=wrong_key python -c "from servers.code_server import analyse_code; analyse_code('x = 1')"

# Inspect the WAL SQLite audit log
sqlite3 data/audit_log.db "SELECT * FROM access_log ORDER BY id DESC LIMIT 5;"

3. 종단간 PR 리뷰

python -c "
import asyncio
from agent.workflow import app

async def run():
    result = await app.ainvoke({
        'repo': 'your-username/your-repo',
        'pr_number': 1
    })
    print('Review published:', result['issue_url'])

asyncio.run(run())
"

참고 사항 / 프로덕션에서 사용하기 전에 확인해야 할 사항

  • core/security.py의 bucket은 단일 프로세스 전역 TokenBucket입니다. 서버의 모든 도구가 동일한 60/min 예산을 공유하므로, 세분화된 제한이 필요한 경우 도구별 또는 클라이언트별 버킷으로 분할하세요.

  • secure_tool은 FastAPI의 HTTPException을 발생시키는데, 이는 FastMCP 전송이 실제로 FastAPI/ASGI 뒤에서 실행되는 경우에만 HTTP 상태 코드로 깔끔하게 매핑됩니다. 일반 stdio로 서버를 실행하는 경우 MCP 계층에서 이를 캐치하거나 전송에 적합한 예외로 대체하세요.

  • .env에서 MCP_API_KEY, GITHUB_TOKEN, GROQ_API_KEY를 실제 비밀 관리자로 교체하세요. .env는 개발 환경에서만 사용하는 것이 좋습니다.

  • GitHub의 코드 검색 API는 코어 API보다 훨씬 낮은 제한이 적용됩니다(30 req/min 대 5,000 req/hr). 부하가 걸리면 search_repo_code가 먼저 이 제한에 도달할 것입니다.

Related MCP Connectors

Related MCP Servers