Cover image
Try Now
2025-04-10

3 years

Works with Finder

1

Github Watches

23

Github Forks

12

Github Stars

파이썬으로 MCP Agent 만들기

YouTube 검색, 요약, 채널 분석 기능을 갖춘 유튜브 에이전트를 MCP로 구현한 예제입니다.

MCP (Model Context Protocol) 소개

  • AI가 외부 데이터의 도구(Tools)에 효과적으로 연결할 수 있는 표준화된 방식
  • 특히 다양한 도구의 표준화된 연결로 많이 활용되고 있음
    • MCP Server: 사용할 수 있는 도구(tool)를 정의하고 제공하는 역할
    • MCP Client: 정의된 도구를 불러와 사용 (Claude Desktop, Cursor, OpenAI Agents SDK)
  • 이번 예제에서는 유튜브 컨텐츠 분석을 위한 MCP Server를 만들어보고, OpenAI Agents SDK 기반의 MCP Client와도 연결해볼 예정입니다.

image

초기 셋팅

  1. 레포지토리 clone 또는 다운로드하기

    git clone https://github.com/dabidstudio/python-mcp-agent.git
    cd python-mcp-agent
    
  2. OpenAI 키 발급

  3. YouTube Data API Key 발급

  4. .env.example를 복사한 후 API 키를 입력하고 .env로 저장

    OPENAI_API_KEY=api키_입력
    YOUTUBE_API_KEY=api_키_입력
    
  5. 파이썬 가상환경 설정

    python -m venv venv
    venv\Scripts\activate # Mac은 source venv/bin/activate  
    
  6. 패키지 설치

    pip install mcp openai-agents streamlit youtube-transcript-api python-dotenv requests
    

MCP 클라이언트 연동을 위한 준비

Claude, Cursor와 같은 MCP 클라이언트 애플리케이션에서 로컬 MCP 서버를 연동하려면,
서버 실행에 필요한 Python 실행 파일 경로MCP 서버 스크립트 경로를 JSON 설정에 입력해야 합니다.

  • 내 경로에 알맞게 mcp.json을 수정해둡니다.

경로 구성 예시

✅ Windows 예시

(예: 프로젝트 폴더가 C:\projects\dabidstudio_videos\python_mcp_agent인 경우)

주의: Windows에서는 JSON 문법상 \ 대신 \\ (역슬래시 두 번)을 사용해야 합니다.

{
  "mcpServers": {
    "mcp-test": {
      "command": "C:\\projects\\dabidstudio_videos\\python_mcp_agent\\venv\\Scripts\\python.exe",
      "args": [
        "C:\\projects\\dabidstudio_videos\\python_mcp_agent\\2_mcp_server.py"
      ]
    }
  }
}

✅ macOS / Linux 예시

(예: 프로젝트 폴더가 /Users/yourname/projects/python_mcp_agent인 경우)

{
  "mcpServers": {
    "mcp-test": {
      "command": "/Users/yourname/projects/python_mcp_agent/venv/bin/python",
      "args": [
        "/Users/yourname/projects/python_mcp_agent/2_mcp_server.py"
      ]
    }
  }
}

폴더 구조

python-mcp-agent/
├── 1_mcp_server_functions.ipynb   # MCP 서버 함수 예제 노트북
├── 2_mcp_server.py                # MCP 서버 구현 예제
├── 3_openai_agents_basics.py      # OpenAI Agent 기본 예제
├── 4_mcp_client.py                # Streamlit MCP Client 예제
├── .env.example                   # 환경변수 예제 파일
└── mcp.json                       # MCP 서버 설정 파일

相关推荐

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • Yusuf Emre Yeşilyurt
  • I find academic articles and books for research and literature reviews.

  • Carlos Ferrin
  • Encuentra películas y series en plataformas de streaming.

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://zenepic.net
  • Embark on a thrilling diplomatic quest across a galaxy on the brink of war. Navigate complex politics and alien cultures to forge peace and avert catastrophe in this immersive interstellar adventure.

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • https://reddgr.com
  • Delivers concise Python code and interprets non-English comments

  • 林乔安妮
  • A fashion stylist GPT offering outfit suggestions for various scenarios.

  • ShrimpingIt
  • Micropython I2C-based manipulation of the MCP series GPIO expander, derived from Adafruit_MCP230xx

  • GeyserMC
  • A library for communication with a Minecraft client/server.

  • 1Panel-dev
  • 💬 MaxKB is an open-source AI assistant for enterprise. It seamlessly integrates RAG pipelines, supports robust workflows, and provides MCP tool-use capabilities.

  • Mintplex-Labs
  • The all-in-one Desktop & Docker AI application with built-in RAG, AI agents, No-code agent builder, MCP compatibility, and more.

  • GLips
  • MCP server to provide Figma layout information to AI coding agents like Cursor

  • Dhravya
  • Collection of apple-native tools for the model context protocol.

  • patchy631
  • In-depth tutorials on LLMs, RAGs and real-world AI agent applications.

  • idosal
  • Put an end to code hallucinations! GitMCP is a free, open-source, remote MCP server for any GitHub project

    Reviews

    1 (1)
    Avatar
    user_oRrxPTRe
    2025-04-17

    I've been using the python_mcp_agent from dabidstudio and it has significantly streamlined my automation tasks. The seamless integration and comprehensive documentation made it incredibly easy to get started right away. Definitely check it out on GitHub!