반응형

2026년 4월 27일 | 제주 AI 아키랩

📋 목표

Python MCP 서버를 클라우드에 배포해서 어디서든 Claude Desktop과 연결하여 사용하기


⚙️ 환경 설정

GCP 설정 완료

  • 계정: woogim@gmail.com
  • 프로젝트: gen-lang-client-########## (Google AI Studio 자동 생성)
  • 리전: asia-northeast3 (서울)
  • : asia-northeast3-a

로컬 파일 구조 (C:\\Users\\[사용자]\\Desktop\\mcp_test)

mcp_test/
├── server.py          # MCP 서버 메인 파일
├── Dockerfile         # 컨테이너 설정
├── requirements.txt   # 패키지 목록
├── server.js
└── client.js

server.py 최종 버전

import os
from mcp.server.fastmcp import FastMCP

mcp = FastMCP("add-mcp-http")

@mcp.tool()
def add(a: int, b: int) -> int:
    """Add two numbers"""
    return a + b

if __name__ == "__main__":
    port = int(os.environ.get("PORT", 8080))
    mcp.run(transport="sse")

requirements.txt

mcp[cli]
uvicorn

❌ GCP Cloud Run 배포 실패

시도한 것들

  1. API 활성화: run.googleapis.com, cloudbuild.googleapis.com, artifactregistry.googleapis.com ✅
  2. IAM 권한 추가: artifactregistry.reader 역할 부여 ✅
  3. 새 프로젝트 생성: jeju-mcp-server-2026 생성 후 시도 ✅
  4. 이미지 직접 지정 배포 시도 ✅
  5. 다른 리전(us-central1) 시도 ✅

실패 원인

ERROR: Container import failed.
reason: ContainerImageImportFailed

결론: gen-lang-client-* 프로젝트는 Google AI Studio 자동 생성 프로젝트로 Cloud Run 컨테이너 실행에 내부 제한이 있음. 새 프로젝트도 동일 계정 레벨 제한으로 실패.


✅ Railway 배포 성공!

배포 과정

  1. GitHub repo 생성: woogim-afk/mcp-test
  2. 코드 push (폴더 구조: Desktop/mcp_test/)
  3. Railway 접속 → GitHub 연동 → 자동 배포

배포 결과

항목 값

플랫폼 Railway
상태 🟢 Online
URL https://mcp-test-production-f362.up.railway.app
SSE 엔드포인트 https://mcp-test-production-f362.up.railway.app/sse

🔌 Claude Desktop 연결 방법

설정 파일 위치

C:\\Users\\[사용자]\\AppData\\Roaming\\Claude\\claude_desktop_config.json

설정 내용

{
  "mcpServers": {
    "my-server": {
      "url": "<https://mcp-test-production-f362.up.railway.app/sse>",
      "transport": "sse"
    }
  }
}

연결 후 테스트

Claude Desktop에서 add(3, 5) 입력 → 결과: 8


📝 배운 점

  • Google AI Studio 자동 생성 프로젝트(gen-lang-client-*)는 Cloud Run 사용 불가
  • Railway는 GitHub 연동만으로 Dockerfile 자동 감지 후 배포 가능
  • FastMCP의 run() 메서드는 버전에 따라 host, port 파라미터 지원 여부가 다름
  • Cloud Run 배포 시 0.0.0.0:8080 바인딩 필수

🔜 다음 단계

  • Claude Desktop 앱 설치 및 MCP 연결 테스트
  • MCP 서버에 더 많은 도구(tool) 추가
  • 제주 AI 아키랩 프로젝트에 활용

+ Recent posts