MCP Code Expert System

by tomsiwik
Verified

local-only server

The server can only run on the client’s local machine because it depends on local resources.

Integrations

  • Supports environment configuration through .env files, enabling customization of knowledge graph settings and Ollama configuration parameters.

  • Provides integration with Ollama for AI-powered code reviews using local models, allowing the MCP server to utilize Ollama's capabilities to generate expert code reviews based on different programming principles.

MCP 코드 전문가 시스템

모델 컨텍스트 프로토콜(MCP)을 사용하는 Python 기반 코드 검토 시스템입니다. Martin Fowler와 Robert C. Martin(Uncle Bob)과 같은 전문가 페르소나를 시뮬레이션하여 코드 검토 기능을 제공합니다.

특징

  • Martin Fowler의 리팩토링 원칙에 기반한 코드 검토
  • Robert C. Martin의 Clean Code 원칙에 기반한 코드 검토
  • 코드, 리뷰 및 관계의 지식 그래프 저장
  • AI 기반 리뷰를 위한 Ollama와의 통합
  • 웹 통합을 위한 서버 측 이벤트(SSE) 지원

필수 조건

파이썬 3.10+

이 프로젝트에는 Python 3.10 이상이 필요합니다.

올라마

AI 기반 코드 검토에는 Ollama가 필요합니다.

  1. 플랫폼에 Ollama를 설치하세요:
    • macOS : ollama.com 에서 다운로드
    • 리눅스 : curl -fsSL https://ollama.com/install.sh | sh
    • Windows : Linux 지침을 통한 Windows WSL2 지원
  2. 추천 모델을 끌어오세요:지엑스피1
  3. Ollama 서버를 시작합니다:
    ollama serve

설치

종속성을 설치하고 가상 환경을 생성하려면 설치 스크립트를 실행하세요.

chmod +x setup.sh ./setup.sh

구성

.env 파일을 편집하여 구성합니다(필요한 경우 .env.example 에서 생성):

# Knowledge Graph Settings KNOWLEDGE_GRAPH_PATH=data/knowledge_graph.json # Ollama Configuration (local AI models) OLLAMA_HOST=http://localhost:11434 OLLAMA_MODEL=llama3:8b

용법

서버 실행

표준 모드(커서 통합용)

source .venv/bin/activate python server.py

HTTP/SSE 모드(웹 통합용)

source .venv/bin/activate python server.py --transport sse

이렇게 하면 SSE 전송을 위해 http://localhost:8000/sse 에서 서버가 시작됩니다.

사용자 정의 포트의 경우:

python server.py --transport sse --port 9000

커서에 설치

Cursor IDE에 설치하려면:

source .venv/bin/activate mcp install server.py --name "Code Expert System"

사용 가능한 도구

서버는 다음 도구를 제공합니다.

  • ask_martin : Martin Fowler에게 코드 검토 및 리팩토링 제안 요청
  • ask_bob : Clean Code 원칙에 따라 코드를 검토해 달라고 Robert C. Martin(Bob 삼촌)에게 요청하세요.
  • read_graph : 지식 그래프 전체를 읽습니다.
  • search_nodes : 지식 그래프에서 노드 검색
  • open_nodes : 이름으로 특정 노드를 엽니다.

사용 예

Martin Fowler와 함께 코드 조각을 검토하려면:

{ "code": "function calculateTotal(items) {\n var total = 0;\n for (var i = 0; i < items.length; i++) {\n total += items[i].price;\n }\n return total;\n}", "language": "javascript", "description": "Calculate the total price of items" }

프로젝트 구조

  • server.py : MCP 통합을 통한 메인 서버 구현
  • experts/ : 코드 검토 기능을 구현하는 전문가 모듈
    • __init__.py : 공유 모델 및 인터페이스
    • martin_fowler/ : Martin Fowler 전문가 구현
    • robert_c_martin/ : Robert C. Martin 전문가 구현
  • knowledge_graph.py : 코드와 리뷰를 저장하기 위한 지식 그래프
  • ollama_service.py : AI 기반 리뷰를 위한 Ollama와의 통합
  • examples/ : 다양한 언어로 검토할 수 있는 예제 코드
  • requirements.txt : Python 종속성
  • setup.sh : 설치 스크립트

건축학

이 시스템은 모듈식 아키텍처를 따릅니다.

  1. 서버 계층 : MCP 프로토콜 통신을 처리하고 요청을 라우팅합니다.
  2. 전문가 계층 : 각 전문가에 대한 코드 검토 논리를 캡슐화합니다.
  3. 서비스 계층 : AI 통합 및 지식 그래프 기능 제공

각 전문가는 일관된 처리와 새로운 전문가의 쉬운 추가를 가능하게 하는 표준 인터페이스를 구현합니다.

특허

MIT

-
security - not tested
F
license - not found
-
quality - not tested

Martin Fowler와 Robert C. Martin과 같은 시뮬레이션된 전문가 페르소나를 통해 AI 기반 코드 검토를 제공하는 Python 기반 시스템으로, 모델 컨텍스트 프로토콜(MCP)을 사용합니다.

  1. Features
    1. Prerequisites
      1. Python 3.10+
      2. Ollama
    2. Installation
      1. Configuration
        1. Usage
          1. Running the Server
          2. Installing in Cursor
          3. Available Tools
          4. Example Usage
        2. Project Structure
          1. Architecture
            1. License
              ID: nbrs3glfk1