A Python implementation of a Model Context Protocol (MCP) server for Slack integration. This server allows AI assistants to interact with Slack workspaces through a standardized interface.
- Python 3.12+
- A Slack Bot Token with appropriate permissions
- Slack Team ID
# Install uv if you haven't already
curl -LsSf https://astral.sh/uv/install.sh | sh
# Install dependencies
uv pip install -r requirements.txtpip install -r requirements.txtSet the following environment variables:
SLACK_BOT_TOKEN: Your Slack bot token (required)SLACK_TEAM_ID: Your Slack team/workspace ID (required)SLACK_CHANNEL_IDS: Comma-separated list of channel IDs to limit access (optional)
export SLACK_BOT_TOKEN="xoxb-your-bot-token"
export SLACK_TEAM_ID="T1234567890"
python slack_mcp_server.pyBuild the image:
docker build -t slack-mcp-server .Run the container:
docker run -e SLACK_BOT_TOKEN="xoxb-your-bot-token" \
-e SLACK_TEAM_ID="T1234567890" \
slack-mcp-server- Create a new Slack app at https://api.slack.com/apps
- Add the following OAuth scopes to your bot:
channels:readchat:writegroups:readreactions:writeusers:readusers.profile:read
- Install the app to your workspace
- Copy the Bot User OAuth Token
This server implements the Model Context Protocol and exposes the following tools:
slack_list_channels: List available channelsslack_post_message: Post a message to a channelslack_reply_to_thread: Reply to a message threadslack_add_reaction: Add an emoji reactionslack_get_channel_history: Get recent messages from a channelslack_get_thread_replies: Get all replies in a threadslack_get_users: List workspace usersslack_get_user_profile: Get detailed user profile
.
├── main.py # Main server implementation
├── requirements.txt # Python dependencies
├── Dockerfile # Container configuration
└── README.md # This file
To add a new tool:
- Define the tool schema in the
TOOLSlist - Add the corresponding method to
SlackClient - Handle the tool call in the
call_toolfunction
MIT
Contributions are welcome! Please feel free to submit a Pull Request.