What gets written
The binary writes the gateway URL, the tier models, the employee’s sign-in, and gateway MCP servers on every run: for Claude Code into a lockedmanaged-settings.json, and for Claude Desktop, together with your preferences, into Desktop’s managed preferences. Only administrators can change them.
Claude Code applies managed settings above project and user settings, so employees cannot override the gateway, models, or policy:
Example: managed-settings.json for Claude Code
Example: managed-settings.json for Claude Code
With device login, the built-in baseline policy, the default models, and
mcp_servers = ["github"]. With OIDC, ANTHROPIC_CUSTOM_HEADERS is replaced by a top-level apiKeyHelper.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 mdm.toml template includes this policy, commented out:
For file-writing rules, use
Edit(...). Claude Code matches file permission checks only against Edit rules, which cover every file-editing tool, and ignores Write(...) rules.
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.
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.Restrict MCP servers to the gateway
Gateway MCP servers frommcp_servers 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 = "claude-code/claude-opus[1m]", for models that support it.
Add Claude Desktop
Add an[agents.claude-desktop] table. Desktop uses the Claude Code tier models unless you override them:
- MCP servers from
mcp_serversappear 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
toolSearchEnabled managed preference, a plain boolean) loads only tool names into each session and fetches a tool’s schema when Claude needs it, so many connectors no longer crowd the context window. It requires Desktop 1.21459.0 or later. This setting is the only switch: Desktop removes 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
claudeAiImport managed preference and adds the Import wizard under Settings → Import & export, so employees can bring claude.ai conversations and projects into Desktop. Imported sessions appear in Desktop’s Code tab. The isClaudeCodeForDesktopEnabled setting is unrelated to import. Replies in imported conversations come from your gateway models, and the transcript is replayed as context, so choose models with enough context.
- 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.
- Claude Desktop cannot use subscription passthrough.
Verify the deployment
After the lock check and test request on the pilot device:- 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 the models. In Claude Code,
/modelshould list your gateway models. - 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 Desktop and find it in AI Gateway → Request Logs.
Windows Subsystem for Linux
To configure Claude Code inside WSL, see Windows Subsystem for Linux in the overview.Data retention
FortranscriptRetentionDays and Anthropic-side retention, see Data retention in the overview.
Troubleshooting
For issues that affect every agent, see Troubleshooting in the overview.
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
- Codex with MDM: models, ChatGPT subscriptions, and Windows enforcement for Codex
- Configuration reference: every
mdm.tomlfield, CLI flag, and file path