0Pricing
MCP Academy · Lektion

Fortschritt bei langen Aufgaben senden

Streamen Sie Fortschrittsmeldungen mit Prozentangaben an den Client.

Fortschritt bei langen Aufgaben senden ist eine kostenlose MCP Academy-Lektion auf CoddyKit. Dies ist Lektion 1 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des MCP Academy-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der MCP Academy-Kurs umfasst insgesamt 4 Lektionen.

Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.

Why Progress Matters

When a tool takes seconds or minutes, the client should not just hang. MCP lets your server send progress updates so the user sees movement.

The Progress Token

The client opts in by attaching a progressToken to the request. Without that token, your server simply skips sending updates.

Reach the Context Object

In the Python SDK, a tool receives a Context object. It is your handle for talking back to the client mid-call, including progress.

from mcp.server.fastmcp import Context

@mcp.tool()
async def crunch(n: int, ctx: Context) -> str:
    return "done"

Call report_progress

To push an update, you call ctx.report_progress. Each call tells the client how far along the work has come.

await ctx.report_progress(progress=3, total=10)

Progress and Total

The total argument is the finish line. The client can divide progress by total to draw a percent-done bar for the user.

await ctx.report_progress(progress=5, total=10)  # 50%

Update Inside a Loop

The natural place to report is inside your work loop. After each chunk finishes, send one update so the bar climbs steadily.

for i, item in enumerate(items):
    process(item)
    await ctx.report_progress(i + 1, len(items))

Progress Without a Total

Sometimes you cannot know the total upfront. You may omit it; the client then shows an indeterminate spinner instead of a precise bar.

await ctx.report_progress(progress=42)  # total unknown

Add an Optional Message

Many SDK versions let you attach a short message to a progress call, like "Indexing files", giving the user friendly human context.

await ctx.report_progress(2, 5, message="Fetching pages")

It Is a Notification

Progress travels as a JSON-RPC notification, so it has no reply and never blocks. Your tool keeps working while updates flow out.

Keep Updates Reasonable

Do not flood the client with thousands of tiny updates. Report at meaningful steps so the stream stays useful and lightweight.

Progress Plus a Result

Progress notifications are separate from your tool's return value. You stream updates as you go, then hand back the final result at the end.

await ctx.report_progress(10, 10)
return "index built"

Quick Check

Test your grasp of how progress reporting begins.

Recap: Progress

You learned to call ctx.report_progress with progress and total, loop your updates, and let the client draw a live bar. Nice work!

Häufig gestellte Fragen

Ist die Lektion „Fortschritt bei langen Aufgaben senden“ kostenlos?

Ja — der vollständige Text von „Fortschritt bei langen Aufgaben senden“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des MCP Academy-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der MCP Academy-Kurs umfasst insgesamt 4 Lektionen.

Was lerne ich in „Fortschritt bei langen Aufgaben senden“?

Streamen Sie Fortschrittsmeldungen mit Prozentangaben an den Client. Du übst MCP Academy mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.

Brauche ich Erfahrung, um MCP Academy zu starten?

Keine Vorkenntnisse erforderlich. MCP Academy auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 1 von 4.

Wie lange dauert die Lektion „Fortschritt bei langen Aufgaben senden“?

Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.

Kann ich in dieser MCP Academy-Lektion Code schreiben und ausführen?

Ja. Jede MCP Academy-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.

Alle Lektionen in diesem Kurs

  1. Fortschritt bei langen Aufgaben senden
  2. Abbruchanfragen verarbeiten
  3. Strukturiertes Logging an den Client
  4. Log-Level zur Laufzeit festlegen
← Zurück zu MCP Academy