upload_file
Upload files directly to specified Slack channels. Provide file content, name, title, and an optional initial comment to share documents or updates efficiently.
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 | ||
| initial_comment | No | ||
| title | No |
Implementation Reference
- slack_mcp/server.py:387-408 (handler)MCP tool handler for 'upload_file'. Registers the tool and implements the logic: parses comma-separated channels, instantiates SlackClient, calls its upload_file method with parameters, returns JSON response 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 constructs the API request payload for Slack's files.upload endpoint and calls the generic _make_request method to perform the HTTP POST.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)