0Pricing
MCP Academy · Lektion

Parametrisierte Ressourcen-URIs

Übernehmen Sie Variablen direkt aus dem URI-Pfad.

Parametrisierte Ressourcen-URIs 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.

One Pattern, Many Resources

A static resource has one fixed address. A parameterized URI is a pattern that stands in for a whole family of resources at once. ✨

Placeholders in Curly Braces

You mark the variable part of a URI with a placeholder in curly braces, like users://{user_id}/profile. That brace is a slot to fill.

users://{user_id}/profile

The Template Is a Promise

A resource template tells the client: any URI matching this shape is valid. The model can plug in real values to ask for exactly what it needs.

Decorate to Register

In the Python SDK you register a template the same way as a tool: with the @mcp.resource decorator, passing the URI pattern as its argument.

@mcp.resource("users://{user_id}/profile")
def get_profile(user_id: str) -> str:
    return f"Profile for {user_id}"

Names Must Match

Every placeholder in the URI must appear as a function parameter with the same name. The SDK wires {user_id} straight into your user_id argument.

Capture More Than One

You can capture several variables in one URI. Multiple placeholders each map to their own parameter, so one pattern can pinpoint very specific data.

@mcp.resource("repos://{owner}/{name}/readme")
def readme(owner: str, name: str) -> str:
    return load_readme(owner, name)

Values Arrive as Strings

Captured pieces come in as text from the URI. If you need a number, convert it yourself inside the function before using it.

def get_page(page: str) -> str:
    n = int(page)
    return render_page(n)

One Segment Per Placeholder

By default a placeholder captures a single path segment, the text between two slashes. It stops at the next slash, so it won't swallow the rest of the path.

Templates Don't List Themselves

A plain resource shows up in the resource list. A templated resource usually does not, since there are endless possible URIs. The client reads it by filling the pattern.

Keep URIs Meaningful

Design URIs that read like clear addresses, such as weather://{city}/today. A model picks the right resource far more reliably when the path explains itself.

weather://{city}/today

Why This Matters

Parameterized URIs let one tidy function serve thousands of resources. You write the shape once, and the variable parts do the rest. 🎯

Quick Check

How does a captured URI placeholder reach your function?

Recap

You learned that parameterized URIs use curly-brace placeholders to serve a whole family of resources, each one mapped to a matching function parameter. Next: building their content. 🚀

Häufig gestellte Fragen

Ist die Lektion „Parametrisierte Ressourcen-URIs“ kostenlos?

Ja — der vollständige Text von „Parametrisierte Ressourcen-URIs“ 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 „Parametrisierte Ressourcen-URIs“?

Übernehmen Sie Variablen direkt aus dem URI-Pfad. 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 „Parametrisierte Ressourcen-URIs“?

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. Parametrisierte Ressourcen-URIs
  2. Inhalte beim Lesen erzeugen
  3. Aufgelistete oder vorlagenbasierte Ressourcen
  4. Clients über Aktualisierungen benachrichtigen
← Zurück zu MCP Academy