MCP Resources for Files
How Resources Work
An MCP server exposes files as resources with stable URIs. A client can discover them throughresources/list, then fetch their content through resources/read.
The important part for file output is the resources/read response. Resource contents can be text:
blob:
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: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
blobfor binary files, base64-encoded without a data URI prefix. - Use
textfor plain text, Markdown, JSON, HTML, and other text-based files.
Example Resource Output
contents array and adds file access metadata under files:
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.
Related Documentation
- Langdock Cookbook - Runnable MCP recipes, including file uploads
- File Input in MCP Tools - Pass user-provided files into MCP tools
- Model Context Protocol (MCP) - Overview of MCP in Langdock
- Langdock Agent MCP Server - Expose your Langdock agents as MCP tools
FAQ
When should an MCP server expose a file as a resource?
When should an MCP server expose a file as a resource?
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. Files inside regular MCP tool results do not become attachments.
What should I check if an MCP file output is missing?
What should I check if an MCP file output is missing?
Check that the MCP server exposes the file as a supported resource, returns the expected metadata, and uses a format Langdock can turn into an attachment. Also confirm the resource read completed successfully.