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
| Name | Required | Description | Default |
|---|---|---|---|
| channels | Yes | ||
| content | Yes | ||
| filename | Yes | ||
| title | No | ||
| initial_comment | No |
Implementation Reference
- slack_mcp/server.py:387-407 (handler)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)
- slack_mcp/server.py:158-175 (helper)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)