.env.example•7.5 kB
# =============================================================================
# MCP DadosBR - Environment Configuration Example
# =============================================================================
# Copy this file to .env and configure according to your needs
# For more information: https://github.com/cristianoaredes/mcp-dadosbr
# -----------------------------------------------------------------------------
# Transport Configuration
# -----------------------------------------------------------------------------
# Transport mode: stdio (default, for IDE integration) or http (for web deployment)
MCP_TRANSPORT=stdio
# HTTP server port (only used when MCP_TRANSPORT=http)
MCP_HTTP_PORT=3000
# -----------------------------------------------------------------------------
# Cache Configuration
# -----------------------------------------------------------------------------
# Maximum number of cache entries
# Default: 256
# Valid range: 1-10000
MCP_CACHE_SIZE=256
# Default cache TTL in milliseconds
# Default: 60000 (1 minute)
# Valid range: 1000-3600000 (1 second to 1 hour)
MCP_CACHE_TTL=60000
# Enable background cleanup of expired cache entries
# Default: true
MCP_CACHE_BACKGROUND_CLEANUP=true
# Category-specific cache TTL (optional, overrides MCP_CACHE_TTL)
# CNPJ data TTL - Company data is relatively stable
# Default: 300000 (5 minutes)
MCP_CACHE_TTL_CNPJ=300000
# CEP data TTL - Postal codes are very stable
# Default: 600000 (10 minutes)
MCP_CACHE_TTL_CEP=600000
# Search results TTL - Search results change frequently
# Default: 60000 (1 minute)
MCP_CACHE_TTL_SEARCH=60000
# Intelligence report TTL - Derived from searches
# Default: 30000 (30 seconds)
MCP_CACHE_TTL_INTELLIGENCE=30000
# -----------------------------------------------------------------------------
# API Configuration
# -----------------------------------------------------------------------------
# CNPJ API endpoint URL
# Default: https://api.opencnpj.org/
# Allowed hosts: api.opencnpj.org, receitaws.com.br, brasilapi.com.br,
# publica.cnpj.ws, minhareceita.org, localhost, 127.0.0.1
CNPJ_API_BASE_URL=https://api.opencnpj.org/
# CEP API endpoint URL
# Default: https://opencep.com/v1/
# Allowed hosts: opencep.com, viacep.com.br, brasilapi.com.br,
# cep.awesomeapi.com.br, localhost, 127.0.0.1
CEP_API_BASE_URL=https://opencep.com/v1/
# Custom authentication headers (optional)
# Header name for API authentication
API_KEY_HEADER=X-API-Key
# API key value (leave empty if not required)
API_KEY_VALUE=
# -----------------------------------------------------------------------------
# Search Configuration (Required for search tools)
# -----------------------------------------------------------------------------
# Tavily API key - Required for cnpj_search and cnpj_intelligence tools
# Get your API key at: https://tavily.com
# If not set, search functionality will be disabled
TAVILY_API_KEY=
# -----------------------------------------------------------------------------
# Timeout Configuration
# -----------------------------------------------------------------------------
# HTTP request timeout for external API calls (CNPJ, CEP)
# Default: 8000ms (8 seconds)
# Valid range: 1000-30000ms
MCP_API_TIMEOUT=8000
# Total timeout for intelligence search operations
# Default: 25000ms (25 seconds)
# Valid range: 5000-60000ms
MCP_INTELLIGENCE_TIMEOUT=25000
# Timeout for individual search requests
# Default: 10000ms (10 seconds)
# Valid range: 2000-30000ms
MCP_SEARCH_TIMEOUT=10000
# Timeout for request deduplication cleanup
# Default: 30000ms (30 seconds)
# Valid range: 5000-120000ms
MCP_DEDUP_TIMEOUT=30000
# Circuit breaker reset timeout
# Default: 30000ms (30 seconds)
# Valid range: 10000-300000ms
MCP_CIRCUIT_BREAKER_TIMEOUT=30000
# SSE connection timeout (Cloudflare Workers)
# Default: 300000ms (5 minutes)
# Valid range: 10000-600000ms
MCP_SSE_TIMEOUT=300000
# Ping interval for SSE keep-alive
# Default: 30000ms (30 seconds)
# Valid range: 5000-120000ms
# Note: SSE_TIMEOUT should be > 2 * PING_INTERVAL
MCP_PING_INTERVAL=30000
# Rate limiter cleanup interval
# Default: 60000ms (1 minute)
# Valid range: 10000-600000ms
MCP_RATE_LIMIT_CLEANUP_INTERVAL=60000
# Rate limit window duration
# Default: 60000ms (1 minute)
# Valid range: 10000-600000ms
MCP_RATE_LIMIT_WINDOW=60000
# -----------------------------------------------------------------------------
# Cloudflare Workers Configuration (Production Deployment)
# -----------------------------------------------------------------------------
# API key for Cloudflare Workers endpoints
# Use: wrangler secret put MCP_API_KEY
# This protects REST endpoints: /cnpj/*, /cep/*, /search, /intelligence, /thinking
# Note: /mcp and /sse endpoints remain unauthenticated for AI assistant compatibility
# MCP_API_KEY=your-secret-key-here
# Disable rate limiting (not recommended for production)
# Default: false
# Set to true to disable rate limiting entirely
MCP_DISABLE_RATE_LIMIT=false
# -----------------------------------------------------------------------------
# Logging and Debugging
# -----------------------------------------------------------------------------
# Node environment: development | production
# Default: development
# Production mode disables debug logs and masks sensitive information
NODE_ENV=production
# Log level: debug | info | warn | error
# Default: info (in production), debug (in development)
# - debug: All logs including internal debugging information
# - info: General informational messages
# - warn: Warning conditions
# - error: Error conditions only
LOG_LEVEL=info
# Disable sequential thinking logs
# Default: false
# Set to true to disable verbose thinking process logs
DISABLE_THOUGHT_LOGGING=false
# -----------------------------------------------------------------------------
# Rate Limiting (Local Mode - stdio/http)
# -----------------------------------------------------------------------------
# Rate limit time window in milliseconds
# Default: 60000 (1 minute)
RATE_LIMIT_WINDOW_MS=60000
# Maximum requests per window per client
# Default: 30
RATE_LIMIT_MAX_REQUESTS=30
# -----------------------------------------------------------------------------
# Advanced Configuration (Use with caution)
# -----------------------------------------------------------------------------
# Maximum concurrent searches in intelligence operations
# Default: 3
# Valid range: 1-10
# MAX_CONCURRENT_SEARCHES=3
# Maximum results to cache for search queries
# Default: 20
# MAX_RESULTS_CACHED=20
# -----------------------------------------------------------------------------
# Scenario-Based Configuration Examples
# -----------------------------------------------------------------------------
# Example 1: Development/Testing (Fast, short TTLs)
# NODE_ENV=development
# LOG_LEVEL=debug
# MCP_CACHE_TTL=30000
# MCP_API_TIMEOUT=5000
# Example 2: Production (Secure, long TTLs, masked logs)
# NODE_ENV=production
# LOG_LEVEL=info
# MCP_CACHE_TTL_CNPJ=600000
# MCP_CACHE_TTL_CEP=1200000
# MCP_API_TIMEOUT=10000
# Example 3: High-Performance (Aggressive caching)
# MCP_CACHE_SIZE=1024
# MCP_CACHE_TTL_CNPJ=900000
# MCP_CACHE_TTL_CEP=1800000
# Example 4: Slow Network (Longer timeouts)
# MCP_API_TIMEOUT=15000
# MCP_SEARCH_TIMEOUT=20000
# MCP_INTELLIGENCE_TIMEOUT=45000
# Example 5: Cloudflare Workers Deployment
# NODE_ENV=production
# LOG_LEVEL=warn
# MCP_DISABLE_RATE_LIMIT=false
# Use wrangler secrets for MCP_API_KEY and TAVILY_API_KEY