간단한 예제로 MCP 이해하기: 실용적인 소개
I’m sorry, but I can’t retrieve the article from the link you provided. If you paste the text you’d like translated here, I’ll be happy to translate it into Korean while preserving the original formatting and markdown.
개인적인 의견 먼저
새로운 프로토콜과 프레임워크가 나올 때, 나는 한 가지 질문에 답하고 싶다:
“이게 실제로 어떤 문제를 해결하나요?”
이 통화 변환기는 MCP가 정확히 어떻게 작동하는지 가르쳐 주며, 이는 공유할 가치가 있다.
학습 목표
코드를 작성하기 전에, 한 가지 특정한 것을 이해하세요:
AI가 실제로 MCP를 통해 외부 도구와 어떻게 통신하는가?
MCP가 실제로 하는 일
MCP 없이
You: "Is ¥10,000 enough to buy a $60 game?"
AI: "I don't have access to current exchange rates, but you can check [some website]."
MCP와 함께
You: "Is ¥10,000 enough to buy a $60 game?"
AI:
1. Realizes it needs an exchange rate
2. Sees there's a `get_exchange_rate` tool available
3. Calls: get_exchange_rate(from="JPY", to="USD", amount=10000)
4. Gets: 10000 JPY = 65.83 USD
5. Responds: "Yes, ¥10,000 is approximately $65.83 USD, so you'd have $5.83 left after buying the game."
핵심 통찰: MCP는 AI가 도구를 발견하고 활용할 수 있도록 표준화된 방법일 뿐입니다.
예시 아키텍처
내 간단한 구현은 다음과 같습니다:
- User가 자연어 프롬프트를 보냅니다.
- Hono API가 이를 수신합니다.
- API가 제공된 MCP 서버 도구 목록(
get_exchange_rate)을 가져옵니다. - API가 프롬프트 plus 도구 목록을 Claude AI에 보냅니다.
- Claude AI가 사용자가 도구를 사용하고자 하는 시점을 결정합니다.
- 가로채기 단계에서 API가 MCP 도구를 호출하고 실제 환율을 가져옵니다.
- API가 실제 환율 and 원본 프롬프트를 포함한 또 다른 요청을 Claude AI에 보냅니다.
- User가 최종 답변을 받습니다.
기본적인 구조이며, 바로 그 점이 학습에 유용한 이유입니다.
MCP 도구 정의
{
"name": "get_exchange_rate",
"description": "Get exchange rate between currencies",
"inputSchema": {
"type": "object",
"properties": {
"from_currency": { "type": "string" },
"to_currency": { "type": "string" },
"amount": { "type": "number", "optional": true }
}
}
}
이 도구는 단순히 환율 데이터를 반환합니다; 나머지는 AI가 처리합니다.
Implementation Steps
1️⃣ User sends a natural‑language prompt
"Is ¥10,000 enough to buy a $60 game?"
2️⃣ API receives it
app.post('/api/chat', async c => {
const { prompt } = await c.req.json();
// …
});
3️⃣ API gets the list of MCP tools
const tools = await mcpClient.listTools(); // returns [{ name: "get_exchange_rate", … }]
4️⃣ API sends prompt + tools to Claude AI
let response = await anthropic.messages.create({
tools,
messages: [{ role: 'user', content: prompt }]
});
5️⃣ Claude decides a tool is needed
while (response.stop_reason === 'tool_use') {
const toolUse = response.content.find(b => b.type === 'tool_use');
// …
}
6️⃣ API calls the MCP tool
const toolResult = await mcpClient.callTool({
name: toolUse.name,
arguments: toolUse.input
});
7️⃣ API sends a second request with the tool result
response = await anthropic.messages.create({
tools,
messages: [
{ role: 'user', content: prompt }, // original prompt
{
role: 'user',
content: [{
type: 'tool_result',
tool_use_id: toolUse.id,
content: JSON.stringify(toolResult.content) // rate info
}]
}
]
});
8️⃣ Return the final answer to the user
const finalText = response.content;
return finalText; // "Yes, ¥10,000 is approximately $65.83 USD, so you'd have $5.83 left..."
왜 이 간단한 예제가 중요한가
-
도구 발견 – AI는 어떤 도구가 사용 가능한지 확인하고, 설명을 기반으로 언제 사용할지 알 수 있습니다.
-
매개변수 추출 – AI는 복잡한 자연어에서 구조화된 매개변수를 자동으로 추출합니다:
“Is ¥10,000 enough for $60?” → from="JPY", to="USD", amount=10000 “How many dollars is 50 euros?” → from="EUR", to="USD", amount=50 -
맥락 인식 – AI는 다단계 쿼리를 처리할 수 있습니다:
“I have 5 euros in cash and 20 in my bank, total in USD?” → AI adds 5 + 20 = 25 EUR, then calls the tool with 25 EUR. -
자연스러운 응답 – AI는 도구의 응답을 원시 JSON을 그대로 내보내는 대신 대화형 방식으로 포맷합니다.
작동 모습 보기
다양한 유형의 쿼리가 처리되는 모습을 보여주는 간단한 데모를 녹화했습니다:
(이미지를 클릭하면 전체 크기로 볼 수 있습니다.)

Nothing fancy, just the basic flow working as expected.
설정하기 (학습 목적)
MCP를 직접 시도해 보고 싶다면 다음과 같이 진행하세요:
git clone https://github.com/hshoja/Currency-Exchange-MCP-Service
npm install
cp env.example .env
# .env 파일에 API 키를 추가하세요
npm run dev
필요 사항
- Anthropic API 키 (Claude AI용)
- Freecurrencyapi 키 (환율용)
그런 다음 자연어 프롬프트를 포함한 POST 요청을 보내면 됩니다:
{
"prompt": "What is 100 USD in EUR?"
}
실제 요점
이 간단한 예제를 만든 후, 우리는 이제 이해한다:
- MCP는 똑똑한 API를 만드는 것이 아니다.
- 그것은 단순하고 집중된 도구를 만들고, AI가 인간의 의도와 연결해 주는 스마트 레이어가 되게 하는 것이다.
당신의 도구는 어리석어도 된다. 어리석어야 한다. 한 가지를 잘 수행하고, 나머지는 AI에게 맡겨라.
잠재적 사용 사례 (이 간단한 예제 외)
통화 변환기는 기본적이지만, 이 패턴은 더 흥미로운 문제들로 확장됩니다. 다음 예시들을 살펴보세요:
- AI Agent Crypto MCP Trading – 자연어를 통해 암호화폐 플랫폼에서 포지션을 열거나 닫는 MCP를 만드는 방법을 보여줍니다.
- Kali Linux HACKING MCP – 자연어로 Kali 명령을 실행하여 해킹을 수행합니다.
- Natural Language to SQL – 자연어를 사용해 데이터베이스에 연결하고 쿼리합니다.
- Building an Agentic Appointment Scheduling App
복잡성은 MCP 자체에 있는 것이 아니라, 여러분이 구축하고 연결하는 도구에 있습니다.
코드를 확인해 보세요
The full repository includes everything you need. Feel free to clone it, modify it, or use it as a reference while learning MCP yourself.
Are you learning MCP too? Have you built simple examples to understand new tech? I’d love to hear about it — drop a comment!
P.S. — If this helped you understand MCP a bit better, give it a like! And remember: simple examples are valid examples.
