Skip to content

feat(tools): add files_list tool for listing Slack channel files#261

Open
aureliomalheiros wants to merge 1 commit intokorotovsky:masterfrom
aureliomalheiros:feat/files-list-tool
Open

feat(tools): add files_list tool for listing Slack channel files#261
aureliomalheiros wants to merge 1 commit intokorotovsky:masterfrom
aureliomalheiros:feat/files-list-tool

Conversation

@aureliomalheiros
Copy link
Copy Markdown

@aureliomalheiros aureliomalheiros commented Mar 27, 2026

Summary

Adds a new files_list tool that lists files shared in a Slack channel or workspace, completing the file workflow alongside the existing attachment_get_data tool.

Motivation

attachment_get_data downloads a file by ID, but there was no way to discover files shared in a channel. An AI agent can now call files_list to find files, then use the returned FileID with attachment_get_data to read the content.

Changes

pkg/provider/api.go

  • Added ListFilesContext(ctx, params) to the SlackAPI interface
  • Implemented MCPSlackClient.ListFilesContext delegating to slack.Client.ListFilesContext

pkg/handler/conversations.go

  • Added filesListParams struct
  • Added FileListResult CSV struct (FileID, Name, Title, Mimetype, Filetype, PrettyType, Size, UserID, Created, Permalink, Curso\)
  • Added parseParamsToolFilesList using request.GetString (consistent with existing parsers)
  • Added FilesListHandler\ returning CSV output with cursor on the last row

pkg/server/server.go

  • Added ToolFilesList = "files_list" constant
  • Added to ValidToolNames
  • Registered in NewMCPServer guarded by SLACK_MCP_FILES_LIST_TOOL env var (same pattern as attachment_get_data)

Design Decisions

  • Disabled by default — same pattern as attachment_get_data, requires explicit opt-in via env var
  • ListFilesContext over GetFilesContext — cursor-based pagination is preferred over page/count
  • CSV output — consistent with all other tools in the project
  • No new dependencies — uses only the existing github.com/slack-go/slack client

Details:
- Add ListFilesContext to SlackAPI interface and MCPSlackClient implementation
- Add FilesListHandler with CSV output (FileID, Name, Mimetype, Size, UserID, Permalink, Cursor)
- Register files_list tool in server guarded by SLACK_MCP_FILES_LIST_TOOL env var
- Support filtering by channel_id, user_id, types, limit and cursor-based pagination
- Tool is read-only and disabled by default, consistent with attachment_get_data pattern
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant