A resource is usually read once, but some data changes while you work. MCP lets a client subscribe to a resource so the server tells it when the underlying data changes. The server must declare the subscribe feature in its resources capability, the client subscribes with a subscriptions/listen request naming the resource URIs, and the server then delivers notifications/resources/updated on the resulting stream whenever a watched resource changes.
What you need
- A resource whose contents change, such as a file or a status page
- A server that declares the subscribe feature for resources
- A client that can hold a subscription stream open
Step 1: Confirm the server supports subscriptions
Check the server declares the resources capability with the subscribe feature. A server that declares neither listChanged nor subscribe may omit both fields, and cannot send update notifications.
Step 2: Subscribe to the resource URI
Send a subscriptions/listen request with the resource URI listed in notifications.resourceSubscriptions. Subscribe only to the resources the task needs, so a busy server does not flood the client with updates.
Step 3: Check the update arrives and is handled
Change the underlying data and confirm the client receives a notifications/resources/updated message on the subscription stream. Then check the client re-reads the resource with resources/read instead of assuming what changed.
Worked example: synthetic subscription check for one file
The table below is a synthetic example. It shows the expected result of subscribing to a resource; no subscription was made.
| Check | Observed | Result |
|---|---|---|
| Subscribe feature declared | Yes | Pass |
| Subscription sent | file:///notes/status.md | Pass |
| File changed | Update notification received | Pass |
| Client re-read | New content fetched | Pass |
Expected result (UNTESTED). the subscription is accepted, a change produces an update notification, and the client re-reads the resource. This check was not run live; the table shows the expected result for the synthetic example.
Limits
- A subscription only reports that a resource changed; the client must read it again to see the new contents.
- The server delivers updates on the subscription stream opened by subscriptions/listen, not on other streams.
- A server may advertise listChanged and subscribe independently, together, or neither.
- If the resource is deleted, the server returns a resource not found error rather than an empty contents array.
