.env.example•7.59 kB
#####################################
# Basic Application Settings
#####################################
# The public-facing name of your gateway (used in docs/UI)
APP_NAME=MCP_Gateway
# Bind address for HTTP server (0.0.0.0 for all interfaces)
HOST=0.0.0.0
# TCP port to listen on
PORT=4444
# SQLAlchemy connection string; leave as-is for local dev
# Examples:
# sqlite:///./mcp.db (local file-based)
# postgresql://user:pass@localhost:5432/mcp
DATABASE_URL=sqlite:///./mcp.db
# Optional root path for deployments under a subpath (e.g., /api)
# Leave empty for default (/)
# Example: APP_ROOT_PATH=/gateway
APP_ROOT_PATH=
#####################################
# Database Connection Pooling
#####################################
# Size of the SQLAlchemy connection pool (default is 200)
DB_POOL_SIZE=200
# Number of extra connections allowed beyond pool size
DB_MAX_OVERFLOW=10
# Max time (in seconds) to wait for a connection from pool
DB_POOL_TIMEOUT=30
# Recycle database connections after N seconds
DB_POOL_RECYCLE=3600
# Maximum number of times to boot database connection for cold start
DB_MAX_RETRIES=3
# Interval time for next retry of database connection
DB_RETRY_INTERVAL_MS=2000
#####################################
# Cache Backend
#####################################
# Backend for caching (memory, redis, database, or none)
CACHE_TYPE=database
# If using Redis: provide full connection URL
# Example: redis://localhost:6379/0
REDIS_URL=redis://localhost:6379/0
# Prefix for cache keys (recommended to avoid collisions)
CACHE_PREFIX=mcpgw:
# TTL for user sessions (in seconds)
SESSION_TTL=3600
# TTL for ephemeral messages (like completions) in seconds
MESSAGE_TTL=600
# Maximum number of times to boot redis connection for cold start
REDIS_MAX_RETRIES=3
# Interval time for next retry of redis connection
REDIS_RETRY_INTERVAL_MS=2000
#####################################
# Protocol Settings
#####################################
# MCP protocol version supported by this gateway
PROTOCOL_VERSION=2025-03-26
#####################################
# Authentication
#####################################
# Admin UI basic-auth credentials
# MCP Gateway Admin API credentials for tool registration (used by make mcp-auth, mcp-register-tool, etc)
# Set these to your admin username and password for the admin API
MCP_ADMIN_USERNAME=admin
MCP_ADMIN_PASSWORD=changeme
# MCP Gateway URL (optional, defaults to http://127.0.0.1:4444)
MCP_GATEWAY_URL=http://127.0.0.1:4444
BASIC_AUTH_USER=admin
BASIC_AUTH_PASSWORD=changeme
# Require any form of authentication (true or false)
AUTH_REQUIRED=true
# Secret used to sign JWTs (use long random value in prod)
JWT_SECRET_KEY=my-test-key
# Algorithm used to sign JWTs (e.g., HS256)
JWT_ALGORITHM=HS256
# Expiry time for generated JWT tokens (in minutes; e.g. 7 days)
TOKEN_EXPIRY=10080
# Used to derive an AES encryption key for secure auth storage
# Must be a non-empty string (e.g. passphrase or random secret)
AUTH_ENCRYPTION_SECRET=my-test-salt
#####################################
# Admin UI and API Toggles
#####################################
# Enable the visual Admin UI (true/false)
MCPGATEWAY_UI_ENABLED=false
# Enable the Admin API endpoints (true/false)
MCPGATEWAY_ADMIN_API_ENABLED=false
#####################################
# Security and CORS
#####################################
# Skip TLS certificate checks for upstream requests (not recommended in prod)
SKIP_SSL_VERIFY=false
# CORS origin allowlist (use JSON array of URLs)
# Example: ["http://localhost:3000"]
# Do not quote this value. Start with [] to ensure it's valid JSON.
ALLOWED_ORIGINS='["http://localhost", "http://localhost:4444"]'
# Enable CORS handling in the gateway
CORS_ENABLED=true
#####################################
# Retry Config for HTTP Requests
#####################################
RETRY_MAX_ATTEMPTS=3
RETRY_BASE_DELAY=1.0 # seconds
RETRY_MAX_DELAY=60.0 # seconds
RETRY_JITTER_MAX=0.5 # fraction of delay
#####################################
# Logging
#####################################
# Logging verbosity level: DEBUG, INFO, WARNING, ERROR, CRITICAL
LOG_LEVEL=INFO
# Log format: json or text
LOG_FORMAT=json
# Optional path to write logs to file (leave empty to log to stdout)
#LOG_FILE=./logs/gateway.log
#####################################
# Transport Configuration
#####################################
# Transport mechanisms to expose (comma-separated): http, ws, sse, stdio, all
TRANSPORT_TYPE=all
# WebSocket ping interval (seconds)
WEBSOCKET_PING_INTERVAL=30
# SSE client retry timeout (milliseconds)
SSE_RETRY_TIMEOUT=5000
#####################################
# Streamabe HTTP Transport Configuration
#####################################
# Set False to use stateless sessions without event store and True for stateful sessions
USE_STATEFUL_SESSIONS=false
# Set true for JSON responses, false for SSE streams
JSON_RESPONSE_ENABLED=true
#####################################
# Federation
#####################################
# Enable federated mode (discovery + peer syncing)
FEDERATION_ENABLED=true
# Automatically discover peer gateways (e.g., via mDNS)
FEDERATION_DISCOVERY=false
# Explicit list of peers (JSON array of URLs). Do not quote this value.
FEDERATION_PEERS='[]'
# Timeout for federated requests (in seconds)
FEDERATION_TIMEOUT=30
# Frequency of syncing peers (in seconds)
FEDERATION_SYNC_INTERVAL=300
#####################################
# Resources
#####################################
# Maximum number of resources to keep in memory cache
RESOURCE_CACHE_SIZE=1000
# Time-to-live for resource cache (seconds)
RESOURCE_CACHE_TTL=3600
# Maximum allowed size for a resource (in bytes, e.g., 10MB)
MAX_RESOURCE_SIZE=10485760
#####################################
# Tools
#####################################
# Max execution time for tools (in seconds)
TOOL_TIMEOUT=60
# Number of retry attempts for failed tools
MAX_TOOL_RETRIES=3
# Max number of tool invocations per minute
TOOL_RATE_LIMIT=100
# Number of tools that can run simultaneously
TOOL_CONCURRENT_LIMIT=10
#####################################
# Prompts
#####################################
# How many prompt templates to cache
PROMPT_CACHE_SIZE=100
# Max size (in bytes) for a prompt template
MAX_PROMPT_SIZE=102400
# Timeout for rendering prompt templates (in seconds)
PROMPT_RENDER_TIMEOUT=10
#####################################
# Health Checks
#####################################
# How often to poll peer gateways (in seconds)
HEALTH_CHECK_INTERVAL=60
# Timeout for a single health check request (seconds)
HEALTH_CHECK_TIMEOUT=10
# Number of failed checks before marking peer unhealthy
UNHEALTHY_THRESHOLD=3
#####################################
# Lock file Settings
#####################################
# This path is append with the system temp directory.
# It is used to ensure that only one instance of the gateway health Check can run at a time.
FILELOCK_NAME=gateway_healthcheck_init.lock # saved dir in /tmp/gateway_healthcheck_init.lock
# FILELOCK_NAME=somefolder/gateway_healthcheck_init.lock # saved dir in /tmp/somefolder/gateway_healthcheck_init.lock#
#####################################
# Development Settings
#####################################
# Enable dev mode features (e.g. schema debug)
DEV_MODE=false
# Reload app on code changes (dev only)
RELOAD=false
# Enable verbose logging/debug traces
DEBUG=false
# Gateway tool name separator
GATEWAY_TOOL_NAME_SEPARATOR=-
VALID_SLUG_SEPARATOR_REGEXP= r"^(-{1,2}|[_.])$"