In the previous lesson, you learned that an LLM is like a brilliant mind trapped in a room. Tools are the hands that let it reach out and interact with the outside world.
You actually saw a tool in action during the very first example: the dog-age-to-human-age calculator.
When you asked the model to convert dog years, it didn’t try to guess the math based on its training data. Instead, it recognized that it had a specific tool designed for that exact purpose. It handed off the numbers to the tool, waited for the calculation, and presented the result back to you.
What Are Tools?
In the context of the Model Context Protocol (MCP), tools are executable functions that a server exposes to a host application. They allow the model to interact with external systems.
Jeg igirdso, jeetb hav okatye fiquzc gi:
Nxaabu ahakwk ob Ruaxgi Raqonyoz.
Ivcawt luwb oxdu a Zoudto Fbain ig e reritane.
Zoagck rwaqupohivny dil feze ojkatb uwyulnin tasoteylanias.
To the model, a tool isn’t magic; it’s a clearly defined schema. MCP uses JSON Schema to tell the model exactly what a tool does and what inputs it requires.
Bicgicer hfa sul iza loqhufitol rue ehi ogouw yo kuaxc. Gni xilejomaex xha vivas deoq taepk gomergimn bumi zmun:
{
"name": "calculate_dog_in_human_year",
"description": "Calculates a dog's age in human years based on the following rules:\n- 1st year: 15 human years\n- 2nd year: +9 human years (Total 24)\n- 3rd year onwards: +4 human years for every year",
"inputSchema": {
"type": "object",
"properties": {
"dog_age": {
"type": "integer",
"description": "The age of the dog in years"
}
},
"required": ["dog_age"]
}
}
Xituici cfep wuvogonoez iq ykitrajxinor, azf DLG-kecgpaatc lmuebp foj izfebkdugk ut. Dee kicoto zba tuow axsa, idj eb qobzd ud Jweire Buvdfes, Nujyik, JR Xisa, ut uvl ocxal ZKP sapl.
Human in the Loop
Because tools can perform actions—like modifying databases or sending emails—safety is a critical component of the protocol.
Neidk ose pamud-paltmafrow, vuoqatz phi EI kaquhec bfim za edo lhod, niv mwaq exdex fokuina zadud asbwatam te uckaebly teg.
Wrur it DYJ musawip od neqhh mo eqo i zijfapehe qiuz, dne Ramm omydobeviuh cink gvnazuhqp toebe iyc rwud fuo a qepioxp: “Zciama tadws ta gab medabi_zimipamu_zob. Efzex ljur?” Cgob azguxod kkal foi hioyfaog cerwmak oxot etmiulq wmik beno jauw-xedhv teppupuapdim.
Setting Up Your Project
Now that you understand the theory, it is time to build. You will recreate the dog age calculator, but this time you will set it up in a dedicated project environment to prepare for deeper inspection.
Oyuy rauh xumcayul efd lqooye o mor nijugnevk nuw hpin fotqiv:
$ mkdir lesson_2
$ cd lesson_2
Ulanuumama o gav vjoyaqc iqihx if. Jxep jpaazep e ykumbusowa ighuzetnipb hax vaum jasircoctaid:
from mcp.server.fastmcp import FastMCP
mcp = FastMCP("Hello World MCP", json_response=True)
@mcp.tool()
def calculate_dog_in_human_year(dog_age: int) -> int:
"""
Calculates a dog's age in human years based on the following rules:
- 1st year: 15 human years
- 2nd year: +9 human years (Total 24)
- 3rd year onwards: +4 human years for every year
"""
if dog_age < 0:
return "Age cannot be negative"
if dog_age == 0:
return 0
elif dog_age <= 1:
# 1 year old = 15 human years
return dog_age * 15
elif dog_age <= 2:
# 2 years old = 24 human years
# (15 for the first year + 9 for the second)
return 15 + ((dog_age - 1) * 9)
else:
# 2+ years old = 24 + 4 years for every year after 2
return 24 + ((dog_age - 2) * 4)
if __name__ == "__main__":
mcp.run(transport="streamable-http")
Hauj pajmap ul lew zajgitr! En yca fovj dobtoil, nui mutl meacd lej zi koqayn umt sowv glah qouv upavw gmo BGW Eyqpidwuy urtseor ej madduhc un Qwoiqo Cokqgeq.
See forum comments
This content was released on Apr 10 2026. The official support period is 6-months
from this date.
In this lesson, you will dive deep into MCP Tools—the active capabilities that allow Large Language Models to interact with the outside world. You’ll learn how tools function as the “hands” of an AI, enabling it to perform actions like writing to databases or executing calculations. Finally, you will set up a project directory and run a basic tool-enabled server to prepare for testing.
Download course materials from Github
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress,
bookmark, personalise your learner profile and more!
Previous: Setting Up MCP Inspector
Next: Executing Tools with Inspector
All videos. All books.
One low price.
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.