Skip to main content

Configuration Reference

ThoughtGate is configured via a YAML configuration file and environment variables.

Configuration File​

HTTP sidecar (Kubernetes): Set the path via THOUGHTGATE_CONFIG environment variable:

export THOUGHTGATE_CONFIG=/etc/thoughtgate/config.yaml

CLI wrapper (local development): Pass the path via --thoughtgate-config flag (defaults to thoughtgate.yaml in the working directory):

thoughtgate wrap --thoughtgate-config /path/to/config.yaml -- claude-code
note

THOUGHTGATE_CONFIG is only used in HTTP sidecar mode. The CLI wrapper uses --thoughtgate-config instead.

Minimal Configuration​

schema: 1

sources:
- id: upstream
kind: mcp
url: http://mcp-server:3000

governance:
defaults:
action: forward

Full Configuration​

schema: 1

sources:
- id: upstream
kind: mcp
url: http://mcp-server:3000
prefix: null # Optional prefix for tool names
expose:
mode: all # all | allowlist | blocklist

governance:
defaults:
action: forward # forward | approve | deny | policy
rules:
- match: "delete_*"
action: approve
approval: slack-ops # References approval section
- match: "admin_*"
action: deny
- match: "sensitive_*"
action: policy
policy_id: sensitive-tools # References Cedar policy

approval:
slack-ops:
adapter: slack
channel: "#approvals"
timeout: 5m

cedar:
policy_path: /etc/thoughtgate/policies.cedar

Environment Variables​

Core​

VariableRequiredDefaultDescription
THOUGHTGATE_CONFIGSidecar only—Path to YAML configuration file (sidecar mode)
THOUGHTGATE_OUTBOUND_PORTNo7467Port for proxy traffic (sidecar mode)
THOUGHTGATE_ADMIN_PORTNo7469Port for health/metrics endpoints (sidecar mode)
THOUGHTGATE_ENVIRONMENTNoproductionDeployment environment label (for telemetry)

Slack & Approvals​

VariableRequiredDefaultDescription
THOUGHTGATE_SLACK_BOT_TOKENFor approvals—Slack Bot OAuth token (xoxb-...)
THOUGHTGATE_SLACK_CHANNELNo#approvalsDefault channel for approval messages
THOUGHTGATE_APPROVAL_TIMEOUT_SECSNo300Default approval timeout in seconds
THOUGHTGATE_REQUEST_TIMEOUT_SECSNo300Default upstream request timeout in seconds
THOUGHTGATE_MAX_BATCH_SIZENo100Maximum Slack batch polling size

Telemetry​

VariableRequiredDefaultDescription
THOUGHTGATE_TELEMETRY_ENABLEDNofalseEnable OTLP trace export
OTEL_EXPORTER_OTLP_ENDPOINTNo—OTLP HTTP endpoint (only http/protobuf supported)
OTEL_SERVICE_NAMENothoughtgateService name for OTLP resource

See Telemetry Reference for the full telemetry configuration.

Port Model​

HTTP Sidecar​

ThoughtGate uses an Envoy-inspired 3-port architecture:

PortNamePurpose
7467OutboundClient requests → upstream (main proxy)
7468InboundReserved for webhooks
7469AdminHealth checks, metrics

CLI Wrapper​

In CLI wrapper mode, the governance service binds to an OS-assigned ephemeral port on 127.0.0.1. You can override this with --governance-port:

thoughtgate wrap --governance-port 9090 -- claude-code

Governance Actions​

ActionBehavior
forwardSend to upstream immediately
denyReturn error immediately
approveCreate SEP-1686 task, post to Slack, wait for approval
policyEvaluate Cedar policy, then forward/approve/deny

Rule Matching​

Rules are evaluated in order. First match wins.

governance:
rules:
# Most specific rules first
- match: "admin_delete_*"
action: deny
# Then broader patterns
- match: "admin_*"
action: approve
# Catch-all last (or use defaults)
- match: "*"
action: forward

Patterns use glob syntax:

  • * matches any characters
  • ? matches single character
  • [abc] matches character class

Exposure Configuration​

Control which tools are visible to agents:

sources:
- id: upstream
kind: mcp
url: http://mcp-server:3000
expose:
mode: allowlist
tools:
- "get_*"
- "list_*"
- "search"
ModeBehavior
allAll tools visible (default)
allowlistOnly listed patterns visible
blocklistAll except listed patterns visible

Admin Endpoints​

Available on admin port (default 7469):

EndpointMethodDescription
/healthGETLiveness check (returns 200 if running)
/readyGETReadiness check (returns 200 if ready for traffic)
/metricsGETPrometheus metrics

Prometheus Metrics​

Key metrics (see Telemetry Reference for the complete inventory):

thoughtgate_requests_total{method, tool_name, status}
thoughtgate_request_duration_ms{method, tool_name}
thoughtgate_approval_requests_total{channel, outcome}
thoughtgate_tasks_pending{task_type}
thoughtgate_upstream_requests_total{target, status_code}
thoughtgate_gate_decisions_total{gate, outcome}

Example Configurations​

Passthrough Mode (Logging Only)​

schema: 1
sources:
- id: upstream
kind: mcp
url: http://mcp-server:3000
governance:
defaults:
action: forward

Strict Mode (Approve Everything)​

schema: 1
sources:
- id: upstream
kind: mcp
url: http://mcp-server:3000
governance:
defaults:
action: approve
approval:
default:
adapter: slack
channel: "#all-approvals"
timeout: 10m

Production Mode (Tiered)​

schema: 1
sources:
- id: upstream
kind: mcp
url: http://mcp-server:3000
expose:
mode: blocklist
tools:
- "internal_*"
- "debug_*"
governance:
defaults:
action: forward
rules:
- match: "delete_*"
action: approve
approval: destructive
- match: "drop_*"
action: approve
approval: destructive
- match: "admin_*"
action: deny
- match: "transfer_*"
action: approve
approval: financial
approval:
destructive:
adapter: slack
channel: "#ops-approvals"
timeout: 5m
financial:
adapter: slack
channel: "#finance-approvals"
timeout: 10m