반응형

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 아키랩 프로젝트에 활용
반응형

오늘 한 일 요약

ecc-agentshield로 Claude Code 환경 보안 감사를 진행하고, 발견된 Critical 이슈들을 수동으로 수정했습니다.


1. AgentShield 보안 스캔 실행

npx ecc-agentshield scan

초기 결과 (수정 전)

항목 점수

종합 등급 F (7/100)
Secrets 0
Permissions 36
Hooks 0
MCP Servers 0
Agents 0
  • 전체 발견: 968개 (Critical 24, High 162, Medium 260, Low 513, Info 9)
  • 자동 수정 가능: 69개
  • 발견된 스킬: 243개 (계측 없음)

2. 수정 내용

~/.claude/mcp-configs/mcp-servers.json

YOUR_*_HERE 형태의 하드코딩 플레이스홀더를 환경변수 참조 형식으로 변경:

서버 변경 전 변경 후

jira "YOUR_JIRA_URL_HERE" "${JIRA_URL}"
jira "YOUR_JIRA_EMAIL_HERE" "${JIRA_EMAIL}"
browser-use "YOUR_BROWSER_USE_KEY_HERE" "${BROWSER_USE_API_KEY}"
confluence "YOUR_CONFLUENCE_URL_HERE" "${CONFLUENCE_BASE_URL}"
confluence "YOUR_EMAIL_HERE" "${CONFLUENCE_EMAIL}"

~/.claude/settings.json

기본 permissions 블록 추가:

"permissions": {
  "allow": [
    "Read",
    "Glob",
    "Grep",
    "Bash(git *)",
    "Bash(npm run *)",
    "Bash(npx *)"
  ],
  "deny": []
}

3. 수정 후 결과

npx ecc-agentshield scan

항목 수정 전 수정 후

종합 점수 7/100 25/100
Secrets 0 100
Permissions 36 26
Hooks 0 0
MCP Servers 0 0

Secrets 항목 완전 해결


4. 남은 이슈

  • Hooks (0/100): PostToolUse 훅 미설정 → /hookify로 개선 가능
  • MCP Servers (0/100): 일부 플레이스홀더 잔존 (supabase project-ref 등)
  • Permissions (26/100): 더 세밀한 권한 설정 필요
  • Agents (0/100): 에이전트 계측(instrumentation) 미설정
  • Skill Health: 243개 스킬 모두 미계측 (versioned/rollback-ready 0개)

관련 명령어

# 보안 스캔
npx ecc-agentshield scan

# 자동 수정 시도
npx ecc-agentshield scan --fix

# 훅 설정
/hookify

+ Recent posts