0Pricing
MCP Academy · Ders

Baştan Sona Hesap Makinesi Aracı

Küçük ama eksiksiz bir aritmetik aracı oluşturun.

Baştan Sona Hesap Makinesi Aracı, CoddyKit'te ücretsiz bir MCP Academy dersidir. Bu, 4 dersinin 4. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, MCP Academy öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. MCP Academy kursu toplamda 4 dersten oluşur.

Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.

Build One Complete Tool

Let's combine everything into one small calculator tool, from a clear name to a clean result the model can trust. 🧮

Start with the Server

First create a FastMCP instance to hold the tool. Give it a name so clients can identify your server.

from mcp.server.fastmcp import FastMCP
mcp = FastMCP("calculator")

Name the Operation

Pick a precise name. We will add two numbers, so the function add reads clearly to both you and the model.

Declare Typed Parameters

Use type hints so the model sends numbers, not text. We accept two floats to allow decimals as well as whole values.

def add(a: float, b: float) -> float:
    ...

Write the Docstring

The docstring becomes the description, so state plainly what the tool does and what it returns.

def add(a: float, b: float) -> float:
    """Add two numbers and return the sum."""

Decorate It as a Tool

Add the tool decorator so FastMCP registers the function and advertises it to any connected client.

@mcp.tool()
def add(a: float, b: float) -> float:
    """Add two numbers."""
    return a + b

Return a Clear Result

Returning the sum works, but a labeled result reads better to the model and to the user who sees the answer.

    return a + b

Add a Second Tool

One tool per job, so create a separate divide tool rather than packing modes into add. Each stays simple to call.

@mcp.tool()
def divide(a: float, b: float) -> float:
    return a / b

Guard Against Bad Input

Division by zero would crash, so check first and return a clear error message the model can read and explain.

    if b == 0:
        return "Error: cannot divide by zero."

Run the Server

Finish with the run call so the server starts and listens for a client over stdio when you launch the file.

if __name__ == "__main__":
    mcp.run()

Test the Whole Tool

Launch it and let a client list your tools. Seeing add and divide with their descriptions confirms the wiring is correct.

Quick Check

Why give divide its own tool instead of a mode flag on add?

Recap

You built a full calculator tool: named clearly, typed parameters, docstring description, guarded errors, and a clean result the model trusts. ✅

Sıkça Sorulan Sorular

“Baştan Sona Hesap Makinesi Aracı” dersi ücretsiz mi?

Evet — “Baştan Sona Hesap Makinesi Aracı” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve MCP Academy kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. MCP Academy kursu toplamda 4 dersten oluşur.

“Baştan Sona Hesap Makinesi Aracı” dersinde ne öğreneceğim?

Küçük ama eksiksiz bir aritmetik aracı oluşturun. MCP Academy ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.

MCP Academy öğrenmeye başlamak için deneyim gerekli mi?

Önceden deneyim gerekmez. CoddyKit'te MCP Academy, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 4. dersidir.

“Baştan Sona Hesap Makinesi Aracı” dersi ne kadar sürer?

Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.

Bu MCP Academy dersinde kod yazıp çalıştırabilir miyim?

Evet. Her MCP Academy dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.

Bu kursun tüm dersleri

  1. Bir Aracı İyi Adlandırma ve Açıklama
  2. Tür İpuçlarıyla Parametre Bildirme
  3. Kullanışlı Sonuçlar Döndürme
  4. Baştan Sona Hesap Makinesi Aracı
← MCP Academy Sayfasına Dön