Configuration
Complete configuration reference for webMCP. Customize behavior, security, performance, and API settings.
Configuration Options
Comprehensive configuration options organized by category
Basic Configuration
Essential settings to get started with webMCP
target_modelstringDefault AI model for optimization
compression_levelstringDefault compression level
output_formatstringDefault output format
verbosebooleanEnable detailed logging
Security Configuration
Authentication, encryption, and security settings
enable_csrfbooleanEnable CSRF token protection
encryptionstringEncryption method for sensitive data
jwt_secretstringJWT signing secret (required for JWT auth)
jwt_expires_innumberJWT expiration time in seconds
jwt_scopesarrayDefault JWT scopes for API access
Performance Configuration
Caching, optimization, and performance settings
cache_enabledbooleanEnable LRU/TTL caching system
cache_sizenumberMaximum number of cached items
cache_ttlnumberCache TTL in seconds
parallel_processingbooleanEnable parallel processing for batch operations
max_workersnumberMaximum number of worker threads
API Configuration
External API settings and rate limiting
api_keystringAPI key for premium features
api_base_urlstringBase URL for webMCP API
rate_limitnumberAPI requests per minute
timeoutnumberRequest timeout in milliseconds
retry_attemptsnumberMaximum retry attempts for failed requests
Configuration Formats
Multiple ways to configure webMCP for different environments and use cases
JavaScript/TypeScript
Configuration using JavaScript objects
import { WebMCPProcessor } from '@webmcp/core';
const config = {
target_model: 'gpt-4o',
compression_level: 'advanced',
security: {
enable_csrf: true,
encryption: 'jwe',
jwt_secret: process.env.WEBMCP_JWT_SECRET
},
performance: {
cache_enabled: true,
cache_size: 1000,
parallel_processing: true
},
api: {
api_key: process.env.WEBMCP_API_KEY,
timeout: 30000,
retry_attempts: 3
}
};
const processor = new WebMCPProcessor(config);Python
Configuration using Python classes and dictionaries
from webmcp_core import WebMCPProcessor, Config, SecurityConfig, PerformanceConfig
config = Config(
target_model='gpt-4o',
compression_level='advanced',
security=SecurityConfig(
enable_csrf=True,
encryption='jwe',
jwt_secret=os.getenv('WEBMCP_JWT_SECRET')
),
performance=PerformanceConfig(
cache_enabled=True,
cache_size=1000,
parallel_processing=True
),
api_key=os.getenv('WEBMCP_API_KEY')
)
processor = WebMCPProcessor(config)Configuration File
External configuration using JSON, YAML, or TOML
// webmcp.config.json
{
"target_model": "gpt-4o",
"compression_level": "advanced",
"security": {
"enable_csrf": true,
"encryption": "jwe",
"jwt_expires_in": 3600
},
"performance": {
"cache_enabled": true,
"cache_size": 1000,
"parallel_processing": true,
"max_workers": 4
},
"api": {
"base_url": "https://api.webmcp.dev",
"timeout": 30000,
"retry_attempts": 3
}
}
// Load configuration
const config = require('./webmcp.config.json');
const processor = new WebMCPProcessor(config);Environment Variables
Configuration using environment variables
# .env file
WEBMCP_TARGET_MODEL=gpt-4o
WEBMCP_COMPRESSION_LEVEL=advanced
WEBMCP_API_KEY=your_api_key_here
WEBMCP_JWT_SECRET=your_jwt_secret_here
WEBMCP_ENABLE_CSRF=true
WEBMCP_CACHE_ENABLED=true
WEBMCP_CACHE_SIZE=1000
WEBMCP_TIMEOUT=30000
# JavaScript usage
const processor = new WebMCPProcessor({
target_model: process.env.WEBMCP_TARGET_MODEL,
compression_level: process.env.WEBMCP_COMPRESSION_LEVEL,
api_key: process.env.WEBMCP_API_KEY,
// ... other env vars
});Advanced Configurations
Advanced configuration patterns for complex use cases
Custom Optimization Rules
Define custom rules for element detection and optimization
const customRules = {
rules: [
{
name: 'ecommerce-forms',
selector: '[data-checkout], .payment-form',
priority: 'high',
optimization: {
preserve_validation: true,
security_level: 'maximum'
}
},
{
name: 'search-inputs',
selector: 'input[type="search"], .search-box',
priority: 'medium',
optimization: {
enable_suggestions: true,
cache_queries: true
}
}
]
};
const processor = new WebMCPProcessor({
custom_rules: customRules,
target_model: 'gpt-4o'
});Model-Specific Configuration
Different settings for different AI models
const modelConfigs = {
'gpt-4o': {
compression_level: 'advanced',
token_limit: 128000,
cost_per_token: 0.000005
},
'claude-3.5-sonnet': {
compression_level: 'premium',
token_limit: 200000,
cost_per_token: 0.000003
},
'gpt-3.5-turbo': {
compression_level: 'basic',
token_limit: 16000,
cost_per_token: 0.0000015
}
};
const processor = new WebMCPProcessor({
model_configs: modelConfigs,
auto_select_model: true // Automatically choose best model
});Development vs Production
Different configurations for different environments
const config = {
development: {
verbose: true,
cache_enabled: false,
security: {
enable_csrf: false,
encryption: 'none'
},
api: {
base_url: 'http://localhost:3000',
timeout: 60000
}
},
production: {
verbose: false,
cache_enabled: true,
security: {
enable_csrf: true,
encryption: 'jwe'
},
api: {
base_url: 'https://api.webmcp.dev',
timeout: 30000
}
}
};
const env = process.env.NODE_ENV || 'development';
const processor = new WebMCPProcessor(config[env]);Environment Variables
Complete list of supported environment variables
| Variable | Description | Required |
|---|---|---|
WEBMCP_API_KEY | API key for premium features | Optional |
WEBMCP_JWT_SECRET | Secret for JWT token signing | Optional |
WEBMCP_TARGET_MODEL | Default AI model | Optional |
WEBMCP_COMPRESSION_LEVEL | Default compression level | Optional |
WEBMCP_CACHE_DIR | Cache directory path | Optional |
WEBMCP_LOG_LEVEL | Logging level (debug, info, warn, error) | Optional |
WEBMCP_TIMEOUT | Request timeout in milliseconds | Optional |
DEBUG | Enable debug mode | Optional |
Configuration Best Practices
Guidelines for secure and efficient configuration management
Use Environment Variables
Store sensitive data like API keys and JWT secrets in environment variables, never in code.
Environment-Specific Configs
Use different configurations for development, staging, and production environments.
Enable Caching
Enable caching in production to improve performance and reduce API calls.
Validate Configuration
Always validate configuration values on startup to catch errors early.
Document Custom Rules
Document any custom optimization rules for team members and future maintenance.
Rotate Secrets Regularly
Regularly rotate API keys, JWT secrets, and other sensitive configuration values.
Ready to Configure?
Start customizing webMCP for your specific needs and environment