How to Run Slack MCP Server
This guide explains how to run and configure the Slack MCP Server after installation.
Configuration
Before running the server, you need to set up your Slack API token. The server supports multiple configuration methods with a clear priority order.
When running the server, configuration values are loaded in this priority order:
.envfile (HIGHEST PRIORITY) - Values in your.envfile override everything- CLI arguments (
--slack-token) - Used as fallback if not set in.envfile - Environment variables - Already set environment variables (lowest priority)
This means your .env file values will always take precedence over CLI arguments, making environment management easier and more predictable.
Using a .env File (Recommended)
The recommended approach is to use a .env file for managing your configuration:
-
Create a
.envfile in your project directory:# Copy the example file
cp .env.example .env
# Edit with your values
# .env file content:
SLACK_BOT_TOKEN=xoxb-your-slack-bot-token
SLACK_TEST_CHANNEL=#dev-testing
QUEUE_BACKEND=memory -
Run the server (automatically loads from
.env):- pip
- poetry
- uv
# Automatically loads from .env in current directory
slack-mcp-server
# Or specify a custom env file path
slack-mcp-server --env-file .env.production# Automatically loads from .env in current directory
poetry run slack-mcp-server
# Or specify a custom env file path
poetry run slack-mcp-server --env-file .env.production# Automatically loads from .env in current directory
uv run slack-mcp-server
# Or specify a custom env file path
uv run slack-mcp-server --env-file .env.production
Using Command-line Arguments (Fallback)
You can provide your API token directly as a command-line argument. This is useful for quick testing or when you want to disable .env file loading:
- pip
- poetry
- uv
# Use CLI argument as fallback (if not in .env file)
slack-mcp-server --slack-token xoxb-your-token
# Disable .env file loading to force CLI argument usage
slack-mcp-server --slack-token xoxb-your-token --no-env-file
# Use CLI argument as fallback (if not in .env file)
poetry run slack-mcp-server --slack-token xoxb-your-token
# Disable .env file loading to force CLI argument usage
poetry run slack-mcp-server --slack-token xoxb-your-token --no-env-file
# Use CLI argument as fallback (if not in .env file)
uv run slack-mcp-server --slack-token xoxb-your-token
# Disable .env file loading to force CLI argument usage
uv run slack-mcp-server --slack-token xoxb-your-token --no-env-file
Using Environment Variables
Set environment variables directly in your shell:
- pip
- poetry
- uv
# Set environment variable
export SLACK_BOT_TOKEN=xoxb-your-token
# Run server (uses environment variable if not in .env)
slack-mcp-server
# Set environment variable
export SLACK_BOT_TOKEN=xoxb-your-token
# Run server (uses environment variable if not in .env)
poetry run slack-mcp-server
# Set environment variable
export SLACK_BOT_TOKEN=xoxb-your-token
# Run server (uses environment variable if not in .env)
uv run slack-mcp-server
Running the Server
This section covers running the server with Python. For containerized deployments, see 🐳 Docker Usage section below, which provides multiple server modes and production-ready configurations.
Basic Usage
Start the server with default settings using Python:
- pip
- poetry
- uv
slack-mcp-server
poetry run slack-mcp-server
uv run slack-mcp-server
This will start the server with HTTP streaming transport on port 8000.
Specifying Transport Type
You can choose between HTTP streaming and Server-Sent Events (SSE) transport:
- pip
- poetry
- uv
For HTTP streaming (default)
slack-mcp-server --transport streamable-http
For SSE
slack-mcp-server --transport sse
For HTTP streaming (default)
poetry run slack-mcp-server --transport streamable-http
For SSE
poetry run slack-mcp-server --transport sse
For HTTP streaming (default)
uv run slack-mcp-server --transport streamable-http
For SSE
uv run slack-mcp-server --transport sse
Custom Port
Run the server on a specific port:
- pip
- poetry
- uv
slack-mcp-server --port 8080
poetry run slack-mcp-server --port 8080
uv run slack-mcp-server --port 8080
Full Example
- pip
- poetry
- uv
slack-mcp-server --env /path/to/.env --transport sse --port 8080
poetry run slack-mcp-server --env /path/to/.env --transport sse --port 8080
uv run slack-mcp-server --env /path/to/.env --transport sse --port 8080
🐳 Docker Usage
The Slack MCP Server provides a Docker image for easy deployment and containerized environments. The Docker container supports multiple server modes controlled by environment variables.
Quick Start with Docker
Pull and run the Docker image:
# Pull the latest image
docker pull chisanan232/slack-mcp-server:latest
# Run with minimal configuration (defaults to MCP server)
docker run -d -p 8000:8000 \
-e SLACK_BOT_TOKEN=xoxb-your-bot-token-here \
chisanan232/slack-mcp-server
Docker Server Modes
The Docker container uses the SERVICE_TYPE environment variable to determine which server to run:
| SERVICE_TYPE | Description | Entry Point |
|---|---|---|
mcp (default) | MCP server only | slack-mcp-server |
webhook | Webhook server only | slack-events-server |
integrated | Combined MCP + webhook via MCP entry | slack-mcp-server --integrated |
integrated-webhook | Combined MCP + webhook via webhook entry | slack-events-server --integrated |
Environment Variables by Mode
🎯 Main Control Variable
| Environment Variable | Description | Default |
|---|---|---|
SERVICE_TYPE | Server mode: mcp, webhook, integrated, integrated-webhook | mcp |
🤖 MCP Server Variables (SERVICE_TYPE=mcp or integrated)
Core Configuration:
| Environment Variable | Description | Default |
|---|---|---|
SLACK_BOT_TOKEN | Slack bot token (required) - format: xoxb-... | - |
MCP_TRANSPORT | Transport mode: stdio, sse, streamable-http | stdio |
MCP_HOST | Host for HTTP transports | - |
MCP_PORT | Port for HTTP transports | - |
MCP_MOUNT_PATH | Mount path for HTTP transports | - |
MCP_LOG_LEVEL | Logging level (case-insensitive): debug, info, warning, error, critical | info |
MCP_LOG_FILE | Path to log file (enables file logging with auto-rotation) | - |
MCP_LOG_DIR | Directory for log files | logs |
MCP_LOG_FORMAT | Custom log format string | - |
MCP_ENV_FILE | Path to custom .env file | - |
MCP_NO_ENV_FILE | Disable .env file loading (set to true) | - |
MCP_INTEGRATED | Enable integrated mode (set to true) | - |
MCP_RETRY | Number of retry attempts for network operations | - |
🪝 Webhook Server Variables (SERVICE_TYPE=webhook or integrated-webhook)
Core Configuration:
| Environment Variable | Description | Default |
|---|---|---|
SLACK_BOT_TOKEN | Slack bot token (required) - format: xoxb-... | - |
SLACK_WEBHOOK_HOST | Host to listen on | - |
SLACK_WEBHOOK_PORT | Port to listen on | - |
SLACK_WEBHOOK_LOG_LEVEL | Logging level (case-insensitive): debug, info, warning, error, critical | info |
SLACK_WEBHOOK_LOG_FILE | Path to log file (enables file logging with auto-rotation) | - |
SLACK_WEBHOOK_LOG_DIR | Directory for log files | logs |
SLACK_WEBHOOK_LOG_FORMAT | Custom log format string | - |
SLACK_WEBHOOK_ENV_FILE | Path to custom .env file | - |
SLACK_WEBHOOK_NO_ENV_FILE | Disable .env file loading (set to true) | - |
SLACK_WEBHOOK_INTEGRATED | Enable integrated mode (set to true) | - |
SLACK_WEBHOOK_MCP_TRANSPORT | MCP transport for integrated mode | - |
SLACK_WEBHOOK_MCP_MOUNT_PATH | MCP mount path for integrated mode | - |
SLACK_WEBHOOK_RETRY | Number of retry attempts | - |
Docker Examples by Mode
🤖 MCP Server Mode
- stdio (default)
- stdio with logging
- SSE
- SSE with logging
- Streamable HTTP
# MCP server with stdio transport (no HTTP port needed)
docker run -d \
-e SERVICE_TYPE=mcp \
-e SLACK_BOT_TOKEN=xoxb-your-token \
chisanan232/slack-mcp-server
# MCP server with stdio transport and file logging
docker run -d \
-e SERVICE_TYPE=mcp \
-e MCP_LOG_LEVEL=debug \
-e MCP_LOG_FILE=/app/logs/mcp.log \
-e SLACK_BOT_TOKEN=xoxb-your-token \
-v $(pwd)/logs:/app/logs \
chisanan232/slack-mcp-server
# MCP server with SSE transport
docker run -d -p 8000:8000 \
-e SERVICE_TYPE=mcp \
-e MCP_TRANSPORT=sse \
-e MCP_HOST=0.0.0.0 \
-e MCP_PORT=8000 \
-e SLACK_BOT_TOKEN=xoxb-your-token \
chisanan232/slack-mcp-server
# MCP server with SSE transport and comprehensive logging
docker run -d -p 8000:8000 \
-e SERVICE_TYPE=mcp \
-e MCP_TRANSPORT=sse \
-e MCP_HOST=0.0.0.0 \
-e MCP_PORT=8000 \
-e MCP_LOG_LEVEL=debug \
-e MCP_LOG_FILE=/app/logs/mcp-server.log \
-e MCP_LOG_DIR=/app/logs \
-e SLACK_BOT_TOKEN=xoxb-your-token \
-v $(pwd)/logs:/app/logs \
chisanan232/slack-mcp-server
# MCP server with streamable HTTP transport
docker run -d -p 8000:8000 \
-e SERVICE_TYPE=mcp \
-e MCP_TRANSPORT=streamable-http \
-e MCP_HOST=0.0.0.0 \
-e MCP_PORT=8000 \
-e SLACK_BOT_TOKEN=xoxb-your-token \
chisanan232/slack-mcp-server
🪝 Webhook Server Mode
- Basic
- With Logging
# Standalone webhook server
docker run -d -p 3000:3000 \
-e SERVICE_TYPE=webhook \
-e SLACK_WEBHOOK_HOST=0.0.0.0 \
-e SLACK_WEBHOOK_PORT=3000 \
-e SLACK_BOT_TOKEN=xoxb-your-token \
chisanan232/slack-mcp-server
# Webhook server with file logging
docker run -d -p 3000:3000 \
-e SERVICE_TYPE=webhook \
-e SLACK_WEBHOOK_HOST=0.0.0.0 \
-e SLACK_WEBHOOK_PORT=3000 \
-e SLACK_WEBHOOK_LOG_LEVEL=debug \
-e SLACK_WEBHOOK_LOG_FILE=/app/logs/webhook.log \
-e SLACK_BOT_TOKEN=xoxb-your-token \
-v $(pwd)/logs:/app/logs \
chisanan232/slack-mcp-server
🔗 Integrated Server Mode
- Via MCP Entry
- Via Webhook Entry
# Integrated server via MCP entry point
docker run -d -p 8000:8000 \
-e SERVICE_TYPE=integrated \
-e MCP_TRANSPORT=sse \
-e MCP_HOST=0.0.0.0 \
-e MCP_PORT=8000 \
-e SLACK_BOT_TOKEN=xoxb-your-token \
chisanan232/slack-mcp-server
# Integrated server via webhook entry point
docker run -d -p 3000:3000 \
-e SERVICE_TYPE=integrated-webhook \
-e SLACK_WEBHOOK_HOST=0.0.0.0 \
-e SLACK_WEBHOOK_PORT=3000 \
-e SLACK_WEBHOOK_MCP_TRANSPORT=sse \
-e SLACK_BOT_TOKEN=xoxb-your-token \
chisanan232/slack-mcp-server
📋 Logging Configuration
The server provides comprehensive logging features for both production and development:
Logging Features
- ✅ Case-Insensitive Log Levels: Use
debug,DEBUG, orDebug- all work! - ✅ File Logging: Automatic log rotation at 10MB with 5 backup files
- ✅ Custom Formats: Customize log output format for your needs
- ✅ Directory Management: Organize logs in custom directories
Log Levels
| Level | Description | Use Case |
|---|---|---|
DEBUG | Detailed diagnostic information (verbose) | Development and troubleshooting |
INFO | General informational messages (default) | Production monitoring |
WARNING | Warning messages for potential issues | Production monitoring |
ERROR | Error messages for serious problems | Production error tracking |
CRITICAL | Critical error messages for fatal issues | Production critical alerts |
Complete Logging Example
# MCP Server with all logging options
docker run -d -p 8000:8000 \
-e SERVICE_TYPE=mcp \
-e MCP_TRANSPORT=sse \
-e MCP_HOST=0.0.0.0 \
-e MCP_PORT=8000 \
-e MCP_LOG_LEVEL=debug \
-e MCP_LOG_FILE=/app/logs/mcp-server.log \
-e MCP_LOG_DIR=/app/logs \
-e MCP_LOG_FORMAT="%(asctime)s [%(levelname)s] %(name)s: %(message)s" \
-e SLACK_BOT_TOKEN=xoxb-your-token \
-v $(pwd)/logs:/app/logs \
chisanan232/slack-mcp-server
Log Rotation Behavior
- Automatically rotates when log file reaches 10MB
- Keeps 5 backup files (e.g.,
mcp.log.1,mcp.log.2, ...,mcp.log.5) - Oldest backup is deleted on next rotation
- Uses UTF-8 encoding by default
Using Environment Files with Docker
Create a .env file for your configuration:
# Required Slack tokens
SLACK_BOT_TOKEN=xoxb-your-slack-bot-token-here
SLACK_SIGNING_SECRET=your-slack-signing-secret
# Optional Slack configuration
SLACK_BOT_ID=your-slack-bot-id
SLACK_USER_TOKEN=xoxp-your-user-token
SLACK_TEST_CHANNEL=#your-test-channel
SLACK_TEST_CHANNEL_ID=C1234567890
# Message queue backend (memory, redis, kafka)
QUEUE_BACKEND=memory
REDIS_URL=redis://localhost:6379/0
KAFKA_BOOTSTRAP=broker:9092
Mount the .env file when running the container:
docker run -d -p 8000:8000 \
-v $(pwd)/.env:/app/.env \
-e SERVICE_TYPE=mcp \
-e MCP_TRANSPORT=sse \
-e MCP_HOST=0.0.0.0 \
-e MCP_PORT=8000 \
chisanan232/slack-mcp-server
Docker Compose Example
Create a docker-compose.yml file:
version: '3.8'
services:
slack-mcp-server:
image: chisanan232/slack-mcp-server:latest
ports:
- "8000:8000"
environment:
- SERVICE_TYPE=integrated
- MCP_TRANSPORT=sse
- MCP_HOST=0.0.0.0
- MCP_PORT=8000
- MCP_LOG_LEVEL=info
- MCP_LOG_FILE=/app/logs/mcp.log
- SLACK_BOT_TOKEN=${SLACK_BOT_TOKEN}
volumes:
- ./logs:/app/logs
env_file:
- .env
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
interval: 30s
timeout: 10s
retries: 3
# Example with Redis backend
slack-mcp-redis:
image: chisanan232/slack-mcp-server:latest
ports:
- "8001:8000"
environment:
- SERVICE_TYPE=integrated
- MCP_TRANSPORT=sse
- MCP_HOST=0.0.0.0
- MCP_PORT=8000
- SLACK_BOT_TOKEN=${SLACK_BOT_TOKEN}
- QUEUE_BACKEND=redis
- REDIS_URL=redis://redis:6379/0
depends_on:
- redis
restart: unless-stopped
redis:
image: redis:7-alpine
ports:
- "6379:6379"
restart: unless-stopped
Run with Docker Compose:
# Start services
docker-compose up -d
# View logs
docker-compose logs -f slack-mcp-server
# Stop services
docker-compose down
Production Deployment Tips
🔒 Security Best Practices
-
Use Docker Secrets for sensitive data:
# Create secret
echo "xoxb-your-token" | docker secret create slack_bot_token -
# Use in container
docker service create \
--name slack-mcp \
--secret slack_bot_token \
-e SLACK_BOT_TOKEN_FILE=/run/secrets/slack_bot_token \
chisanan232/slack-mcp-server -
Use multi-stage builds for smaller images:
FROM chisanan232/slack-mcp-server:latest
# Add your custom configuration -
Run as non-root user:
docker run --user 1000:1000 \
-e SLACK_BOT_TOKEN=xoxb-your-token \
chisanan232/slack-mcp-server
📊 Monitoring and Logging
-
Health Check Configuration:
docker run -d \
--health-cmd="curl -f http://localhost:8000/health || exit 1" \
--health-interval=30s \
--health-timeout=10s \
--health-retries=3 \
chisanan232/slack-mcp-server -
Application Log Management:
# Enable file logging with rotation
docker run -d -p 8000:8000 \
-e MCP_LOG_LEVEL=info \
-e MCP_LOG_FILE=/app/logs/mcp.log \
-e MCP_LOG_DIR=/app/logs \
-v $(pwd)/logs:/app/logs \
chisanan232/slack-mcp-server -
Docker Log Driver Configuration:
# Configure Docker's log driver for container logs
docker run -d \
--log-driver=json-file \
--log-opt max-size=10m \
--log-opt max-file=3 \
-e MCP_LOG_LEVEL=warning \
chisanan232/slack-mcp-server
🚀 Scaling and Load Balancing
For high-availability deployments:
# docker-compose.yml for load balancing
version: '3.8'
services:
nginx:
image: nginx:alpine
ports:
- "80:80"
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
depends_on:
- slack-mcp-1
- slack-mcp-2
slack-mcp-1:
image: chisanan232/slack-mcp-server:latest
environment:
- SERVICE_TYPE=integrated
- MCP_TRANSPORT=sse
- MCP_HOST=0.0.0.0
- MCP_PORT=8000
slack-mcp-2:
image: chisanan232/slack-mcp-server:latest
environment:
- SERVICE_TYPE=integrated
- MCP_TRANSPORT=sse
- MCP_HOST=0.0.0.0
- MCP_PORT=8000
Verifying Server Operation
Once the server is running, you can verify it's working by accessing:
curl http://localhost:8000/health
You should receive a JSON response confirming the server is operational.