Configuration Reference
Overview
M2M Protocol can be configured via:
- Configuration file (
~/.m2m/config.toml)
- Environment variables
- Command-line arguments
Priority: CLI > Environment > Config File > Defaults
Configuration File
Default location: ~/.m2m/config.toml
Complete Example
# M2M Protocol Configuration
listen = "127.0.0.1:8080"
# Upstream LLM API endpoint
upstream = "http://localhost:11434/v1"
# API key for upstream (optional)
# Request timeout in seconds
# Compress outgoing requests
# Compress incoming responses
# Preferred algorithm (token, brotli, auto)
# Enable security scanning
# Block unsafe content (vs just logging)
# Confidence threshold (0.0 - 1.0)
# Use ML model for algorithm routing
# Minimum size for Brotli (bytes)
# Prefer token compression for API payloads
prefer_token_for_api = true
# Log level: trace, debug, info, warn, error
# JSON format for structured logging
Environment Variables
| Variable | Description | Default |
|---|
M2M_SERVER_PORT | Proxy listen port | 8080 |
M2M_SERVER_HOST | Proxy listen address | 127.0.0.1 |
M2M_UPSTREAM_URL | Upstream API URL | - |
M2M_API_KEY | API key for upstream | - |
M2M_SECURITY_ENABLED | Enable security scanning | true |
M2M_SECURITY_BLOCKING | Block unsafe content | true |
M2M_BLOCK_THRESHOLD | Security confidence threshold | 0.8 |
M2M_LOG_LEVEL | Logging level | info |
M2M_LOG_JSON | JSON log format | false |
M2M_TIMEOUT | Request timeout (seconds) | 30 |
CLI Arguments
Server Command
-p, --port <PORT> Listen port [default: 8080]
-h, --host <HOST> Listen address [default: 127.0.0.1]
-u, --upstream <URL> Upstream API URL [required]
-k, --api-key <KEY> API key for upstream
--security Enable security scanning
--threshold <FLOAT> Security threshold [default: 0.8]
--timeout <SECONDS> Request timeout [default: 30]
--log-level <LEVEL> Log level [default: info]
--log-json JSON log format
Compress Command
m2m compress [OPTIONS] <CONTENT>
<CONTENT> Content to compress (or - for stdin)
-a, --algorithm <ALG> Algorithm (token, brotli, auto) [default: auto]
-o, --output <FILE> Output file (default: stdout)
Decompress Command
m2m decompress [OPTIONS] <CONTENT>
<CONTENT> Content to decompress (or - for stdin)
-o, --output <FILE> Output file (default: stdout)
Scan Command
m2m scan [OPTIONS] <CONTENT>
<CONTENT> Content to scan
-t, --threshold <FLOAT> Confidence threshold [default: 0.8]
--json JSON output format
Proxy Configuration Details
Listen Address
listen = "127.0.0.1:8080" # Local only
listen = "0.0.0.0:8080" # All interfaces (caution!)
Upstream Configuration
upstream = "http://localhost:11434/v1"
upstream = "https://api.openai.com/v1"
upstream = "https://YOUR-RESOURCE.openai.azure.com/openai/deployments/YOUR-DEPLOYMENT"
Security Configuration
Scanning Modes
| Mode | enabled | blocking | Behavior |
|---|
| Disabled | false | - | No scanning |
| Monitor | true | false | Scan and log, allow all |
| Blocking | true | true | Scan and reject threats |
Threshold Tuning
| Threshold | False Positives | False Negatives |
|---|
| 0.5 | High | Low |
| 0.8 | Medium | Medium |
| 0.95 | Low | High |
Compression Configuration
Algorithm Selection
| Setting | Description |
|---|
auto | Automatically select best algorithm |
token | Always use token compression |
brotli | Always use Brotli compression |
none | Disable compression |
Size Thresholds
# Minimum content size for compression (bytes)
# Use Brotli above this size (bytes)
# Maximum content size (bytes)
Logging Configuration
Log Levels
| Level | Description |
|---|
trace | Very detailed debugging |
debug | Debugging information |
info | Normal operation |
warn | Warning conditions |
error | Error conditions |
JSON Logging
Output:
{"timestamp":"2026-01-17T12:00:00Z","level":"INFO","message":"Request compressed","algorithm":"token","ratio":0.66}