Understanding MCP Through a Simple Example: A Practical Introduction

Published: (January 17, 2026 at 01:41 PM EST)
5 min read
Source: Dev.to

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:

  1. User sends a natural‑language prompt.
  2. Hono API receives it.
  3. API gets the list of provided MCP server tools (get_exchange_rate).
  4. API sends the prompt plus the tool list to Claude AI.
  5. Claude AI decides when the user wants to use a tool.
  6. In an interception step, the API calls the MCP tool and gets the actual rate.
  7. API sends another request to Claude AI that includes the actual rate and the original prompt.
  8. 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

  1. Tool Discovery – The AI can see what tools are available and know when to use them based on the description.

  2. 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
  3. 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.
  4. 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:

Demo GIF

(Click the image to view it full‑size.)

![Currency Exchange Demo](https://media2.dev.to/dynamic/image/width=800,height=,fit=scale-down,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6die6pigf3m6qlkdj5ou.gif)

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

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:

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.

Back to Blog

Related posts

Read more Ā»

Rapg: TUI-based Secret Manager

We've all been there. You join a new project, and the first thing you hear is: > 'Check the pinned message in Slack for the .env file.' Or you have several .env...

Technology is an Enabler, not a Saviour

Why clarity of thinking matters more than the tools you use Technology is often treated as a magic switch—flip it on, and everything improves. New software, pl...