Skip to main content
Glama
piekstra

Slack MCP Server

by piekstra

upload_file

Upload files to Slack channels by specifying channel IDs, file content, and filename. Add titles and comments to share information directly in Slack workspaces.

Instructions

Upload a file to one or more Slack channels.

Args: channels: Comma-separated list of channel IDs content: File content as text filename: Name for the file title: Title of the file initial_comment: Initial comment for the file

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
channelsYes
contentYes
filenameYes
titleNo
initial_commentNo

Implementation Reference

  • MCP tool handler for upload_file: decorated with @mcp.tool(), parses input, calls SlackClient.upload_file, returns JSON result or error.
    @mcp.tool()
    async def upload_file(
        channels: str, content: str, filename: str, title: Optional[str] = None, initial_comment: Optional[str] = None
    ) -> str:
        """
        Upload a file to one or more Slack channels.
    
        Args:
            channels: Comma-separated list of channel IDs
            content: File content as text
            filename: Name for the file
            title: Title of the file
            initial_comment: Initial comment for the file
        """
        try:
            client = SlackClient()
            channels_list = channels.split(",")
            result = await client.upload_file(channels_list, content, filename, title, initial_comment)
            return json.dumps(result, indent=2)
        except Exception as e:
            return json.dumps({"error": str(e)}, indent=2)
  • SlackClient helper method that makes the actual Slack API call to files.upload with prepared parameters.
    async def upload_file(
        self,
        channels: List[str],
        content: str,
        filename: str,
        title: Optional[str] = None,
        initial_comment: Optional[str] = None,
    ) -> Dict[str, Any]:
        """Upload a file to one or more channels."""
        data = {"channels": ",".join(channels), "content": content, "filename": filename}
    
        if title:
            data["title"] = title
    
        if initial_comment:
            data["initial_comment"] = initial_comment
    
        return await self._make_request("POST", "files.upload", json_data=data)

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/piekstra/slack-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server