MCP Python Tutorial
MCP 파이썬 튜토리얼
모의 데이터가 포함된 간단한 로컬 DB를 갖춘 Python의 MCP용 튜토리얼 앱
설치 및 실행
Smithery를 통해 설치
Smithery를 통해 Claude Desktop용 Python MCP 튜토리얼 서버를 자동으로 설치하려면:
지엑스피1
수동 설치
이 저장소를 복제하세요
종속성 설치:
pip install -r requirements.txtMCP 서버를 개발 모드로 실행:
mcp dev localdb_app.pyMCP 서버의 기본 포트는
5173입니다.http://localhost:5173에 접속하세요.
Related MCP server: xmcp Demo Application
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설치하세요.
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"uv사용하여 MCP 서버 종속성을 설치합니다.
# Create virtual environment and activate it
uv venv
.venv\Scripts\activate
uv pip install -r requirements.txtClaude Desktop 다운로드:
claude_desktop_config.json파일을 찾거나 만드세요. 위치는 OS마다 다릅니다.
윈도우:
C:\Users\%USER%\AppData\Roaming\Claude\claude_desktop_config.jsonMacOS/리눅스:
~/Library/Application\ Support/Claude/claude_desktop_config.jsonclaude_desktop_config.json에mcpServers속성을 추가합니다.
{
"mcpServers": {
"local_db": {
"command": "uv",
"args": [
"--directory",
"/ABSOLUTE/PATH/TO/PARENT/FOLDER/weather",
"run",
"localdb_app.py"
]
}
}
}참고: 각기 다른 관심사와 전문 지식을 가진 여러 MCP 서버를 배포할 수 있습니다. 이렇게 관심사를 분리하는 것이 단일 MCP 서버에 모든 것을 구현하는 것보다 낫습니다.
Claude Desktop을 다시 시작합니다.
This server cannot be deployed
Maintenance
Related MCP Connectors
Nifty's MCP server — exposes tasks, projects, messages, and files as tools for AI agents.
An MCP server that provides an API to LLMs to manage their JumpCloud resources.
MCP server for your apps' tools and custom tools, plus hosted AI agents and approval-gated workflows
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA minimal demonstration server showcasing MCP protocol capabilities including tools, resources, and prompts with basic examples like hello world functionality.1 npmMIT
- FlicenseNot gradedqualityDmaintenanceA demonstration MCP server showcasing the xmcp framework's structured approach to defining tools, prompts, and resources with automatic discovery from their respective directories.-
- FlicenseNot gradedqualityDmaintenanceA Python-based MCP server demonstrating tools for math calculations, time retrieval, and echo messages, along with resources and prompt templates.-
- FlicenseCqualityDmaintenanceA simple MCP server demonstrating resources, tools, and prompts using a local task list. It enables reading, creating, and analyzing tasks through MCP.1-