티스토리 뷰

728x90

이 문서는 codemcp의 공식 README(https://github.com/ezyang/codemcp)와 실제 설치 경험을 기반으로 작성되었습니다.

1. codemcp란?

codemcp는 Claude Desktop과 함께 동작하는 AI 기반 페어 프로그래밍 도구입니다. 이를 통해 코드 작성, 버그 수정, 리팩토링을 자동화할 수 있으며, Git을 활용하여 변경 사항을 관리할 수 있습니다.

주요 기능

  • Claude에게 코드 수정 요청 가능
  • Git을 통해 변경 사항 자동 커밋 및 롤백 지원
  • 코드 포매팅 및 테스트 자동 실행 (codemcp.toml 설정)
  • IDE에 종속되지 않으며 다양한 개발 환경에서 활용 가능

2. 설치 방법

2.1 uv 패키지 매니저 설치

codemcpuv 패키지 매니저를 사용합니다. 아래 명령어를 실행하여 uv를 설치하세요.

macOS/Linux

curl -LsSf https://astral.sh/uv/install.sh | sh

Windows (PowerShell 실행)

powershell -c "irm https://astral.sh/uv/install.ps1 | iex"

설치 확인:

uv --version

2.2 codemcp 설치

uv pip install --force-reinstall git+https://github.com/ezyang/codemcp@prod

설치 확인:

uvx --from git+https://github.com/ezyang/codemcp@prod codemcp --help

3. Claude Desktop 설정

Claude Desktop에서 codemcp를 실행하도록 설정을 변경해야 합니다.

설정 파일 경로

  • macOS/Linux: ~/.config/claude_desktop/claude_desktop_config.json
  • Windows: %APPDATA%\claude_desktop\claude_desktop_config.json

설정 예제

{
  "mcpServers": {
    "codemcp": {
      "command": "/Users/사용자이름/.local/bin/uvx",
      "args": [
        "--from",
        "git+https://github.com/ezyang/codemcp@prod",
        "codemcp"
      ]
    }
  }
}

설정을 저장한 후 Claude Desktop을 다시 시작하세요.

4. 프로젝트 설정 (codemcp.toml 생성)

4.1 Git 프로젝트 디렉토리 이동

cd /path/to/your/project

4.2 codemcp.toml 파일 생성

vi codemcp.toml

4.3 예제 설정

format = ["./run_format.sh"]  # 코드 포매팅 스크립트 실행
test = ["./run_test.sh"]  # 테스트 실행 스크립트

5. Claude Desktop에서 프로젝트 설정

5.1 Claude Desktop 실행

open -a "Claude Desktop"

5.2 프로젝트 생성

  • "Projects" 탭 이동
  • 새 프로젝트 생성
  • Instructions 필드에 아래 내용 입력
Before doing anything, first init project $PROJECT_DIR.

6. Claude에게 코드 작업 요청하기

Claude에게 직접 코드 변경을 요청하면 codemcp가 자동으로 파일을 수정하고 Git에 커밋을 생성합니다.

예제 요청

함수 추가 요청

Please add a function in `utils.py` that calculates the factorial of a number.

버그 수정 요청

There is a bug in `data_processor.py` where the program crashes when the input is None. Please fix it.

코드 리팩토링 요청

Refactor the `get_user_data()` function in `models.py` to follow best practices and improve readability.

7. Git을 활용한 변경 사항 관리

7.1 변경 사항 확인

git status
git diff

7.2 변경 사항 적용

변경 사항 커밋

git commit -am "Applied changes from codemcp"

변경 사항 취소

git reset --keep main

8. 문제 해결 (Troubleshooting)

uvx 실행 오류

which uvx  # macOS/Linux
where uvx  # Windows

출력이 없으면 환경 변수 등록이 필요합니다.

macOS/Linux

echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

Windows

  1. Win + Rsysdm.cpl 입력 후 Enter
  2. "고급" → "환경 변수" 클릭
  3. C:\Users\사용자이름\AppData\Local\uv\ 추가 후 시스템 재부팅

9. 최종 요약

  1. uvcodemcp 설치
  2. claude_desktop_config.json 설정 변경
  3. codemcp.toml 생성 및 포맷팅, 테스트 명령어 지정
  4. Claude Desktop에서 프로젝트 연결 후 코드 작업 요청
  5. Git을 활용한 변경 사항 검토 및 적용

이제 AI를 활용하여 더욱 효율적으로 코드 작업을 수행할 수 있습니다.

728x90
댓글