Guard Codex coding agents so they do not install risky or hallucinated packages.
In ~/.codex/config.toml:
[mcp.servers.pkgsafe]
command = "pkgsafe"
args = ["mcp", "serve"]Or via CLI (syntax may vary by Codex version):
codex mcp add pkgsafe --command "pkgsafe" --args "mcp" --args "serve"pkgsafe must be on PATH.
Use the live tools/list schema. Common safety tools:
| Tool | Purpose |
|---|---|
validate_package_install / check_package |
Package allow/warn/block |
validate_install_command / check_install_command |
Guard install command lines |
review_dependency_diff |
Review manifest/lockfile changes |
explain_package_risk / explain_policy_decision |
Explain decisions |
suggest_safe_alternative |
Fix bad or invented names |
Do not expose broad shell or unrestricted install tools to the agent.
- Validate before install.
- BLOCK → never install.
- WARN → ask a human.
- ALLOW → proceed under policy.