Environment Configuration
Both the MCP server and webhook server share common environment variable requirements for Slack integration, queue backends, and basic configuration. This guide covers all shared environment variables used across both server types.
Required Environment Variables
Slack Authentication
The primary requirement for both servers is Slack bot authentication:
# Slack bot token (required for both MCP and webhook servers)
SLACK_BOT_TOKEN="xoxb-your-bot-token-here"
How to get your bot token:
- Go to Slack API Apps
- Create a new app or select an existing one
- Navigate to "OAuth & Permissions"
- Copy the "Bot User OAuth Token" (starts with
xoxb-)
Optional Environment Variables
Alternative Authentication Variables
# Alternative token variable (fallback, used by some legacy configurations)
SLACK_TOKEN="xoxb-your-bot-token-here"
# Additional Slack credentials (for advanced features)
SLACK_BOT_ID="B1234567890" # Your bot's user ID
SLACK_USER_TOKEN="xoxp-your-user-token" # For user-level operations
SLACK_SIGNING_SECRET="your-signing-secret" # For webhook request verification
Development and Testing Variables
# Test channel configuration (useful for development/testing)
SLACK_TEST_CHANNEL="#dev-testing" # Channel name with #
SLACK_TEST_CHANNEL_ID="C1234567890" # Channel ID (recommended)
Queue Backend Configuration
Both servers support multiple queue backend options for handling asynchronous operations:
# Queue backend selection
QUEUE_BACKEND="memory" # Options: memory | redis | kafka
# Redis backend settings (when QUEUE_BACKEND=redis)
REDIS_URL="redis://localhost:6379/0"
# Kafka backend settings (when QUEUE_BACKEND=kafka)
KAFKA_BOOTSTRAP="broker1:9092,broker2:9092"
Queue Backend Options:
- memory: In-memory queue (default, good for development)
- redis: Redis-based queue (recommended for production)
- kafka: Apache Kafka (for high-throughput scenarios)
Environment File Examples
Development Environment (.env.development)
- Basic Setup
- Advanced Setup
# Basic development configuration
SLACK_BOT_TOKEN="xoxb-your-development-token"
SLACK_TEST_CHANNEL="#dev-testing"
QUEUE_BACKEND="memory"
# Advanced development configuration
SLACK_BOT_TOKEN="xoxb-your-development-token"
SLACK_USER_TOKEN="xoxp-your-user-token"
SLACK_SIGNING_SECRET="your-development-signing-secret"
SLACK_TEST_CHANNEL="#dev-testing"
SLACK_TEST_CHANNEL_ID="C1234567890"
QUEUE_BACKEND="redis"
REDIS_URL="redis://localhost:6379/1"
Production Environment (.env.production)
- Basic Production
- Advanced Production
# Basic production configuration
SLACK_BOT_TOKEN="xoxb-your-production-token"
QUEUE_BACKEND="redis"
REDIS_URL="redis://prod-redis:6379/0"
# Advanced production configuration
SLACK_BOT_TOKEN="xoxb-your-production-token"
SLACK_USER_TOKEN="xoxp-your-user-token"
SLACK_SIGNING_SECRET="your-production-signing-secret"
QUEUE_BACKEND="kafka"
KAFKA_BOOTSTRAP="kafka-1:9092,kafka-2:9092,kafka-3:9092"
Testing Environment (.env.test)
# Testing configuration
SLACK_BOT_TOKEN="xoxb-your-test-token"
SLACK_TEST_CHANNEL="#automated-testing"
SLACK_TEST_CHANNEL_ID="C9876543210"
QUEUE_BACKEND="memory"
Docker Environment Configuration
When running servers in Docker containers, you can pass environment variables in several ways:
Using Environment Files
# Run with environment file
docker run --env-file .env.production your-server-image
# Docker Compose
version: '3.8'
services:
slack-server:
image: your-server-image
env_file:
- .env.production
Using Environment Variables Directly
# Pass individual environment variables
docker run \
-e SLACK_BOT_TOKEN="xoxb-your-token" \
-e QUEUE_BACKEND="redis" \
-e REDIS_URL="redis://redis:6379/0" \
your-server-image
Environment Variable Validation
Both servers perform automatic validation of environment variables on startup:
Required Variable Validation
- Checks for presence of
SLACK_BOT_TOKEN - Validates token format (must start with
xoxb-) - Warns about missing optional variables
Queue Backend Validation
- Validates
QUEUE_BACKENDvalue against allowed options - Checks backend-specific connection variables
- Tests connectivity to external services (Redis/Kafka)
Common Validation Errors
# Missing required token
❌ Error: SLACK_BOT_TOKEN environment variable is required
# Invalid token format
❌ Error: SLACK_BOT_TOKEN must start with 'xoxb-'
# Invalid queue backend
❌ Error: QUEUE_BACKEND must be one of: memory, redis, kafka
# Redis connection failed
❌ Error: Cannot connect to Redis at redis://localhost:6379/0
Security Best Practices
Token Security
- Never commit tokens to version control
- Use
.envfiles and add them to.gitignore - Rotate tokens regularly in production
- Use different tokens for different environments
Environment File Security
- Set appropriate file permissions:
chmod 600 .env - Store production
.envfiles securely - Use secrets management systems in production (e.g., Kubernetes secrets, AWS Secrets Manager)
Example .gitignore
# Environment files
.env
.env.local
.env.development
.env.production
.env.test
# Backup env files
*.env.backup
Troubleshooting Environment Issues
Token Issues
# Test token validity
curl -H "Authorization: Bearer $SLACK_BOT_TOKEN" \
https://slack.com/api/auth.test
Redis Connection Issues
# Test Redis connection
redis-cli -u $REDIS_URL ping
Environment Variable Debug
# Check if variables are loaded
env | grep SLACK_
env | grep QUEUE_
env | grep REDIS_
For server-specific configuration options, see: