feat: add BotName, FileCount, HasMedia fields to message output#170
feat: add BotName, FileCount, HasMedia fields to message output#170korotovsky merged 4 commits intokorotovsky:masterfrom
Conversation
Adds metadata fields to help identify media-containing messages: - BotName: populated from msg.BotProfile.Name for bot messages (e.g., 'giphy') - FileCount: count of attached files - HasMedia: true if message has files OR image blocks This provides visibility into message types that was previously stripped from the Slack API response, addressing user requests in issue korotovsky#88. For SearchMessage results, only HasMedia is populated (via blocks) since the search API doesn't return BotProfile or Files data.
|
In the original request #88 it has been also asked to provide the tool for fetching the attachment itself. I guess plaintext attachments must be returned as text and blobs must be encoded as base64. |
Adds ability to download file content by file ID, addressing maintainer request on PR korotovsky#170. - New files_get tool gated by SLACK_MCP_FILES_TOOL env var - Text files (text/*, application/json, etc.) returned as plain text - Binary files returned as base64-encoded content - 5MB size limit to keep responses reasonable for LLM context - Returns structured JSON: file_id, filename, mimetype, size, encoding, content
|
How Agent or MCP Client will get context of file_id? Not sure if we collect all available fileIds per message? Could you share screenshot how did you use tool |
Enables agents to discover file IDs from conversation history, completing the workflow for files_get tool usage.
|
Good catch! I've added a Complete Workflow ExampleStep 1: Get conversation history Response (CSV): MsgID,UserID,...,FileCount,FileIDs,HasMedia,Cursor
1739821275.613919,UBHCH6943,...,1,F08DQ3DBAM8,true,
1727712637.419529,UBHCH6943,...,1,F07QCNL4XFS,true,
1769715839.885789,UBHCH6943,...,0,,false,Step 2: Agent sees Step 3: Fetch file content Response: {
"file_id": "F08DQ3DBAM8",
"filename": "20250217_134047.jpg",
"mimetype": "image/jpeg",
"size": 825923,
"encoding": "base64",
"content": "/9j/4AAQSkZJRgABAQAA..."
}For text files, The new |
|
Not sure if splitting |
|
Just tested with a 4-file message - MsgID,...,FileCount,FileIDs,HasMedia,Cursor
1769728398.924449,...,4,"F0ABEBYP33R,F0ABZDCPAQL,F0ABEBZE495,F0ACQ4FTHCY",true,
1739821275.613919,...,1,F08DQ3DBAM8,true,
1769715839.885789,...,0,,false,Single file → no quotes needed. Multiple files → properly quoted. CSV parsers should handle both cases correctly. |
|
And let's rename the tool to |
…gy consistency - Tool: files_get → attachment_get_data - Field: FileIDs → AttachmentIDs - Env var: SLACK_MCP_FILES_TOOL → SLACK_MCP_ATTACHMENT_TOOL Per maintainer feedback - aligns with Slack's 'attachment' terminology and may improve LLM performance due to training data prevalence.
|
Done! Renamed for Slack terminology consistency:
( |
|
@Flare576 yeah, I know, that go library will do automatic quoting in this case as per CSV standard, I'm just trying to make the CSV output as much simpler as possible to be understandable for low-grade models, for them it might be a little confusing different amount of commas in header and in following rows. This is the only my concern. WDYT? |
|
I totally see your point, but I think in this case you'd be introducing a non-standard delimiter ( I think the problem is CSV, but I don't think this is the venue to solve it 😂 |
|
Ok, let's keep auto-quoting. Btw, CSV saves everyone lots of tokens, rather than if we would use native JSON. |
Adds ability to download file content by file ID, addressing maintainer request on PR korotovsky#170. - New files_get tool gated by SLACK_MCP_FILES_TOOL env var - Text files (text/*, application/json, etc.) returned as plain text - Binary files returned as base64-encoded content - 5MB size limit to keep responses reasonable for LLM context - Returns structured JSON: file_id, filename, mimetype, size, encoding, content
Summary
Adds metadata fields to message CSV output to help identify media-containing messages, and adds a new
files_gettool for downloading file content. Addresses #88 and maintainer feedback.Part 1: Message Metadata Fields
New Fields in Message Output:
BotNamemsg.BotProfile.NameFileCountlen(msg.Files)HasMediaExample Output:
Notes:
SearchMessageresults, onlyHasMediais populated (via blocks check) since the search API doesn't returnBotProfileorFilesdataslack.MBTImageconstant to detect image blocksPart 2:
files_getTool (New)Downloads file content by file ID, allowing LLMs to access file attachments.
Guardrail: Requires
SLACK_MCP_FILES_TOOL=trueenvironment variable.Response Format:
{ "file_id": "F0ABV8E0KGC", "filename": "example.txt", "mimetype": "text/plain", "size": 94, "encoding": "none", "content": "File content here..." }Design Decisions:
encoding: "none")encoding: "base64")text/*,application/json,application/xml, etc.Text mimetypes treated as plain text:
text/*application/jsonapplication/xmlapplication/javascriptapplication/x-yamlapplication/tomlFixes #88