Skip to main content
Glama

MCP Python Tutorial

MCP 파이썬 튜토리얼

모의 데이터가 포함된 간단한 로컬 DB를 갖춘 Python의 MCP용 튜토리얼 앱

설치 및 실행

Smithery를 통해 설치

Smithery를 통해 Claude Desktop용 Python MCP 튜토리얼 서버를 자동으로 설치하려면:

지엑스피1

수동 설치

  1. 이 저장소를 복제하세요
  2. 종속성 설치:
pip install -r requirements.txt
  1. MCP 서버를 개발 모드로 실행:
mcp dev localdb_app.py
  1. MCP 서버의 기본 포트는 5173 입니다. http://localhost:5173 에 접속하세요.

MCP 기능

이 튜토리얼 앱은 핵심 MCP 개념을 보여줍니다. tutorial_app/mcp_server.py 에서 역할별 주석(annotation-per-role)을 확인할 수 있습니다.

@mcp.resource

기본적으로 이 주석은 RESTAPI의 GET 과 마찬가지로 에이전트가 리소스를 "가져오는" 것에 대한 것입니다.

  • users://all - 모든 사용자 가져오기
  • users://{user_id}/profile - 사용자 프로필 가져오기
  • posts://all - 모든 게시물 가져오기
  • posts://{post_id} - ID로 게시물 가져오기

@mcp.tool

이는 RESTAPI의 POST 와 마찬가지로 에이전트가 새 리소스를 "생성"하는 것과 관련이 있습니다.

  • create_user - 새로운 사용자 생성
  • create_post - 새 게시물 만들기
  • search_posts - 제목이나 내용으로 게시물 검색

@mcp.prompt

이는 LLM과 편리하게 상호작용하기 위한 재사용 가능한 템플릿입니다.

  • user_profile_analysis - 사용자 프로필 분석 생성
  • post_feedback - 게시물 피드백을 위한 대화형 프롬프트

[!NOTE] 추가 주석은 https://github.com/modelcontextprotocol/python-sdk?tab=readme-ov-file#core-concepts 에서 확인하세요.

클라이언트에 연결

MCP 서버를 설정한 후에는 MCP 서버를 사용하여 에이전트를 구축할 LLM 클라이언트가 필요합니다. 다음 가이드는 Claude Desktop을 클라이언트로 연결하는 데 도움이 됩니다.

  1. Claude Desktop은 uv 사용하여 MCP 서버 종속성을 설치합니다. 먼저 uv 설치하세요.
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
  1. uv 사용하여 MCP 서버 종속성을 설치합니다.
# Create virtual environment and activate it uv venv .venv\Scripts\activate uv pip install -r requirements.txt
  1. Claude Desktop 다운로드:
  1. claude_desktop_config.json 파일을 찾거나 만드세요. 위치는 OS마다 다릅니다.
  • 윈도우:
C:\Users\%USER%\AppData\Roaming\Claude\claude_desktop_config.json
  • MacOS/리눅스:
~/Library/Application\ Support/Claude/claude_desktop_config.json
  1. claude_desktop_config.jsonmcpServers 속성을 추가합니다.
{ "mcpServers": { "local_db": { "command": "uv", "args": [ "--directory", "/ABSOLUTE/PATH/TO/PARENT/FOLDER/weather", "run", "localdb_app.py" ] } } }

참고: 각기 다른 관심사와 전문 지식을 가진 여러 MCP 서버를 배포할 수 있습니다. 이렇게 관심사를 분리하는 것이 단일 MCP 서버에 모든 것을 구현하는 것보다 낫습니다.

  1. Claude Desktop을 다시 시작합니다.
-
security - not tested
F
license - not found
-
quality - not tested

local-only server

The server can only run on the client's local machine because it depends on local resources.

로컬 데이터베이스를 갖춘 간단한 사용자/게시물 시스템에 대한 리소스 처리, 도구 작업, 재사용 가능한 프롬프트를 갖춘 Python으로 MCP 구현을 보여주는 데모 서버입니다.

  1. 설치 및 실행
    1. Smithery를 통해 설치
    2. 수동 설치
  2. MCP 기능
    1. @mcp.resource
    2. @mcp.tool
    3. @mcp.prompt
  3. 클라이언트에 연결

    Related MCP Servers

    • A
      security
      A
      license
      A
      quality
      An MCP server to run commands.
      Last updated -
      2
      265
      150
      TypeScript
      MIT License
      • Apple
    • -
      security
      A
      license
      -
      quality
      A Python-based server that implements the Model Context Protocol to interface with Claude Desktop as an MCP client, supporting interaction through efficient memory management.
      Last updated -
      1
      Python
      MIT License
    • -
      security
      F
      license
      -
      quality
      This is an MCP server that facilitates building tools for interacting with various APIs and workflows, supporting Python-based development with potential for customizable prompts and user configurations.
      Last updated -
      Python
    • A
      security
      A
      license
      A
      quality
      A server that provides a persistent Python REPL environment through the MCP protocol, allowing execution of Python code, variable management, and package installation.
      Last updated -
      3
      3
      Python
      MIT License

    View all related MCP servers

    MCP directory API

    We provide all the information about MCP servers via our MCP API.

    curl -X GET 'https://glama.ai/api/mcp/v1/servers/jhj0517/mcp-python-tutorial'

    If you have feedback or need assistance with the MCP directory API, please join our Discord server