ai-agent-slack-mcp-server
v1.0.0
Published
MCP server for Slack integration (messaging, channels, users, files)
Downloads
19
Maintainers
Readme
Slack MCP Server
A Model Context Protocol (MCP) server that provides Slack integration capabilities, including messaging, channel management, user management, and file uploads.
Features
- Send Messages: Send messages to Slack channels or users (with confirmation)
- Get Channels: List channels in the workspace
- Get Messages: Retrieve message history from channels
- Get Users: List users in the workspace
- Upload Files: Upload files to Slack channels (with confirmation)
- OAuth Integration: Seamless authentication via AI Agent CLI
Tools
slack_send_message
Send a message to a Slack channel or user.
Parameters:
channel(required): Channel ID or name (e.g., "#general" or "C1234567890")text(required): Message text to sendconfirm(required): Must be true to confirm sending the messageuser_id(optional): User ID for authentication (defaults to "default")thread_ts(optional): Thread timestamp to reply to a specific message
slack_get_channels
Get a list of channels in the Slack workspace.
Parameters:
user_id(optional): User ID for authentication (defaults to "default")types(optional): Channel types to include (default: "public_channel")
slack_get_messages
Get messages from a Slack channel.
Parameters:
channel(required): Channel ID or nameuser_id(optional): User ID for authentication (defaults to "default")limit(optional): Number of messages to retrieve (default: 10, max: 100)oldest(optional): Start timestamp for message rangelatest(optional): End timestamp for message range
slack_get_users
Get a list of users in the Slack workspace.
Parameters:
user_id(optional): User ID for authentication (defaults to "default")
slack_upload_file
Upload a file to Slack channels.
Parameters:
channels(required): Comma-separated list of channel IDsfile_path(required): Path to the file to uploadconfirm(required): Must be true to confirm uploading the fileuser_id(optional): User ID for authentication (defaults to "default")title(optional): Title of the fileinitial_comment(optional): Initial comment with the file
slack_authenticate
Check authentication status or get authentication instructions.
Parameters:
user_id(optional): User ID to check (defaults to "default")
Installation
npm install
npm run buildUsage with AI Agent CLI
Set up OAuth credentials (obtain from Slack App configuration):
export SLACK_CLIENT_ID="your-slack-client-id" export SLACK_CLIENT_SECRET="your-slack-client-secret"Authenticate with Slack:
ai-agent auth login slackAdd to AI Agent CLI configuration (
~/.agent-fleet/config.json):{ "mcpServers": [{ "name": "slack", "url": "node /path/to/slack-mcp-server/dist/server.js", "oauth": { "service": "slack", "userId": "default" } }] }Use with an agent:
ai-agent chat --agent slack-assistant
OAuth Setup
To use this MCP server, you need to create a Slack App and configure OAuth:
Go to api.slack.com/apps
Create a new app
Configure OAuth & Permissions with these scopes:
channels:readchannels:historychat:writefiles:readfiles:writeusers:readteam:readgroups:readgroups:historyim:readim:historympim:readmpim:history
Set redirect URL to:
http://localhost:3000/oauth/callbackCopy the Client ID and Client Secret to your environment variables
Security Features
- Confirmation Required: Destructive operations (sending messages, uploading files) require explicit confirmation
- OAuth Integration: Secure token management via AI Agent CLI
- User Isolation: Support for multiple authenticated users
- Environment Variable Injection: Tokens provided securely by the AI Agent CLI
Development
# Run in development mode
npm run dev
# Build
npm run build
# Type check
npm run typecheck
# Lint
npm run lint
# Format
npm run formatArchitecture
/src/auth- OAuth2 authentication management/src/handlers- Slack API interaction handlers/src/types- TypeScript type definitions/src/server.ts- Main MCP server implementation
Error Handling
The server provides comprehensive error handling with helpful messages:
- Authentication errors include instructions to use
ai-agent auth login slack - Missing parameters return clear validation messages
- API errors from Slack are properly formatted and returned
- File operations validate file existence before attempting upload
Integration with AI Agent CLI
This MCP server is designed to work seamlessly with the AI Agent CLI's OAuth system:
- OAuth flow is handled by the CLI (which can open browsers)
- Tokens are injected via environment variables
- Multiple users are supported
- Automatic token refresh (when supported by Slack)
- Consistent error handling across all tools
