0Pricing
MCP Academy · Ders

İçeriği Okuma Anında Oluşturma

Bir kaynağın gövdesini istendiğinde hesaplayın.

İçeriği Okuma Anında Oluşturma, CoddyKit'te ücretsiz bir MCP Academy dersidir. Bu, 4 dersinin 2. 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.

Lazy, Not Eager

A dynamic resource doesn't store a fixed body. Its content is computed on demand, only when a client actually asks to read it. ⚡

The Read Triggers the Work

Your resource function runs at the moment of a read request. Nothing happens until a client reads it, so you never waste effort building content no one wants.

Return the Body

Whatever your function returns becomes the resource's content. Return a string and the client receives that exact text as the resource body.

@mcp.resource("time://now")
def now() -> str:
    return datetime.now().isoformat()

Fresh Every Read

Because the body is rebuilt each time, the model always sees current data. Read the clock twice and you get two different timestamps.

Use the URI Variables

Combine read-time building with a template. The captured parameters shape what you compute, so the same function serves tailored content per URI.

@mcp.resource("greeting://{name}")
def greet(name: str) -> str:
    return f"Hello, {name}!"

Pull From Anywhere

At read time you can do real work: query a database, call an API, or read a file. The result of that work is what you return as the body.

@mcp.resource("stats://summary")
def summary() -> str:
    return db.fetch_summary()

Async When You Wait

If building content means waiting on I/O, make the function async. The server can serve other reads while yours awaits a slow network call.

@mcp.resource("feed://latest")
async def latest() -> str:
    return await fetch_feed()

Shape the Returned Text

You decide the format of the body. Returning JSON text is common when the model needs structured data it can reason over cleanly.

import json

def report() -> str:
    return json.dumps({"ok": True})

Keep It Quick

A read should feel snappy. If the work is heavy, cache the result so repeated reads don't redo expensive computation every single time.

Handle Missing Data

What if the requested thing doesn't exist? Raise an error from the function so the client learns the resource couldn't be read, rather than returning junk.

def get_doc(doc_id: str) -> str:
    if doc_id not in store:
        raise ValueError("not found")
    return store[doc_id]

Why This Matters

Read-time building turns a static idea into a live window on your data. The model always reads what is true right now, not a stale snapshot. 🎯

Quick Check

When does the body of a dynamic resource get produced?

Recap

You saw how returning a value from a resource function builds content on read, giving the model fresh, computed data every time. Next: listed vs templated resources. 🚀

Sıkça Sorulan Sorular

“İçeriği Okuma Anında Oluşturma” dersi ücretsiz mi?

Evet — “İçeriği Okuma Anında Oluşturma” 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.

“İçeriği Okuma Anında Oluşturma” dersinde ne öğreneceğim?

Bir kaynağın gövdesini istendiğinde hesaplayın. 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 2. dersidir.

“İçeriği Okuma Anında Oluşturma” 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. Parametreli Kaynak URI'leri
  2. İçeriği Okuma Anında Oluşturma
  3. Liste ve Şablonlu Kaynaklar
  4. Güncellemeleri İstemcilere Bildirme
← MCP Academy Sayfasına Dön