Resources and Prompts: URI Templates, Change Notifications, Progress and Logging, Pagination, and Client Capabilities
Turn read-only data into resources and repeated question patterns into prompts, then round out URI templates, pagination, progress, subscriptions, and caching — the things that keep a server usable at real data volumes.
Today's Goals
- Judge whether a piece of data should become a resource or a tool, and state the reasoning
- Expose a set of parameterized resources with a URI template, and implement cursor pagination for a list endpoint
- Explain the difference between a subscription stream and an in-request notification, and give a use case for each
Yesterday your server had only tools, two of them, equally fast for anyone. Today a realistic volume of data arrives — several thousand notes — and you immediately hit three walls: pagination, caching, and notifications. D1 already took the full message skeleton apart, so today looks only at the new fields. Come back and tick off the three goals above.
Plain-Language Walkthrough
Resources are application-driven: who decides whether one enters the context
Back to the adapter analogy. A tool is like the switch on an appliance: the model reads the manual and presses it. A resource is different, more like the label on a power strip — the host application or the user glances at it and decides whether that socket gets power.
The spec is blunt about this: resources are application-driven, with the host application deciding how to fold them into the context. The typical interface form is a file chooser, a directory tree, or a search box; the app can also attach them automatically by heuristic. A tool, by contrast, is model-controlled, with the model picking from the description itself.
So which form a piece of data takes is decided not by what it is but by who decides whether to use it this time:
| Situation | Make it a |
|---|---|
| Read-only, enumerable, and you want the user to pick it in the interface | Resource |
| Has side effects, or the model should judge when to use it | Tool |
| Needs one retrieval producing results rather than list-then-read | Tool (even though it is read-only) |
That last row is the most easily confused. Searching code looks read-only and resource-like, but it cannot be enumerated — you cannot list every possible query for a user to choose from. Whether it can be listed is the most practical dividing line between a resource and a tool.
That line also has a benefit nobody says out loud and everybody feels: a resource that does not enter the context costs nothing. A tool's definition goes into the request every turn whether used or not; a resource is one catalog entry, occupying not a single token until the host selects it. A knowledge base of three thousand documents made into three thousand tools would blow the context outright, and as resources it costs only when the user picks one.
Which raises the question: three thousand notes, and resources/list returns them all at once?
Interview questions
For the same data, what is the difference between exposing it as an MCP resource versus a tool, and how do you choose?同一份数据,做成 MCP 资源和做成工具有什么区别?你按什么标准选?
Common in ChinaCommon overseasBasic#primitives#server-design🔒 Unlock this chapter to see the answer keys.
Why must MCP pagination cursors be opaque, and what breaks if a client parses them?MCP 的分页游标为什么必须是不透明的?如果客户端去解析它,会出什么问题?
Common in ChinaCommon overseasIntermediate#pagination#api-design🔒 Unlock this chapter to see the answer keys.
On HTTP both subscription streams and in-request progress notifications ride SSE, so why does the 2026-07-28 spec split them into two channels?订阅流和请求内的进度通知在 HTTP 上都走 SSE,为什么 2026-07-28 规范要把它们分成两个通道?
Common in ChinaCommon overseasDeep dive#subscriptions#notifications🔒 Unlock this chapter to see the answer keys.
