静的なテキストリソースを提供する
モデルが読み取れる固定ドキュメントを公開します。
「静的なテキストリソースを提供する」はCoddyKit上の無料MCP Academyレッスンです。 これはレッスン2/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはMCP Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 MCP Academyコースには全4レッスンが含まれています。
このレッスンの一部はまだ翻訳されておらず、英語で表示されています。
A Fixed Document
The simplest resource is a static one: a fixed string your server returns every time. Great for help text, policies, or config notes.
One Function, One URI
You expose it by writing a Python function and tagging it with a resource URI. When a client reads that URI, your function runs and returns text.
The Decorator
The resource decorator registers the function under its URI. The string you pass becomes the address clients use to fetch the content.
@mcp.resource("info://welcome")
def welcome():
return "Welcome to the server!"Return Plain Text
For a text resource, just return a Python string. The SDK wraps it into the proper MCP read response so the client receives clean content.
Name and Describe It
Give the resource a clear description so the model knows when to read it. A docstring on the function is used as that description.
@mcp.resource("info://welcome")
def welcome():
"Greeting shown to new users."
return "Hello there!"Static Means No Inputs
A static resource takes no parameters; it always yields the same body. If you need to vary output, that is a job for templates, covered later.
Build Text in Code
The return value can be assembled in Python before sending. The result is still static to the client, since the same call gives the same text.
@mcp.resource("config://limits")
def limits():
return "max_items=100\ntimeout=30"Why Resources, Not Tools
Use a resource when the model only needs to read context. Tools are for actions; reading reference text is exactly what resources are for.
The Model Pulls It In
Many hosts let the user attach a resource to a chat, dropping its content into context. The model then reasons over that text alongside the prompt.
Keep It Lightweight
Static resources load fast since there is no work to do. Reserve them for small, stable text so you do not flood the model with tokens.
Test Your Resource
Run the server and use a client to list and read the URI. Seeing your exact string come back confirms the resource is wired correctly.
Quick Check
Choosing the right primitive for fixed text.
Recap
A static resource is a function under a URI that returns fixed text. Add a docstring description and keep the body small. 📄
よくある質問
「静的なテキストリソースを提供する」レッスンは無料ですか?
はい。「静的なテキストリソースを提供する」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、MCP Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 MCP Academyコースには全4レッスンが含まれています。
「静的なテキストリソースを提供する」で何を学びますか?
モデルが読み取れる固定ドキュメントを公開します。 ブラウザで直接実行するハンズオンコードでMCP Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。
MCP Academyを始めるのに経験は必要ですか?
事前経験は必要ありません。CoddyKitのMCP Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン2/4です。
「静的なテキストリソースを提供する」レッスンにはどのくらい時間がかかりますか?
ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。
このMCP Academyレッスンでコードを書いて実行できますか?
はい。すべてのMCP Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。
このコースのすべてのレッスン
- リソースURIを理解する
- 静的なテキストリソースを提供する
- ディスクからファイルを読み取る
- 適切なMIMEタイプを設定する