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_modelstring
default: gpt-4o

Default AI model for optimization

gpt-4oclaude-3.5-sonnetgpt-4gpt-3.5-turbogemini-pro
compression_levelstring
default: advanced

Default compression level

basicadvancedpremium
output_formatstring
default: json

Default output format

jsonwmcpyaml
verboseboolean
default: false

Enable detailed logging

Security Configuration

Authentication, encryption, and security settings

enable_csrfboolean
default: false

Enable CSRF token protection

encryptionstring
default: none

Encryption method for sensitive data

noneaesjwe
jwt_secretstring
default: null

JWT signing secret (required for JWT auth)

jwt_expires_innumber
default: 3600

JWT expiration time in seconds

jwt_scopesarray
default: []

Default JWT scopes for API access

Performance Configuration

Caching, optimization, and performance settings

cache_enabledboolean
default: true

Enable LRU/TTL caching system

cache_sizenumber
default: 1000

Maximum number of cached items

cache_ttlnumber
default: 3600

Cache TTL in seconds

parallel_processingboolean
default: true

Enable parallel processing for batch operations

max_workersnumber
default: 4

Maximum number of worker threads

API Configuration

External API settings and rate limiting

api_keystring
default: null

API key for premium features

api_base_urlstring
default: https://api.webmcp.dev

Base URL for webMCP API

rate_limitnumber
default: 100

API requests per minute

timeoutnumber
default: 30000

Request timeout in milliseconds

retry_attemptsnumber
default: 3

Maximum 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

VariableDescriptionRequired
WEBMCP_API_KEYAPI key for premium featuresOptional
WEBMCP_JWT_SECRETSecret for JWT token signingOptional
WEBMCP_TARGET_MODELDefault AI modelOptional
WEBMCP_COMPRESSION_LEVELDefault compression levelOptional
WEBMCP_CACHE_DIRCache directory pathOptional
WEBMCP_LOG_LEVELLogging level (debug, info, warn, error)Optional
WEBMCP_TIMEOUTRequest timeout in millisecondsOptional
DEBUGEnable debug modeOptional

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