What gets written
Claude Code applies managed settings above project and user settings, so employees cannot override the gateway, models, or policy:
Policies in Claude’s Admin Console (Settings → Policies) do not reach sessions routed through a gateway. Put your Claude Code policy in
mdm.toml instead.Set the Claude Code policy
[agents.claude-code.managed_settings] takes any key from Claude Code’s settings reference, including nested permissions, env, sandbox, and MCP policy keys. The starter in the overview uses this policy:
Do not set
ANTHROPIC_BASE_URL, the model variables, or credentials here. The binary adds them after loading your policy.
To keep the policy in a JSON file instead, pass --settings-file=/path/to/policy.json to the binary. Precedence is --settings-file, then the inline table, then the existing managed file, then the baseline. If the --settings-file path cannot be read, the binary silently uses the baseline, so check the path on a pilot device.
Restrict MCP servers to the gateway
Gateway MCP servers from[mcp] are added to managedMcpServers in managed-settings.json, alongside servers employees add themselves. This requires Claude Code 2.1.259 or later.
To allow only servers behind your gateway, add an allowlist to the policy:
Earlier MDM scripts wrote an exclusive
managed-mcp.json that blocked every other server. This setup does not, so add allowedMcpServers if you relied on that behavior.Choose models
Claude Code uses three tiers. The defaults are:- Use Virtual Models so you can change routing or add fallbacks in TrueFoundry without redeploying the script. See Virtual Models.
- To request 1M context in Claude Code, add the
[1m]suffix, for exampleopus_model = "claude-code/claude-opus[1m]", for models that support it.
Add Claude Desktop
Addclaude-desktop to tools. Desktop uses the Claude Code tier models unless you override them:
- MCP servers from
[mcp]appear under Customize → Connectors, where each employee selects Connect to authorize them. This requires Desktop 1.2581.0 or later. To allow only remote servers, pass--claude-desktop-allow-local-mcp=falseto the binary, which blocks employees’ local (stdio) servers. - Skills are staged as ZIP files in
~/.tf/skills/claude-desktop. Employees upload them through Desktop’s Skills settings with code execution enabled. A newly staged ZIP does not update a Skill that was already uploaded. - Restrict sign-in with binary flags:
--force-login-org=<Claude org UUID>(repeatable) limits sign-in to your Claude organizations, and with OIDC,--disable-deployment-mode-chooserstops employees from leaving the gateway profile for a personal Claude.ai account. - Inference headers are added with the repeatable
--desktop-header='Name: Value'flag. Aheaderskey in TOML fails validation.
Turn on tool search and 1M context
ENABLE_TOOL_SEARCH from sessions when it is unset, so employees cannot turn it on themselves.
1M context: set supports_1m and prefer_1m only for tiers whose gateway models support 1M context. Desktop uses these settings rather than Claude Code’s [1m] suffix.
Let employees import claude.ai history
- Requires Desktop 1.10628.0 or later.
- For Team or Enterprise workspaces, a workspace owner must also turn on Allow members to export their own data in claude.ai.
- The Sign in to claude.ai path needs network access to claude.ai. Importing a downloaded
.zipfile does not. - Terminal Claude Code history is not imported.
- If import stays unavailable on macOS, try
encoding = "native-dict".
export_enabled (default true) shows Export, banner_behavior ("detect", "show", or "off") controls the import prompt, and automatic_3p (beta, default false) imports earlier third-party sessions without asking. Turn on automatic_3p only with your organization’s agreement, because employees are never prompted. It also requires deploymentOrganizationUuid in Desktop’s managed preferences, which this tool does not set. See Anthropic’s import documentation.
Use a Claude Enterprise or Team subscription
To bill Claude Code usage to employees’ Claude seats instead of an API key, create the Anthropic model account with an empty API key, as described in Subscription passthrough. Then point the tiers at that account’s models:X-TFY-API-KEY, and each employee runs /login in Claude Code once and chooses their Claude account, so the two sign-ins are independent.
- A Virtual Model can have only one empty-key Anthropic target.
- If the account has an API key, the gateway uses it and bills the key instead of the seat.
- For a
401or403: if the Claude session expired, the employee runs/loginagain; if the TrueFoundry sign-in expired, trigger the MDM script again.
Verify the deployment
- Check the managed files are locked. See Check that the settings are locked.
- Check sign-in in
managed-settings.json. With device login, look forX-TFY-API-KEYinANTHROPIC_CUSTOM_HEADERSand noapiKeyHelper. With OIDC, look forapiKeyHelpercontaining--_print-oidc-tokenand no token. - Check Claude Desktop’s preferences. With OIDC, look for
inferenceCredentialKindset toexternal-idpandinferenceIdpOidcwith"bearerTokenType":"access_token". With device login, look forinferenceGatewayApiKey. - Send a test request from Claude Code and Claude Desktop, then find both in AI Gateway → Request Logs. In Claude Code,
/modelshould list your gateway models.
Windows Subsystem for Linux
Claude Code inside WSL reads the distribution’s own/etc/claude-code, not the Windows configuration. Add --wsl to the binary’s command to also configure the employee’s WSL distributions. See the WSL caveats, which apply to both agents. Verify with wsl.exe -d Ubuntu cat /etc/claude-code/managed-settings.json.
Data retention
transcriptRetentionDays in the Claude Code policy deletes local transcripts; 7 to 14 days is a common choice. Anthropic-side retention, Zero Data Retention, and compliance are configured with Anthropic; see Claude’s data retention documentation.
Troubleshooting
Related
- Claude Code integration: authentication modes, model configuration, and beta features
- Claude Desktop integration: third-party inference mode and managed preference keys
- Govern Claude’s MCP traffic: MCP allowlists, Claude.ai connectors, and web search
- Configuration reference: every
mdm.tomlfield