upload_file
Upload files to Slack channels by providing content, filename, and target channels to share documents and data within your workspace.
Instructions
Upload a file to Slack
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| channels | Yes | Array of channel IDs to share the file to | |
| content | Yes | File content | |
| filename | Yes | Filename | |
| title | No | File title | |
| initial_comment | No | Initial comment |
Implementation Reference
- src/tools/files.ts:4-25 (handler)The main handler function for the 'upload_file' tool. It validates the input arguments using uploadFileSchema and uploads the file content to specified Slack channels using the files.uploadV2 API, returning the file object.export async function uploadFile(client: SlackClientWrapper, args: unknown) { const params = uploadFileSchema.parse(args); return await client.safeCall(async () => { const result = await client.getClient().files.uploadV2({ channels: params.channels.join(','), content: params.content, filename: params.filename, title: params.title, initial_comment: params.initial_comment, }); const maybeFile = (result && typeof result === 'object' && 'file' in result) ? (result as { file?: unknown }).file : undefined; return { ok: true, file: maybeFile, }; }); }
- src/utils/validators.ts:86-92 (schema)Zod schema for input validation of the upload_file tool, defining required channels array, content, filename, and optional title and initial_comment.export const uploadFileSchema = z.object({ channels: z.array(channelIdSchema).min(1), content: z.string().min(1), filename: z.string().min(1), title: z.string().optional(), initial_comment: z.string().optional(), });
- src/index.ts:318-350 (registration)MCP tool registration in the list_tools response, defining the name, description, and inputSchema for 'upload_file'.{ name: 'upload_file', description: 'Upload a file to Slack', inputSchema: { type: 'object', properties: { channels: { type: 'array', items: { type: 'string', }, description: 'Array of channel IDs to share the file to', }, content: { type: 'string', description: 'File content', }, filename: { type: 'string', description: 'Filename', }, title: { type: 'string', description: 'File title', }, initial_comment: { type: 'string', description: 'Initial comment', }, }, required: ['channels', 'content', 'filename'], }, },
- src/index.ts:434-434 (registration)Registration of the upload_file handler in the internal tool dispatch map, mapping the tool name to the fileTools.uploadFile function.upload_file: (args) => fileTools.uploadFile(slackClient, args),