0Pricing
MCP Academy · Lesson

Add a Hello Tool

Decorate a Python function so AI can call it.

Add a Hello Tool is a free MCP Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the MCP Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Give Your Server a Skill

A server with no tools is just a shell. A tool is a Python function the AI can call to actually do something for the user. 🛠️

The Magic Decorator

FastMCP exposes a function as a tool with one line: the @mcp.tool() decorator placed right above your function definition.

@mcp.tool()
def hello():
    ...

Write a Normal Function

The body is just Python. No special protocol code, no JSON by hand. You write what the tool should do and return a value.

@mcp.tool()
def hello():
    return "Hello from MCP!"

Add a Parameter

Tools get more useful with input. Add a parameter and the model can pass a value when it decides to call your tool.

@mcp.tool()
def greet(name):
    return "Hello, " + name

Type Hints Build the Schema

Add a type hint like name: str and FastMCP turns it into an input schema. The model then knows exactly what kind of value to send.

@mcp.tool()
def greet(name: str) -> str:
    return "Hello, " + name

The Docstring Becomes the Description

Your function's docstring becomes the tool's description. The model reads it to decide when this tool is the right one to use.

@mcp.tool()
def greet(name: str) -> str:
    """Greet a person by name."""
    return "Hello, " + name

The Name Comes from the Function

By default the tool's name is the function name. So def greet publishes a tool the client lists as "greet".

Return Plain Text

For a first tool, just return a string. FastMCP wraps it into the proper MCP result shape so the client receives clean text.

Describe It Well

Good wording matters: a clear description helps the model pick your tool at the right moment. Vague docstrings lead to missed calls.

It Registers Automatically

You never call a register function yourself. Just by decorating it, the tool is registered on your mcp instance and ready to advertise.

Add as Many as You Like

One server can hold many tools. Just decorate each function, and they all show up together when a client asks what's available.

Quick Check

Where does a tool's description come from?

Recap

You added a tool with @mcp.tool(), gave it typed parameters, and let the docstring describe it. Your server can finally do something. Now let's run it! ✨

Frequently asked questions

Is the “Add a Hello Tool” lesson free?

Yes — the full text of “Add a Hello Tool” is free to read here on the web, and the MCP Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the MCP Academy course, upgrade to CoddyKit PRO.

What will I learn in “Add a Hello Tool”?

Decorate a Python function so AI can call it. You practise MCP Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start MCP Academy?

No prior experience is required. MCP Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Add a Hello Tool” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this MCP Academy lesson?

Yes. Every MCP Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Create a FastMCP Instance
  2. Add a Hello Tool
  3. Run the Server with stdio
  4. Confirm It Loads & Lists Tools
← Back to MCP Academy