mcp-server-examples
If you are the rightful owner of mcp-server-examples and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
This project includes examples of Model Context Protocol (MCP) servers, implementing functionalities like BMI calculation and weather information retrieval.
MCP Server Examples
์ด ํ๋ก์ ํธ๋ Model Context Protocol (MCP) ์๋ฒ ์์ ๋ค์ ํฌํจํ๊ณ ์์ต๋๋ค. BMI ๊ณ์ฐ๊ณผ ๋ ์จ ์ ๋ณด ์กฐํ ๊ธฐ๋ฅ์ ์ ๊ณตํ๋ MCP ์๋ฒ๋ฅผ ๊ตฌํํฉ๋๋ค.
ํ๋ก์ ํธ ๊ตฌ์กฐ
mcp-server-examples/
โโโ .venv/ # Python ๊ฐ์ํ๊ฒฝ
โโโ server.py # MCP ์๋ฒ ๊ตฌํ (BMI ๊ณ์ฐ๊ธฐ, ๋ ์จ ์ ๋ณด ์กฐํ)
โโโ config.json # ์๋ฒ ์ค์ ํ์ผ
์ ๊ณตํ๋ ๋๊ตฌ๋ค
-
BMI ๊ณ์ฐ๊ธฐ
- ํค(m)์ ๋ชธ๋ฌด๊ฒ(kg)๋ฅผ ์ ๋ ฅ๋ฐ์ BMI ์ง์๋ฅผ ๊ณ์ฐ
calculate_bmi
๋๊ตฌ ์ฌ์ฉ
-
๋ ์จ ์ ๋ณด ์กฐํ
- ๋์ ์ด๋ฆ์ ์ ๋ ฅ๋ฐ์ ํด๋น ๋์์ ๋ ์จ ์ ๋ณด๋ฅผ ์กฐํ
fetch_weather
๋๊ตฌ ์ฌ์ฉ
ํ๋ก์ ํธ ์ค์ ๋ฐ ์คํ ๋ฐฉ๋ฒ
1. Python ๊ฐ์ํ๊ฒฝ ์์ฑ
# venv ๋ชจ๋์ ์ฌ์ฉํ์ฌ ๊ฐ์ํ๊ฒฝ ์์ฑ
python -m venv .venv
# ๊ฐ์ํ๊ฒฝ ํ์ฑํ
# Windows์ ๊ฒฝ์ฐ:
.venv\Scripts\activate
# macOS/Linux์ ๊ฒฝ์ฐ:
source .venv/bin/activate
2. ํ์ํ ํจํค์ง ์ค์น
# MCP ํจํค์ง ์ค์น (CLI ๋๊ตฌ ํฌํจ)
pip install "mcp[cli]"
# HTTP ํด๋ผ์ด์ธํธ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ค์น (๋ ์จ API ํธ์ถ์ฉ)
pip install httpx
3. ์๋ฒ ์คํ
๊ฐ๋ฐ ๋ชจ๋๋ก ์๋ฒ๋ฅผ ์คํํ๊ฑฐ๋ Claude Desktop์ ์ค์นํ ์ ์์ต๋๋ค:
# ๊ฐ๋ฐ ๋ชจ๋๋ก ์๋ฒ ์คํ
mcp dev server.py
# Claude Desktop์ ์๋ฒ ์ค์น
mcp install server.py
์์กด์ฑ ํจํค์ง
mcp
: Model Context Protocol ๊ตฌํ์ ์ํ ํต์ฌ ํจํค์งhttpx
: ๋น๋๊ธฐ HTTP ํด๋ผ์ด์ธํธ ๋ผ์ด๋ธ๋ฌ๋ฆฌ (๋ ์จ API ํธ์ถ์ฉ)
์๋ฒ ์ฌ์ฉ ๋ฐฉ๋ฒ
์๋ฒ๊ฐ ์คํ๋๋ฉด Claude Desktop์์ ๋ค์๊ณผ ๊ฐ์ ๋๊ตฌ๋ค์ ์ฌ์ฉํ ์ ์์ต๋๋ค:
-
BMI ๊ณ์ฐํ๊ธฐ:
- ํค(๋ฏธํฐ)์ ๋ชธ๋ฌด๊ฒ(ํฌ๋ก๊ทธ๋จ)๋ฅผ ์ ๋ ฅํ๋ฉด BMI ์ง์๋ฅผ ๊ณ์ฐํด์ค๋๋ค
- ์: ํค 1.79m, ๋ชธ๋ฌด๊ฒ 80kg โ BMI 25.0
-
๋ ์จ ์ ๋ณด ์กฐํํ๊ธฐ:
- ๋์ ์ด๋ฆ์ ์ ๋ ฅํ๋ฉด ํด๋น ๋์์ ํ์ฌ ๋ ์จ ์ ๋ณด๋ฅผ ์กฐํํฉ๋๋ค
- API๋ฅผ ํตํด ์ค์๊ฐ ๋ ์จ ๋ฐ์ดํฐ๋ฅผ ์ ๊ณตํฉ๋๋ค