MCP 파이썬 튜토리얼
모의 데이터가 포함된 간단한 로컬 DB를 갖춘 Python의 MCP용 튜토리얼 앱
설치 및 실행
Smithery를 통해 설치
Smithery를 통해 Claude Desktop용 Python MCP 튜토리얼 서버를 자동으로 설치하려면:
지엑스피1
수동 설치
- 이 저장소를 복제하세요
- 종속성 설치:
- MCP 서버를 개발 모드로 실행:
- 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을 클라이언트로 연결하는 데 도움이 됩니다.
- Claude Desktop은
uv
사용하여 MCP 서버 종속성을 설치합니다. 먼저uv
설치하세요.
uv
사용하여 MCP 서버 종속성을 설치합니다.
- Claude Desktop 다운로드:
claude_desktop_config.json
파일을 찾거나 만드세요. 위치는 OS마다 다릅니다.
- 윈도우:
- MacOS/리눅스:
claude_desktop_config.json
에mcpServers
속성을 추가합니다.
참고: 각기 다른 관심사와 전문 지식을 가진 여러 MCP 서버를 배포할 수 있습니다. 이렇게 관심사를 분리하는 것이 단일 MCP 서버에 모든 것을 구현하는 것보다 낫습니다.
- Claude Desktop을 다시 시작합니다.
This server cannot be installed
local-only server
The server can only run on the client's local machine because it depends on local resources.
로컬 데이터베이스를 갖춘 간단한 사용자/게시물 시스템에 대한 리소스 처리, 도구 작업, 재사용 가능한 프롬프트를 갖춘 Python으로 MCP 구현을 보여주는 데모 서버입니다.
Related MCP Servers
- AsecurityAlicenseAqualityAn MCP server to run commands.Last updated -2265150TypeScriptMIT License
- -securityAlicense-qualityA 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 -1PythonMIT License
- -securityFlicense-qualityThis 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
- AsecurityAlicenseAqualityA server that provides a persistent Python REPL environment through the MCP protocol, allowing execution of Python code, variable management, and package installation.Last updated -33PythonMIT License