Understanding MCP Through a Simple Example: A Practical Introduction
Source: Dev.to
A Personal Take First
When new protocols and frameworks come out, I want to answer one question:
āWhat problem does this actually solve?ā
This currency converter teaches exactly how MCP works, and thatās worth sharing.
The Learning Goal
Before writing any code, understand one specific thing:
How does AI actually communicate with external tools through MCP?
What MCP Actually Does
Without 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]."
With 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."
Key insight: MCP is just a standardized way for AI to discover and use your tools.
The Example Architecture
My simple implementation looks like this:
- User sends a naturalālanguage prompt.
- Hono API receives it.
- API gets the list of provided MCP server tools (
get_exchange_rate). - API sends the prompt plus the tool list to Claude AI.
- Claude AI decides when the user wants to use a tool.
- In an interception step, the API calls the MCP tool and gets the actual rate.
- API sends another request to Claude AI that includes the actual rate and the original prompt.
- User receives the final answer.
Itās basic, and thatās exactly why itās useful for learning.
MCP Tool Definition
{
"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 }
}
}
}
This tool simply returns exchangeārate data; the AI handles everything else.
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..."
Why This Simple Example Matters
-
Tool Discovery ā The AI can see what tools are available and know when to use them based on the description.
-
Parameter Extraction ā The AI automatically extracts structured parameters from messy natural language:
āIs Ā„10,000 enough for $60?ā ā from="JPY", to="USD", amount=10000 āHow many dollars is 50 euros?ā ā from="EUR", to="USD", amount=50 -
Context Awareness ā The AI can handle multiāstep queries:
ā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. -
Natural Responses ā The AI formats the toolās response in a conversational way instead of dumping raw JSON.
See It Working
I recorded a quick demo showing different types of queries being handled:
(Click the image to view it fullāsize.)

Nothing fancy, just the basic flow working as expected.
Setting It Up (For Learning Purposes)
If you want to try this yourself to understand MCP:
git clone https://github.com/hshoja/Currency-Exchange-MCP-Service
npm install
cp env.example .env
# Add your API keys to .env
npm run dev
Youāll need
- Anthropic API key (for Claude AI)
- Freecurrencyapi key (for exchange rates)
Then just send POST requests with naturalālanguage prompts:
{
"prompt": "What is 100 USD in EUR?"
}
The Real Takeaway
After building this simple example, we now understand:
- MCP is not about building smarter APIs.
- Itās about building simple, focused tools and letting AI be the smart layer that connects them to human intent.
Your tool can be dumb. It should be dumb. Do one thing well, and let AI handle the rest.
Potential Use Cases (Beyond This Simple Example)
While the currency converter is basic, the pattern scales to more interesting problems. Have a look at these examples:
- AI Agent Crypto MCP Trading ā shows how to create an MCP that opens or closes positions on a crypto platform via natural language.
- Kali Linux HACKING MCP ā run Kali commands for hacking by natural language.
- Natural Language to SQL ā connect and query a database using natural language.
- Building an Agentic Appointment Scheduling App
The complexity isnāt in MCP itself ā itās in the tools you build and connect.
Check Out The Code
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.
