リソースURIを理解する
スキームとパスでリソースを指定する方法を学びます。
「リソースURIを理解する」はCoddyKit上の無料MCP Academyレッスンです。 これはレッスン1/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはMCP Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 MCP Academyコースには全4レッスンが含まれています。
このレッスンの一部はまだ翻訳されておらず、英語で表示されています。
What a Resource Is
An MCP resource is read-only context your server hands the model, like a file, config, or record. The AI reads it, but never changes it.
Why an Address
Each resource needs a stable name so a client can ask for it by reference. That name is its URI, just like a web page has a URL. 🔗
Scheme Then Path
A resource URI is built from a scheme, then a colon and slashes, then a path. The scheme says what kind of thing the URI points to.
file:///notes/today.txt
config://app/settingsPick Your Own Scheme
You are free to invent a scheme that fits your server, such as config or db. The scheme groups related resources under one clear label.
The file Scheme
The file scheme is common for documents on disk. Three slashes mean the path starts at the root, just like file URLs in a browser.
file:///home/data/report.mdCustom Scheme Example
For app data, a tidy custom scheme keeps things readable. The model sees a name that tells it exactly what the resource holds.
users://profile/active
weather://city/londonURIs Must Be Unique
Every resource needs its own distinct URI so requests are never ambiguous. Two resources sharing one URI would collide and confuse clients.
Declare It in FastMCP
In the Python SDK you attach a URI to a function with the resource decorator. That string is the address clients use to read it.
from mcp.server.fastmcp import FastMCP
mcp = FastMCP("Demo")
@mcp.resource("config://app")
def config(): ...Clients List URIs
When a client connects, it asks the server to list every resource it offers. Each entry carries its URI, a name, and a short description.
Read by URI
To fetch content, the client sends a read request naming the exact URI. The server matches that URI to a handler and returns the body.
Keep URIs Stable
Treat a published URI like a promise. Renaming it later breaks any client or saved reference that pointed at the old address.
Quick Check
Spot the part that defines the resource type.
Recap
Resources are read-only context named by a URI: a scheme plus a path. Keep URIs unique and stable so clients can rely on them. ✅
よくある質問
「リソースURIを理解する」レッスンは無料ですか?
はい。「リソースURIを理解する」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、MCP Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 MCP Academyコースには全4レッスンが含まれています。
「リソースURIを理解する」で何を学びますか?
スキームとパスでリソースを指定する方法を学びます。 ブラウザで直接実行するハンズオンコードでMCP Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。
MCP Academyを始めるのに経験は必要ですか?
事前経験は必要ありません。CoddyKitのMCP Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン1/4です。
「リソースURIを理解する」レッスンにはどのくらい時間がかかりますか?
ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。
このMCP Academyレッスンでコードを書いて実行できますか?
はい。すべてのMCP Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。
このコースのすべてのレッスン
- リソースURIを理解する
- 静的なテキストリソースを提供する
- ディスクからファイルを読み取る
- 適切なMIMEタイプを設定する