Aufgelistete oder vorlagenbasierte Ressourcen
Bieten Sie feste Einträge und zusätzlich dynamisch erzeugte Muster an.
Aufgelistete oder vorlagenbasierte Ressourcen ist eine kostenlose MCP Academy-Lektion auf CoddyKit. Dies ist Lektion 3 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.
Two Ways to Offer Data
MCP exposes data two ways: a listed resource with a fixed URI, or a templated one with placeholders. Knowing which to pick keeps your server clear.
Listed: Enumerable and Few
A listed resource has a concrete URI and shows up in resources/list. Use it when there are only a handful of known items the client can browse.
@mcp.resource("config://app")
def app_config() -> str:
return read_config()Templated: Infinite by Pattern
A templated resource uses curly-brace placeholders, so it covers countless URIs. It can't be listed in full, because the set is open-ended.
@mcp.resource("file://{path}")
def read_file(path: str) -> str:
return open(path).read()The Listing Difference
Clients call resources/list to discover fixed resources. Templates appear in a separate templates list instead, advertising the shape rather than concrete entries.
Browse vs Address
Think of it as browse vs address. Listed resources are like menu items you scan; templates are like typing an address you already know.
When the Set Is Small
If your data is a short, stable set, prefer listed resources. The model can see every option, which makes the right choice obvious to it.
When the Set Is Huge
If items number in the thousands, a template wins. Listing them all would flood the client, so you advertise the pattern and let it fill in values.
weather://{city}/todayCombine Both Freely
A real server often does both: a few listed entries for common data, plus templates for the long tail. They coexist happily side by side.
Help Discovery Along
Templates can't enumerate, but you can add a small listed index resource that points to popular URIs, giving the model useful starting points.
@mcp.resource("cities://index")
def cities() -> str:
return "london, paris, tokyo"Same Read, Either Way
However a URI is found, the client reads it the same way: one resources/read call. Listed or templated changes discovery, not how content is fetched.
Why This Matters
Choosing listed vs templated shapes how easily a model finds your data. Pick listed for browsing, templated for scale, and your server stays usable. 🎯
Quick Check
Which resource type should you use for thousands of items?
Recap
You learned that listed resources suit small browsable sets while templated ones scale to huge collections, and the two combine well. Next: notifying clients of updates. 🚀
Häufig gestellte Fragen
Ist die Lektion „Aufgelistete oder vorlagenbasierte Ressourcen“ kostenlos?
Ja — der vollständige Text von „Aufgelistete oder vorlagenbasierte Ressourcen“ 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 „Aufgelistete oder vorlagenbasierte Ressourcen“?
Bieten Sie feste Einträge und zusätzlich dynamisch erzeugte Muster an. 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 3 von 4.
Wie lange dauert die Lektion „Aufgelistete oder vorlagenbasierte Ressourcen“?
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
- Parametrisierte Ressourcen-URIs
- Inhalte beim Lesen erzeugen
- Aufgelistete oder vorlagenbasierte Ressourcen
- Clients über Aktualisierungen benachrichtigen