Skip to main content
Resources expose data to MCP clients. Unlike tools (which perform actions), resources provide read-only access to content like files, database records, or live data.

Example

Anatomy of a Resource

When a client calls resources/list, the server returns metadata for each resource. Resources with URI templates (like {section}) are returned via resources/templates/list instead. Here’s the JSON-RPC response that the example above produces when a client calls resources/templates/list:
Here’s what maps to what:
If your URI contains {param} placeholders, the resource is registered as a template. Otherwise, it’s registered as a static resource.

Static Resources

Resources without URI parameters are static - they always return at the same URI:

Resource Templates

Use {param} placeholders in the URI to create dynamic resources:
Clients request user://123 and the function receives user_id="123".

Multiple Parameters

Templates support multiple parameters:

Async Resources

Resources can be async for I/O operations:

Binary Resources

Return bytes for binary content:

Resource Subscriptions

Clients can subscribe to resources and receive notifications when they change. This follows the MCP resource subscriptions spec.

How It Works

  1. Client sends resources/subscribe with a resource URI
  2. Your server updates the resource and calls notify_resource_updated()
  3. All subscribed clients receive a notifications/resources/updated notification
  4. Clients re-read the resource to get the new content
MCPServer handles subscribe/unsubscribe tracking automatically - you just need to call notify_resource_updated() when your resource changes.

Example

When a client subscribes to data://price and then any client calls update_price, all subscribers receive the notification and can re-read the resource.
Subscriptions are session-scoped - they’re automatically cleaned up when a client disconnects. If the server restarts, clients need to re-subscribe.

Common MIME Types

Resources vs Tools