一覧型リソースとテンプレート型リソース
固定のエントリと、その場で生成するパターンを提供します。
「一覧型リソースとテンプレート型リソース」はCoddyKit上の無料MCP Academyレッスンです。 これはレッスン3/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはMCP Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 MCP Academyコースには全4レッスンが含まれています。
このレッスンの一部はまだ翻訳されておらず、英語で表示されています。
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. 🚀
よくある質問
「一覧型リソースとテンプレート型リソース」レッスンは無料ですか?
はい。「一覧型リソースとテンプレート型リソース」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、MCP Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 MCP Academyコースには全4レッスンが含まれています。
「一覧型リソースとテンプレート型リソース」で何を学びますか?
固定のエントリと、その場で生成するパターンを提供します。 ブラウザで直接実行するハンズオンコードでMCP Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。
MCP Academyを始めるのに経験は必要ですか?
事前経験は必要ありません。CoddyKitのMCP Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン3/4です。
「一覧型リソースとテンプレート型リソース」レッスンにはどのくらい時間がかかりますか?
ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。
このMCP Academyレッスンでコードを書いて実行できますか?
はい。すべてのMCP Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。
このコースのすべてのレッスン
- パラメーター付きリソースURI
- 読み取り時にコンテンツを生成する
- 一覧型リソースとテンプレート型リソース
- 更新をクライアントに通知する