Skip to main content
Version: 0.0.2

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.

Configuration Priority Order

When running the server, configuration values are loaded in this priority order:

  1. .env file (HIGHEST PRIORITY) - Values in your .env file override everything
  2. CLI arguments (--slack-token) - Used as fallback if not set in .env file
  3. 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.

The recommended approach is to use a .env file for managing your configuration:

  1. Create a .env file 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
  2. Run the server (automatically loads from .env):

    # Automatically loads from .env in current directory
    slack-mcp-server

    # Or specify a custom env file path
    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:

# 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

Using Environment Variables

Set environment variables directly in your shell:

# Set environment variable
export SLACK_BOT_TOKEN=xoxb-your-token

# Run server (uses environment variable if not in .env)
slack-mcp-server

Running the Server

Alternative Deployment Options

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:

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:

For HTTP streaming (default)

slack-mcp-server --transport streamable-http

For SSE

slack-mcp-server --transport sse

Custom Port

Run the server on a specific port:

slack-mcp-server --port 8080

Full Example

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_TYPEDescriptionEntry Point
mcp (default)MCP server onlyslack-mcp-server
webhookWebhook server onlyslack-events-server
integratedCombined MCP + webhook via MCP entryslack-mcp-server --integrated
integrated-webhookCombined MCP + webhook via webhook entryslack-events-server --integrated

Environment Variables by Mode

🎯 Main Control Variable

Environment VariableDescriptionDefault
SERVICE_TYPEServer mode: mcp, webhook, integrated, integrated-webhookmcp

🤖 MCP Server Variables (SERVICE_TYPE=mcp or integrated)

Core Configuration:

Environment VariableDescriptionDefault
SLACK_BOT_TOKENSlack bot token (required) - format: xoxb-...-
MCP_TRANSPORTTransport mode: stdio, sse, streamable-httpstdio
MCP_HOSTHost for HTTP transports-
MCP_PORTPort for HTTP transports-
MCP_MOUNT_PATHMount path for HTTP transports-
MCP_LOG_LEVELLogging level (case-insensitive): debug, info, warning, error, criticalinfo
MCP_LOG_FILEPath to log file (enables file logging with auto-rotation)-
MCP_LOG_DIRDirectory for log fileslogs
MCP_LOG_FORMATCustom log format string-
MCP_ENV_FILEPath to custom .env file-
MCP_NO_ENV_FILEDisable .env file loading (set to true)-
MCP_INTEGRATEDEnable integrated mode (set to true)-
MCP_RETRYNumber of retry attempts for network operations-

🪝 Webhook Server Variables (SERVICE_TYPE=webhook or integrated-webhook)

Core Configuration:

Environment VariableDescriptionDefault
SLACK_BOT_TOKENSlack bot token (required) - format: xoxb-...-
SLACK_WEBHOOK_HOSTHost to listen on-
SLACK_WEBHOOK_PORTPort to listen on-
SLACK_WEBHOOK_LOG_LEVELLogging level (case-insensitive): debug, info, warning, error, criticalinfo
SLACK_WEBHOOK_LOG_FILEPath to log file (enables file logging with auto-rotation)-
SLACK_WEBHOOK_LOG_DIRDirectory for log fileslogs
SLACK_WEBHOOK_LOG_FORMATCustom log format string-
SLACK_WEBHOOK_ENV_FILEPath to custom .env file-
SLACK_WEBHOOK_NO_ENV_FILEDisable .env file loading (set to true)-
SLACK_WEBHOOK_INTEGRATEDEnable integrated mode (set to true)-
SLACK_WEBHOOK_MCP_TRANSPORTMCP transport for integrated mode-
SLACK_WEBHOOK_MCP_MOUNT_PATHMCP mount path for integrated mode-
SLACK_WEBHOOK_RETRYNumber of retry attempts-

Docker Examples by Mode

🤖 MCP Server Mode

# 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

🪝 Webhook Server Mode

# 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

🔗 Integrated Server Mode

# 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

📋 Logging Configuration

The server provides comprehensive logging features for both production and development:

Logging Features

  • Case-Insensitive Log Levels: Use debug, DEBUG, or Debug - 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

LevelDescriptionUse Case
DEBUGDetailed diagnostic information (verbose)Development and troubleshooting
INFOGeneral informational messages (default)Production monitoring
WARNINGWarning messages for potential issuesProduction monitoring
ERRORError messages for serious problemsProduction error tracking
CRITICALCritical error messages for fatal issuesProduction 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

  1. 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
  2. Use multi-stage builds for smaller images:

    FROM chisanan232/slack-mcp-server:latest
    # Add your custom configuration
  3. Run as non-root user:

    docker run --user 1000:1000 \
    -e SLACK_BOT_TOKEN=xoxb-your-token \
    chisanan232/slack-mcp-server

📊 Monitoring and Logging

  1. 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
  2. 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
  3. 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.