Skip to main content
Resources are read-only data the client/LLM can pull in as context. Unlike tools (actions), resources are meant to provide information without side effects. Clients can also subscribe to resource URIs and receive change notifications. Resources flow through the MCP protocol like this:
  1. A client discovers resources via resources/list (each resource includes uri, optional name, optional mimeType, etc.).
  2. A client reads a resource via resources/read with a uri.
  3. The server executes your resource handler.
  4. The server returns a ReadResourceResult containing contents per MCP spec.
Define resources with @resource(...) and register them with server.collect(...) (or inside with server.binding(): ...).

Decorator signature

  • resource(...): resource(uri: str, *, name=None, description=None, mime_type=None)
Your handler is called like:
  • fn() → returns str (text) or bytes (binary). (async def is also supported.)

Basic resource

The decorator defines the resource URI. collect() registers it. Clients list resources with resources/list and read them with resources/read.

Text vs binary

Return str for text:
Return bytes for binary (Dedalus encodes it as base64 in the MCP response):

Async resources

Prefer async def for I/O. (Like tools, sync handlers run inline.)

MIME types

Common defaults:
  • text/plain (default when returning str and no mime_type is provided)
  • application/octet-stream (default when returning bytes and no mime_type is provided)

Subscriptions

Clients can subscribe to resource changes via resources/subscribe and unsubscribe via resources/unsubscribe. When your underlying data changes, notify subscribers:
Subscribed clients receive notifications/resources/updated.

Decorator options


Error handling

If your resource handler raises, Dedalus returns a text fallback resource:
  • mimeType="text/plain"
  • text="Resource error: <exception message>"
If a URI is not registered, resources/read returns an empty contents list.

Testing

Test resource handlers as normal functions:
Integration-style test via the server API (mirrors resources/read):

Resource templates

Use @resource_template(...) to advertise URI patterns via resources/templates/list (for client discovery and completions). Dedalus MCP currently registers templates for listing, but does not automatically route resources/read to a template function—you still need to register concrete resource URIs with @resource(...).
Last modified on June 30, 2026