How do URI templates work in MCP Resources, and how do subscriptions differ from a one-shot read?
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
Explain how URI templates are used in MCP Resources and describe the difference between a `resources/read` call and a `resources/subscribe` subscription.
URI templates let one MCP resource declaration cover a whole family of addresses; read is a one-shot pull, subscribe is a server push on change.
Think of a parking garage. Instead of printing a separate sign for every single spot, the garage posts one rule: spot B-{number}. That one pattern covers hundreds of spots without listing each. An MCP URI template works the same way: the server says file://{path} and the host fills in the blank to address any file. Now imagine two ways to check if your car is still there. You could walk down every hour and look yourself, that is a read, one fetch, done. Or you could ask the attendant to text you the moment anything changes, that is a subscribe. The attendant pushes you a message instead of you walking back over and over. Same data, but one is you pulling and one is the server pushing.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
5 min: define resources and URIs, explain RFC 6570 templates with a concrete example, contrast read pull versus subscribe push, then cover capability negotiation and when subscribe earns its state cost.
| Aspect | resources/read | resources/subscribe |
|---|---|---|
| Initiator | Host pulls | Server pushes after registration |
| Timing | Synchronous, one-shot | Ongoing until unsubscribe or disconnect |
| Returns content? | Yes, immediately | No, later via notifications/resources/updated |
| Server state | Stateless per call | Tracks subscribers per URI |
| Best for | On-demand snapshots | Live or frequently changing data |
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Calling a URI template a glob or regex. It is RFC 6570 variable expansion, and resource subscriptions notify on change rather than returning content on the subscribe call itself.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.