Skip to main content
The MCP specification defines resources as the standard way for MCP servers to expose files and other contextual data to clients. Resources are application-driven: the host application decides how users discover, select, read, preview, or attach them. In Langdock, MCP resources can become regular file attachments that users can preview, download, and pass to other tools.

MCP Resources for Files

How Resources Work

An MCP server exposes files as resources with stable URIs. A client can discover them through resources/list, then fetch their content through resources/read. The important part for file output is the resources/read response. Resource contents can be text:
Or binary data, encoded as base64 in blob:
Langdock reads these contents entries and stores them as action-style file outputs. The uri provides the filename, the mimeType tells Langdock how to process the file, and either text or blob contains the file content.

Demo Resource Server

This minimal server exposes one Markdown file as an MCP resource:
When Langdock reads this resource, it attaches summary.md to the conversation.

Requirements

  • Return file data in contents.
  • Include mimeType; Langdock needs it to process the file correctly.
  • Include a meaningful uri; the last path segment becomes the filename.
  • Use blob for binary files, base64-encoded without a data URI prefix.
  • Use text for plain text, Markdown, JSON, HTML, and other text-based files.

Example Resource Output

Langdock stores this as an attachment. The tool result keeps the original contents array and adds file access metadata under files:
The text or blob value stays in the tool result after Langdock stores the file as an attachment, so the resource content counts toward the model’s context window. For binary files, the base64 blob can take up a large share of the available context. Keep resource contents small so the model retains room for the rest of the conversation. A tool can return a large file without putting the bytes in the result. Add a resource_link block to the tool result. When the tool runs in chat or through the API, Langdock reads that URI with resources/read on the same connection and stores the file as a conversation attachment. An Action node in a Workflow does not follow the link, so the block stays in the raw result. The link does not have to appear in resources/list. The server still answers resources/read for that URI with text or blob. When name is set, its last path segment becomes the filename. Langdock uses the URI only when name is missing, or when that segment is ., .., or empty.
Langdock keeps those content blocks. It adds a short file summary under files. The model receives the file path, not the file bytes. If the read fails, the bytes still stay out of the result.
A file whose contents are already in the result stays there. That body still counts toward the model’s context. Return a link when the export is too large to leave in the result.

FAQ

Expose a file as a resource when the result is better handled as a downloadable artifact, such as a generated document, transformed file, report, export, or binary asset. Langdock creates attachments from resources. A tool can also return a file by link. Langdock stores that file as a conversation attachment. File contents that are already in the tool result stay there.
Check that the server returns the file as a supported resource or as a link it can read, includes the expected metadata, and uses a format Langdock can turn into an attachment. Also confirm the read completed successfully. If the file came back as a link, Langdock writes the reason on files.failed_files[].error and leaves the file bytes out of the result:
  • The read failed, or the body was empty.
  • The file passed the size limit for its type.
  • The tool returned more than 20 links.
  • The files together passed 100 MB.
  • The read ran longer than 180 seconds.
  • Storage failed.