Add fetch_file tool: download any Slack attachment on demand - #3
Merged
Merged
Conversation
Non-image files (PDFs, CSVs, HTML, etc.) were only noted by name, so agents couldn't open them. Now every attachment is cached to a local path (same on-demand-Read pattern as images) with a size guard to keep routine history reads from stalling on huge files. Reuses the existing files:read scope.
Message renders (read_history / get_thread / thread-context) no longer download anything — each attachment is annotated inline with its type, size, and Slack file id. The new fetch_file tool takes that id, downloads the file (image, PDF, CSV, whatever) to a local cache dir, and returns the path for the agent's Read tool. Cache-hit reuses; bad/missing ids error gracefully. Reuses files:read.
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.
Agents could only open images — every other attachment (PDF, CSV, HTML, …) was just noted by name with no way to fetch it.
Design: on-demand, not eager. Message renders (
read_history,get_thread, inbound thread-context) download nothing now. Each attachment is annotated inline with its type, size, and Slack file id:When the agent actually wants a file, it calls the new
fetch_filetool with that id → the file is downloaded to a local cache dir and its path returned for the agent's Read tool. Works for images too. Cache-hit reuses; bad/missing ids error gracefully.Reuses the existing
files:readscope — no new Slack permissions.Verified standalone against a real non-image (
text/plainHTML) attachment: annotation triggers no download;fetch_filepulls the full 19,595 bytes; second call hits cache; bad id + missing id both return clean errors. Also verified live after restarting the MCP.