MCP tutorial project with weather, time, and RAG servers
Project description
๐ค MCP (Model Context Protocol) Tutorial
์ ๋ฌธ์๋ฅผ ์ํ ์ฒด๊ณ์ ์ธ Model Context Protocol ํ์ต ๊ฐ์ด๋
๐ ํ๋ก์ ํธ ๊ฐ์
์ด ํํ ๋ฆฌ์ผ์ Model Context Protocol(MCP) ์ ์ฒ์ ์ ํ๋ ๊ฐ๋ฐ์๋ค์ ์ํ ์ค์ต ์ค์ฌ ํ์ต ์๋ฃ์ ๋๋ค. LangGraph์ MCP๋ฅผ ํตํฉํ์ฌ ๋ค์ํ ์ธ๋ถ ๋๊ตฌ์ ์๋น์ค๋ฅผ ํ์ฉํ๋ ๊ฐ๋ ฅํ AI ์์ด์ ํธ๋ฅผ ๊ตฌ์ถํ๋ ๋ฐฉ๋ฒ์ ๋จ๊ณ๋ณ๋ก ํ์ตํฉ๋๋ค.
๐ฏ ํ์ต ๋ชฉํ
- MCP์ ํต์ฌ ๊ฐ๋ ๊ณผ ์ํคํ ์ฒ ์ดํด
- FastMCP๋ฅผ ํ์ฉํ MCP ์๋ฒ ๊ฐ๋ฐ
- LangGraph์ MCP์ ํจ๊ณผ์ ์ธ ํตํฉ
- ๋ค์ค MCP ์๋ฒ ๊ด๋ฆฌ ๋ฐ ์ค์ผ์คํธ๋ ์ด์
- ์ค์ RAG ์์คํ ๊ตฌํ
๐ ์ฃผ์ ๊ธฐ๋ฅ
- ํ์คํ๋ ํ๋กํ ์ฝ: MCP ํ์ค์ ๋ฐ๋ฅด๋ ๋๊ตฌ ์ธํฐํ์ด์ค ๊ตฌํ
- ๋ค์ํ ์ ์ก ๋ฐฉ์: stdio ๋ฐ Streamable HTTP ์ง์
- ๋์ ๋๊ตฌ ๊ฒ์: ๋ฐํ์ ๋๊ตฌ ์๋ ๊ฒ์ ๋ฐ ๋ก๋
- ํ์ฅ ๊ฐ๋ฅํ ์ํคํ ์ฒ: ์ฌ๋ฌ MCP ์๋ฒ ๋์ ์ฐ๊ฒฐ ์ง์
- ์ค์ต ์ค์ฌ ํ์ต: Jupyter Notebook์ ํตํ ์ธํฐ๋ํฐ๋ธ ํ์ต
๐ ํ๋ก์ ํธ ๊ตฌ์กฐ
mcp-tutorial/
โโโ 01-LangGraph-MCP-Tutorial.ipynb # ๋ฉ์ธ ํํ ๋ฆฌ์ผ ๋
ธํธ๋ถ
โโโ server/ # MCP ์๋ฒ ๊ตฌํ์ฒด
โ โโโ mcp_server_local.py # ๋ก์ปฌ ๋ ์จ ์๋น์ค (stdio)
โ โโโ mcp_server_remote.py # ์๊ฒฉ ์๊ฐ ์๋น์ค (HTTP)
โ โโโ mcp_server_rag.py # RAG ์๋น์ค (๋ฒกํฐ ๊ฒ์)
โ โโโ rag/ # RAG ๊ด๋ จ ์ ํธ๋ฆฌํฐ
โ โโโ base.py
โ โโโ pdf.py
โ โโโ utils.py
โโโ assets/ # ์ด๋ฏธ์ง ๋ฐ ๋ฆฌ์์ค
โโโ pyproject.toml # ํ๋ก์ ํธ ์ค์
โโโ .env.example # ํ๊ฒฝ ๋ณ์ ์์
๐ ์ค์น ๋ฐฉ๋ฒ
์ฌ์ ์๊ตฌ์ฌํญ
- Python 3.11 ์ด์
- UV ํจํค์ง ๋งค๋์ (์ค์น ๊ฐ์ด๋)
์ค์น ๋จ๊ณ
- ์ ์ฅ์ ํด๋ก
git clone https://github.com/teddynote-lab/mcp-tutorial.git
cd mcp-tutorial
- ํ๊ฒฝ ๋ณ์ ์ค์
cp .env.example .env
# .env ํ์ผ์ ์ด์ด ํ์ํ API ํค ์
๋ ฅ
- ์์กด์ฑ ์ค์น
# UV๋ฅผ ์ฌ์ฉํ ๊ฐ์ํ๊ฒฝ ์์ฑ ๋ฐ ํจํค์ง ์ค์น
uv sync
# ๊ฐ์ํ๊ฒฝ ํ์ฑํ
source .venv/bin/activate # macOS/Linux
# ๋๋
.venv\Scripts\activate # Windows
๐ ํ์ต ๊ฒฝ๋ก
Part 1: MCP ๊ธฐ๋ณธ ๊ฐ๋
- MCP ํ๋กํ ์ฝ ์ดํด
- ๊ธฐ๋ณธ ์ํคํ ์ฒ ํ์ต
Part 2: ๊ธฐ๋ณธ MCP ์๋ฒ ์์ฑ
- FastMCP๋ฅผ ํ์ฉํ ์๋ฒ ๊ตฌํ
- stdio ์ ์ก ๋ฐฉ์ ์ดํด
Part 3: MultiServerMCPClient ์ค์
- ๋ค์ค ์๋ฒ ๊ด๋ฆฌ ๋ฐฉ๋ฒ
- ๋๊ตฌ ๋์ ๋ก๋
Part 4: React Agent์ MCP ํตํฉ
- LangGraph React Agent ๊ตฌ์ฑ
- MCP ๋๊ตฌ ๋ฐ์ธ๋ฉ
Part 5: ToolNode์ MCP ํตํฉ
- ์ปค์คํ ์ํฌํ๋ก์ฐ ๊ตฌ์ถ
- ์ธ๋ฐํ ์ ์ด ๊ตฌํ
Part 6: ์ธ๋ถ MCP ์๋ฒ ํ์ฉ
- Smithery AI ํ๋ซํผ ์ฐ๋
- ์๋ํํฐ ๋๊ตฌ ํตํฉ
Part 7: Dify MCP ์๋ฒ ์ฐ๋
- Dify ํ๋ซํผ ํ์ฉ
- ์ค์ ํตํฉ ์์
๐ป ์คํ ๋ฐฉ๋ฒ
MCP ์๋ฒ ์คํ
# ๋ก์ปฌ ๋ ์จ ์๋ฒ (stdio)
uv run python server/mcp_server_local.py
# ์๊ฒฉ ์๊ฐ ์๋ฒ (HTTP, ํฌํธ 8002)
uv run python server/mcp_server_remote.py
# RAG ์๋ฒ (๋ฌธ์ ๊ฒ์)
uv run python server/mcp_server_rag.py
MCP Inspector๋ก ํ ์คํธ
# ๋ธ๋ผ์ฐ์ ์์ MCP ์๋ฒ ํ
์คํธ
npx @modelcontextprotocol/inspector
ํํ ๋ฆฌ์ผ ์คํ
# Jupyter Notebook ์คํ
jupyter notebook 01-LangGraph-MCP-Tutorial.ipynb
๐ง ํ๊ฒฝ ์ค์
.env ํ์ผ์ ๋ค์ ํ๊ฒฝ ๋ณ์ ์ค์ ์ด ํ์ํฉ๋๋ค:
# ํ์
OPENAI_API_KEY=your_openai_api_key
TAVILY_API_KEY=your_tavily_api_key
# ์ ํ (์ถ๊ฐ ๊ธฐ๋ฅ)
LANGCHAIN_API_KEY=your_langchain_api_key
CONTEXT7_API_KEY=your_context7_api_key
๐ ํต์ฌ ์์กด์ฑ
- LangGraph: AI ์์ด์ ํธ ์ํฌํ๋ก์ฐ ๊ตฌ์ถ
- FastMCP: MCP ์๋ฒ ๊ฐ๋ฐ ํ๋ ์์ํฌ
- langchain-mcp-adapters: LangChain-MCP ํตํฉ
- FAISS: ๋ฒกํฐ ์คํ ๋ฆฌ์ง (RAG์ฉ)
- PyMuPDF: PDF ๋ฌธ์ ์ฒ๋ฆฌ
๐ค ๊ธฐ์ฌ ๋ฐฉ๋ฒ
์ด ํ๋ก์ ํธ๋ ๊ต์ก ๋ชฉ์ ์ผ๋ก ์ ์๋์์ต๋๋ค. ๊ฐ์ ์ฌํญ์ด๋ ๋ฒ๊ทธ๋ฅผ ๋ฐ๊ฒฌํ์๋ฉด Issue๋ฅผ ๋ฑ๋กํด ์ฃผ์ธ์.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
๐ ์ฐธ๊ณ ์๋ฃ
๐ฅ ํ์ต ๋ฆฌ์์ค
๐ ๋ผ์ด์ ์ค
์ด ํ๋ก์ ํธ๋ ๊ต์ก ๋ชฉ์ ์ผ๋ก๋ง ์ฌ์ฉ ๊ฐ๋ฅํฉ๋๋ค. ์์ธํ ๋ด์ฉ์ LICENSE ํ์ผ์ ์ฐธ์กฐํ์ธ์.
โจ ์ ์
Made by TeddyNote LAB
MCP์ LangGraph๋ก ์ฐจ์ธ๋ AI ์์ด์ ํธ๋ฅผ ๊ตฌ์ถํ์ธ์! ๐
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file iflow_mcp_teddynote_lab_mcp_tutorial-0.1.1.tar.gz.
File metadata
- Download URL: iflow_mcp_teddynote_lab_mcp_tutorial-0.1.1.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
99cc8605bf80005beab4273154a7c4e86681d3f54cb7517cb5bcf36e01f3914a
|
|
| MD5 |
e431c49a26208eb7513cb8aa95a772a3
|
|
| BLAKE2b-256 |
5bd19ef979198f1aa84fc8fb85185d3fd1905e2f3688324f9ce7426050297137
|
File details
Details for the file iflow_mcp_teddynote_lab_mcp_tutorial-0.1.1-py3-none-any.whl.
File metadata
- Download URL: iflow_mcp_teddynote_lab_mcp_tutorial-0.1.1-py3-none-any.whl
- Upload date:
- Size: 8.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f4d57a923008c5fd588c57556edc2a7ab6044eed3ab25ad7d83d308764fd4ca
|
|
| MD5 |
9aec41ce5fab78be28d38afbb0dfd67f
|
|
| BLAKE2b-256 |
3699c6bb371065a65c5cb89f29c58493c4df2c60f6d20b251081d48a17ee5cfb
|