Resources and Prompts
6.1 Resources in Detail
Resources allow Servers to expose data to AI applications. The distinction from Tools:| Tools | Resources | |
|---|---|---|
| Nature | Execute operations | Provide data |
| Controlled by | AI model decides to invoke | Application (Host) actively reads |
| Side effects | Possible (write to DB, call API) | None (read-only) |
| Scenario | ”Check inventory for me" | "Here is the product category structure” |
Resource URIs
Each resource has a unique URI identifier:URI Templates (RFC 6570)
MCP supports RFC 6570 URI template syntax for defining dynamic resources. Servers can include URI templates inresources/list responses, and Clients fill in template variables to request specific resources:
Annotations
Each resource can carry Annotations metadata to help the Host decide how to use the resource:| Field | Type | Description |
|---|---|---|
audience | String array | Target audience. "user" means suitable for display to users; "assistant" means suitable for the AI model |
priority | Number (0-1) | Priority. 1 is highest. The Host can use this to decide which resources to load first when context window space is limited |
lastModified | ISO 8601 string | Last modified time. Helps the Client decide whether to re-read |
Resource Subscriptions
If the Server declaresresources: { subscribe: true } during initialization, the Client can subscribe to resource changes:
resources/read to get the latest data. This pattern suits scenarios with high real-time requirements, such as inventory monitoring.
To unsubscribe:
Resource List Change Notifications
When the Server’s resource collection changes (resources added or removed), it can notify the Client:resources/list to get the latest resource list.
Implementation Example
6.2 Prompts in Detail
Prompts are predefined interaction templates provided by the Server. Unlike Tools and Resources, Prompts are user-controlled — users actively select which template to use in the Host application.Prompt Structure
Getting a Prompt (with Arguments)
Commerce Prompt Examples
Multi-Message Prompts
Prompts can return multiple messages, including the system role:Prompts with Embedded Resources
Messages in Prompts can use theembedded_resource type to embed resource data:
When to Use Prompt vs Tool vs Resource
| Scenario | Recommendation | Reason |
|---|---|---|
| Fixed interaction patterns | Prompt | Templated, user-selectable |
| Dynamic operations | Tool | AI model decides autonomously |
| Requires specific question format | Prompt | Controls input quality |
| Requires executing an action | Tool | Prompts only provide templates |
| Static context data | Resource | No side effects, Host controls read timing |
| High-priority background information | Resource + Annotations | priority field controls loading priority |
Next Chapter: Security and Authentication — OAuth 2.1 integration and permission management