Basic resource
collect() registers it. Clients list resources with resources/list and read them with resources/read.
Text vs binary
Returnstr for text:
bytes for binary (encoded as base64):
Async resources
MIME types
text/plain(default for str)application/jsontext/markdownapplication/octet-stream(default for bytes)
Subscriptions
Clients subscribe to resource changes. Notify them when data updates:notifications/resources/updated.
Decorator options
Error handling
Exceptions return an error wrapper:Testing
Test resources as functions:Resource templates
For dynamic URIs, use resource templates:resources/templates/list. The {user_id} placeholder matches URI parameters.