Slack MCP Server
Overview
The Slack MCP Server is a Model Context Protocol (MCP) server built with FastMCP that enables Claude Code to interact with Slack workspaces. It provides secure, human-monitored access to Slack functionality with Human-in-the-Loop (HITL) enforcement for sensitive operations such as messaging external channels, sending DMs to new users, file uploads, and bulk messaging.
Prerequisites
Slack Bot Token
- Create a Slack App at https://api.slack.com/apps
- Navigate to OAuth & Permissions
- Add the following Bot Token Scopes:
| Scope | Purpose |
|---|---|
| channels:read | List and get info about public channels |
| channels:history | Read messages in public channels |
| groups:read | List and get info about private channels |
| groups:history | Read messages in private channels |
| chat:write | Send messages as the bot |
| files:write | Upload files |
| files:read | Read file metadata |
| reactions:write | Add emoji reactions |
| reactions:read | Read emoji reactions |
| search:read | Search messages in the workspace |
| users:read | Read user profiles |
| im:history | Read DM history |
| im:write | Open DM channels |
- Install the app to your workspace
- Copy the Bot User OAuth Token (starts with
xoxb-)
Environment Variables
SLACK_BOT_TOKEN=xoxb-your-bot-token
SLACK_APP_TOKEN=xapp-your-app-token # Optional: for Socket Mode
SLACK_DEFAULT_CHANNEL=general # Optional: default channel
SLACK_SIGNING_SECRET=your-signing-secret # Optional: for request verification
Quick Start
# Install dependencies
pip install -r .claude/skills/slack-mcp-server/assets/requirements.txt
# Set environment variable
export SLACK_BOT_TOKEN=xoxb-your-bot-token
# Run the server
python .claude/skills/slack-mcp-server/scripts/slack_mcp_server.py
MCP Tools
Available Operations
| Tool | Description | HITL Required |
|---|---|---|
| send_message | Send a message to a channel or thread | External channels only |
| read_channel | Read recent messages from a channel | No |
| search_messages | Search messages across the workspace | No |
| list_channels | List channels in the workspace | No |
| get_channel_info | Get detailed channel information | No |
| upload_file | Upload a file to a channel | Always |
| add_reaction | Add an emoji reaction to a message | No |
| get_thread | Get all replies in a thread | No |
Python Usage
from slack_mcp_server import create_slack_mcp_server
# Create and run the server
server = create_slack_mcp_server()
server.run()
Tool Examples
# Send a message
await send_message(channel="#general", text="Hello from Claude!")
# Send a threaded reply
await send_message(channel="#general", text="Reply here", thread_ts="1234567890.123456")
# Read last 10 messages
messages = await read_channel(channel="#general", limit=10)
# Search workspace
results = await search_messages(query="deployment update", count=5)
# Upload a file
await upload_file(channel="#general", content="Report data...", filename="report.txt", title="Daily Report")
# Add a reaction
await add_reaction(channel="#general", timestamp="1234567890.123456", emoji="thumbsup")
# Get thread replies
thread = await get_thread(channel="#general", thread_ts="1234567890.123456")
HITL Controls
Approval Matrix
| Action | Condition | HITL Required |
|---|---|---|
| Send message | Internal channel | No |
| Send message | External/shared channel | Yes |
| Send DM | Previously messaged user | No |
| Send DM | New user (first contact) | Yes |
| Upload file | Any channel | Yes |
| Bulk messages | More than 3 in 60 seconds | Yes |
| Add reaction | Any message | No |
| Read channel | Any channel | No |
| Search messages | Any query | No |
Approval Workflow
- Claude requests a HITL-gated operation
- An approval request is written to
Pending_Approval/directory - Human reviews and approves or rejects via the approval file
- On approval, the operation executes and result is returned
- All decisions are audit-logged
Configuration
config_manager.py Settings
@dataclass
class SlackConfig:
bot_token: str # SLACK_BOT_TOKEN
app_token: str # SLACK_APP_TOKEN (optional)
default_channel: str # Default channel for messages
hitl_enabled: bool # Enable/disable HITL globally
hitl_external_channels: bool # Require approval for external channels
hitl_new_dm_users: bool # Require approval for new DM recipients
hitl_file_uploads: bool # Require approval for file uploads
hitl_bulk_threshold: int # Message count triggering bulk HITL
hitl_bulk_window_seconds: int # Window for counting bulk messages
rate_limit_per_minute: int # Max API calls per minute
rate_limit_per_second: int # Max API calls per second
audit_log_path: str # Path to audit log file
approval_dir: str # Directory for pending approvals
approval_timeout_seconds: int # How long approvals remain valid
Rate Limiting
The server enforces Slack API rate limits:
- Tier 1: 1 request per second (most write operations)
- Tier 2: 20 requests per minute (search, list operations)
- Tier 3: 50 requests per minute (read operations)
Custom rate limits can be configured via SlackConfig.
Architecture
slack_mcp_server.py -- FastMCP server with 8 tool endpoints
approval_workflow.py -- HITL approval engine with file-based workflow
config_manager.py -- Configuration dataclass and environment loader
Security Considerations
- Bot tokens are loaded from environment variables, never hardcoded
- All write operations are audit-logged with timestamps and context
- HITL approval is enforced for sensitive operations before execution
- Rate limiting prevents accidental API abuse
- File uploads always require human approval regardless of destination
- The approval directory should have restricted filesystem permissions
Resources
scripts/
Python scripts for the FastMCP server, HITL approval workflow, and configuration management.
assets/
Requirements file and configuration templates.
The Slack MCP server enables secure and compliant Slack workspace operations with appropriate human oversight.
When NOT to Use This Skill
- External customer communications — Slack is an internal tool; use
email-mcp-serverormeta-social-mcp-serverfor external communications - High-volume message broadcasting — Slack's rate limits make it unsuitable for mass notifications; use email or push notification services for broadcasts
- Free-tier Slack workspaces — some Slack API features (webhooks, full message search) require paid plans; verify plan compatibility before building integrations
Common Mistakes
- Using Slack bot tokens instead of app tokens for socket mode — bot tokens are for web API calls; socket mode requires an app-level token; using the wrong token type causes silent authentication failures
- Posting sensitive data in Slack messages — Slack messages are logged, searchable, and often retained indefinitely; never post credentials, PII, or financial data in Slack messages
- Not handling Slack event subscriptions with acknowledgment within 3 seconds — Slack retries unacknowledged events multiple times, creating duplicate message processing; always acknowledge immediately then process asynchronously