mcp_chat

blueworm-lee/mcp_chat

3.1

If you are the rightful owner of mcp_chat and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.

FastAPI MCP Chat is a Model Context Protocol-based chat service designed for efficient communication.

FastAPI MCP Chat

  • FastAPI 기반의 MCP(Model Context Protocol) 채팅 서비스입니다.
  • Host(UI), MCP Client, MCP Server를 완전히 분리시킨 데모입니다.
  • 본 데모에서 Host 부분을 빼거나 별도 API 엔드포인트로 연결하면 됩니다. (POST /chat/stream)
  • .env 파일 생성이 필요합니다.
    • GPT 키는 반드시 필요합니다 (ANTHROPIC 사용하더라도 비용절감을 위해 메시지 summary 부분에서 gpt-mini를 사용함)
    • ANTHROPIC 키는 옵션입니다

요구사항

  • Python 3.8+
  • uv - Python 패키지 관리자
  • Linux/macOS (systemd 지원)

설치 방법

1. uv 설치 (필요한 경우)

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

2. 프로젝트 클론

git clone https://github.com/blueworm-lee/mcp-chat.git
cd mcp-chat

3. 자동 설치

chmod +x install/install.sh
./install/install.sh

설치 스크립트는 다음 작업을 수행합니다:

  • Python 의존성 설치 (uv sync)
  • 로그 디렉토리 생성 (/var/log/mcp_chat)
  • systemd 서비스 등록

4. 환경 설정

.env 파일을 생성하세요:

OPENAI_API_KEY="sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
ANTHROPIC_API_KEY="sk-ant-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
TAVILY_API_KEY="tvly-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

참고:

  • OPENAI_API_KEY: 필수 - 메시지 요약에 사용
  • ANTHROPIC_API_KEY: 선택 - Claude 모델 사용 시 필요
  • TAVILY_API_KEY: 필수 - 웹 검색 기능 사용 시 필요 (검색 기능은 기본 tool로 넣음)

데몬 구동

서비스 관리

# 서비스 시작
sudo systemctl start mcp_client

# 서비스 중지
sudo systemctl stop mcp_client

# 서비스 재시작
sudo systemctl restart mcp_client

# 서비스 상태 확인
sudo systemctl status mcp_client

부팅 시 자동 시작

# 자동 시작 활성화
sudo systemctl enable mcp_client

# 자동 시작 비활성화
sudo systemctl disable mcp_client

로그 확인

# 실시간 로그 보기
sudo journalctl -u mcp_client -f

# 최근 로그 확인
sudo journalctl -u mcp_client --since "1 hour ago"

API 엔드포인트

  • POST /chat/stream - 스트리밍 채팅 API

개발 모드

개발 중에는 서비스 대신 직접 실행할 수 있습니다:

# 개발 서버 실행
uv run uvicorn main:app --host 0.0.0.0 --port 8000 --reload

트러블슈팅

서비스가 시작되지 않는 경우

# 서비스 상태 확인
sudo systemctl status mcp_client

# 상세 로그 확인
sudo journalctl -u mcp_client -n 50

환경 변수 문제

.env 파일이 프로젝트 루트에 있는지 확인하고, API 키가 올바른지 확인하세요.

라이선스

MIT License