You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
cleanup: remove guard CLI flags, auto-detect DIFC from policies (#1723)
## Summary
Remove unnecessary guard CLI flags and simplify DIFC configuration.
Guards are now auto-enabled when an allow-only policy is detected — no
explicit flags needed.
## Flags Removed
| Flag | Env Var | Reason |
|------|---------|--------|
| `--enable-guards` | `MCP_GATEWAY_ENABLE_GUARDS` | Auto-detected from
policies |
| `--enable-config-extensions` | `MCP_GATEWAY_CONFIG_EXTENSIONS` |
Extension fields always accepted |
| `--session-secrecy` | `MCP_GATEWAY_SESSION_SECRECY` | Session labels
set by guards |
| `--session-integrity` | `MCP_GATEWAY_SESSION_INTEGRITY` | Session
labels set by guards |
## How DIFC Auto-Detection Works
After guard registration in `NewUnified()`, the gateway checks:
1. Does any server have a non-noop guard registered?
2. Is there a global guard policy override (`--guard-policy-json`)?
3. Does any server have per-server `guard-policies` configured?
If any condition is true, DIFC is automatically enabled. Otherwise, all
servers get noop guards and DIFC remains disabled.
## Other Changes
- Remove `EnableDIFC` field from `config.Config` and `SessionConfig`
struct
- Add `HasNonNoopGuard()` to `guard.Registry` for auto-detection
- Add `hasServerGuardPolicies()` helper to detect per-server guard
policies
- `requireGuardPolicyIfGuardEnabled()` now warns and falls back to noop
instead of fatal error
- Restore JSON schema validation in `LoadFromStdin`: extension fields
(`guards`, per-server `guard`) are stripped from a copy before
validation so spec-compliance is maintained while still accepting
gateway-specific extensions; unsupported fields like `command` are
properly rejected
- Fix flaky integration tests (hardcoded ports → dynamic
`getFreePort(t)`)
- Update guard-policies docs to canonical `allow-only` format
- Remove all references to removed flags from scripts and docs
## Testing
- `make agent-finished` passes (format, build, lint, unit + integration
tests)
- 24 files changed
<!-- START COPILOT CODING AGENT TIPS -->
---
✨ Let Copilot coding agent [set things up for
you](https://github.com/github/gh-aw-mcpg/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot)
— coding agent works faster and does higher quality work when set up for
your repo.
cmd.Flags().StringVar(&difcSinkServerIDs, "guards-sink-server-ids", getDefaultDIFCSinkServerIDs(), "Comma-separated server IDs whose RPC JSONL logs should include agent secrecy/integrity tag snapshots")
0 commit comments