Repository navigation
Conversation
attachment_get_data returns the file inside the MCP response, which caps it at 5 MB and sends everything that is neither text nor an image through the client as base64 text. - SLACK_MCP_ATTACHMENT_DIR: when set, the file is streamed into this directory and the tool returns its local path and metadata instead of its content. Bytes go to a hidden .partial file and are renamed into place once complete, so a failed download leaves nothing behind and a reader never sees a truncated file. - SLACK_MCP_ATTACHMENT_MAX_BYTES: configurable size limit, default 5 MiB as before. Enforced against the size files.info reports and again while streaming. An invalid value fails at startup. - File downloads no longer inherit the HTTP client's 30s request timeout, which cut off any download that took longer, in either mode. They are bounded at 10 minutes through the request context instead. - The tool description follows the configured mode and limit. Nothing new comes from the tool call: the download URL is still the one files.info returns, and the file name is Slack's own, reduced to a single path component inside the configured directory.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
attachment_get_datareturns the whole file inside the MCP response. That capsit at 5 MB, and every file that is neither text nor an image arrives as base64
in a text block, which clients that cap tool output (common for agent hosts)
truncate into something undecodable well below 5 MB.
This adds an opt-in mode for clients that share the server's filesystem, such
as an agent running the server over stdio on the same host:
SLACK_MCP_ATTACHMENT_DIR: when set, the file is streamed into thisdirectory as
<file ID>-<file name>and the tool returns metadata plus thelocal
pathinstead of the content. Bytes go to a hidden.partialfile andare renamed into place when complete, so a failed download leaves nothing
behind. Unset, behaviour is unchanged.
SLACK_MCP_ATTACHMENT_MAX_BYTES: the size limit, default 5 MiB as today.Checked against the size
files.inforeports and again while streaming. Aninvalid value fails at startup.
Timeout: 30scovers reading the body, so any download slower than that failed, in either
mode. Downloads now use a client without it and are bounded at 10 minutes
through the request context.
Security
Following the concerns raised on #121 and #285:
SLACK_MCP_ATTACHMENT_DIRnothing is written to disk.file_id. The download URL is still the onefiles.inforeturns, so there is no caller-controlled URL to scope.to one path component (separators, characters Windows rejects and control
characters replaced, length capped), so it cannot escape the directory.
0644subject to the process umask. The server neverdeletes them; retention is left to the operator.
Testing
pkg/handler/attachments_test.go(make testpasses): atomicwrite and replace, no leftovers on an oversized body or a failed download,
hostile file names, limit parsing, tool description.
SLACK_MCP_PROXY:download fails at 30 s on
masterwithClient.Timeout ... while reading body.body larger than its reported size is cut off at the limit, and no file is
left.
Relates to #247.