mcptrust proxy

Command reference for the runtime enforcement proxy.


Synopsis

mcptrust proxy [flags] -- <server-command>

Description

Runs as a stdio proxy between the host (AI agent) and the MCP server. Enforces lockfile allowlists at runtime.

Enforcement Modes

ModeFlagBehavior
Enforce (default)-Filter lists, block calls to unapproved tools
Audit-only--audit-onlyLog blocked requests, but allow all traffic
Filter-only--filter-onlyFilter lists, but don't block calls

Flags

FlagDefaultDescription
--lock(required)Path to v3 lockfile
--timeout10sServer startup timeout
--fail-oncriticalDrift severity threshold: critical, moderate, info
--policy(empty)Policy preset name (optional)
--audit-onlyfalseLog blocked requests but allow all traffic
--filter-onlyfalseFilter lists but don't block calls
--allow-static-resourcesfalseAllow resources from startup resources/list
--print-effective-allowlistfalsePrint derived allowlist and exit

What Gets Filtered/Blocked

MCP MethodEnforce Behavior
tools/listOnly show allowlisted tools
tools/callBlock calls to non-allowlisted tools
prompts/listOnly show allowlisted prompts
prompts/getBlock gets for non-allowlisted prompts
resources/templates/listOnly show allowlisted templates
resources/readBlock reads for non-allowlisted resources

Preflight Drift Check

Before bridging traffic, the proxy:

  1. Calls tools/list on the server.
  2. Compares against lockfile.
  3. If drift severity ≥ --fail-on, exits with error.

Advanced Features

Security & ID Translation

  • ID Translation: The proxy generates fresh IDs for every request; original host IDs are never forwarded to the untrusted server.
  • Anti-Spoofing: Responses with unknown or duplicate IDs are dropped silently.
  • Fail-Closed: If the internal tracking table is saturated, the proxy returns an OverloadedError and rejects new traffic rather than failing open.

Resource Limits

  • Message Size: NDJSON lines larger than 10MB are dropped to prevent buffer exhaustion.
  • OOM Protection: Strict memory limits are enforced on buffered messages.

Examples

# Enforce mode
mcptrust proxy --lock mcp-lock.json -- npx -y @scope/server
 
# Audit-only (for rollout testing)
mcptrust proxy --audit-only --lock mcp-lock.json -- npx -y @scope/server
 
# Strict drift threshold
mcptrust proxy --fail-on info --lock mcp-lock.json -- npx -y @scope/server