mdm.toml, that lists the agents, models, sign-in method, MCP servers, and Skills to deploy. A script that your MDM runs on a schedule runs the tfy-local-ai-setup binary, which applies that file on each device and keeps it applied.
This guide is for IT administrators. To connect agents on your own computer without MDM, see Set Up Your IDEs.
How it works
On each run, the binary:- Writes managed settings that employees cannot edit: the gateway URL, models, sign-in, MCP servers, and policy for each agent. It locks the Claude Code, Codex, and Claude Desktop files, its own policy file (
agents-policy.json), Cursor hooks, and other agents’ managed settings (chflags schgon macOS,chattr +ion Linux, an admin-only ACL on Windows). - Writes user settings for agents that have no managed settings, installs Skills in each agent’s Skills folder, and adds a shell block for agents that read the gateway from environment variables. Employees can edit these files; the next run reapplies them. The first time the binary edits an existing user file, it keeps the original as a
.bakcopy. For every path, see Files written. - Signs the employee in and refreshes their credential, so no shared API key is ever distributed.
Supported agents
Managed settings are machine-wide and locked; employees cannot edit them. User settings are in the employee’s home directory; employees can edit them, and the next run reapplies them. Skills are always per-user.--wsl. For each agent’s extra options, see the configuration reference.
Before you start
- An MDM that runs scripts as root on macOS/Linux or as Administrator/SYSTEM on Windows, on a schedule. Jamf, Kandji, Mosyle, Intune, SCCM, Group Policy, and configuration tools such as Ansible, Chef, or Puppet all work.
- Your connection details: the TrueFoundry control-plane URL (the address of your TrueFoundry console), your tenant name, and the gateway base URL. Copy the gateway URL, including any
/api/llmpath, from a Playground code snippet. - Gateway models that employees can access. Claude Code needs Opus, Sonnet, and Haiku tier models. Codex needs a Virtual Model with a bare OpenAI model slug, such as
gpt-5.4. - Identity controls in your vendors’ consoles. Enforce SSO in Claude and in OpenAI so employees cannot fall back to personal accounts.
- The agents, installed separately. You can deploy the configuration before or after installing them.
Choose how employees sign in
Every employee signs in with their own TrueFoundry identity. Choose one method for your rollout:Set up OIDC sign-in
Skip this section if you use device login. With OIDC, no credential is written into the agents’ configuration. Claude Code and Codex ask the installedtfy-local-ai-setup binary for a token when they need one, and Claude Desktop signs in itself. One public OIDC client, with no client secret, serves all three agents. Other agents, such as OpenCode or Gemini CLI, and Cursor monitoring do not ask for tokens on demand; the first MDM run signs the employee in for them, as described in What employees see.
interactive and inferenceGatewayOidc pair, which the binary removes on its next run. The issuer, client ID, scopes, and token type stay the same.Create the OIDC client
Create a Personal Access Token
Create the client
/api/svc/v1/oidc/clients.- Redirect URIs: Claude Desktop uses
http://127.0.0.1/callback. The binary, which signs in for Claude Code and Codex, listens on port 8585, or on 8586 or 8587 if that port is busy. refresh_token_ttlsets how long an employee stays signed in without using an agent. Withrefresh_token_max_uses: 1, each refresh issues a new refresh token.
Copy the client ID
{ "data": { "id": "cli_...", "manifest": { ... } } }. data.id is the client ID.Sending the request again with the same manifest.name updates the client and keeps its ID. client_type cannot be changed after creation.Find the issuer
/<tenant>, for example https://<tenant_name>.truefoundry.cloud/<tenant_name>. Open <issuer>/.well-known/openid-configuration and copy its issuer value exactly.Add OIDC to mdm.toml
mdm.toml, replace its [auth] table:mode = "api-key" and set auth = "oidc" in the [agents.claude-code], [agents.codex], or [agents.claude-desktop] table. All additional agents must use the same mode.What employees see
- MDM runs write the configuration for Claude Code, Codex, and Claude Desktop without opening a browser. If you also deploy additional agents, such as OpenCode or Gemini CLI, or Cursor monitoring, the first MDM run signs the employee in once through the browser.
- Claude Code and Codex open a browser sign-in the first time they need a token. Later requests reuse the cached access token, or refresh it silently, without a browser.
- Claude Desktop asks the employee to sign in on first launch and keeps its own session.
- When the refresh token expires, after
refresh_token_ttlwithout use, the next request opens the browser again.
What OIDC writes
- Claude Code:
apiKeyHelperinmanaged-settings.jsonrunstfy-local-ai-setup --_print-oidc-token. - Codex:
[model_providers.truefoundry.auth]has acommandthat runs the binary with--_print-oidc-token. - Claude Desktop:
inferenceCredentialKind=external-idpandinferenceIdpOidc={"bearerTokenType":"access_token","clientId":"<client-id>","issuer":"<issuer>","scopes":"openid profile email offline_access"}.
~/.tf/oidc-* files, separate from device login’s ~/.tf/refresh-token. For each agent’s file paths, see What gets written for Claude Code and Claude Desktop and for Codex.
Keep the Claude Desktop defaults:
bearerTokenTypemust beaccess_token. The gateway validates access tokens and rejects ID tokens, which are Desktop’s default.- Keep
openidin the scopes, or Desktop’s sign-in fails. Desktop still sends the access token to the gateway.
--oidc-bearer-token-type and --oidc-scopes change these values; leave them at their defaults for TrueFoundry.
Limitations
- Codex’s ChatGPT subscription mode needs device login. Claude Code with a Claude Enterprise or Team subscription is also set up with device login.
mcp_servers = ["@all"]uses the employee’s cached OIDC sign-in. Until the employee has signed in once, runs with it fail without writing any configuration, so Claude Code never receives its sign-in command. Roll out with a fixedmcp_serverslist first.
Deploy to a pilot device
Test on one device per operating system, with an employee who is logged in and available to complete a browser sign-in.Write mdm.toml
#. To use a setting under a commented [table] line, uncomment that table line too. An agent is deployed only when its [agents.<id>] table is present.- Replace
control_plane_url,tenant_name, andgateway_urlwith your connection details. - Replace the model IDs with gateway models your employees can access.
- Keep a table only for each agent you deploy. Claude Code, Codex, Claude Desktop, and agents with managed settings are configured even before they are installed.
- Optional: uncomment the Claude Code policy to set your own. Without it, the binary keeps the policy in an existing
managed-settings.json, or applies a built-in baseline. See Set the Claude Code policy.
url, tenant, and tools, still work; see Older file layout.Create the deployment script
tfy-local-ai-setup release, checks it against the release’s checksums, and stops if they are missing or do not match. It then writes your mdm.toml and runs the binary. Copy the script for your platform and paste your mdm.toml into the Configuration section at the top.- macOS
- Linux
- Windows
RELEASE_TAG the same across your rollout. To upgrade, change it and redeploy the script.Run it through your MDM
0, and neither the script’s output nor the log file (/var/log/tfy-mdm-setup.log, or C:\Program Files\TrueFoundry\mdm-setup.log) shows errors. Some errors appear only in the script’s output, so always check the exit code. If sign-in failed or timed out, run the script again when the employee is available. See Exit codes.Preview before applying
Preview before applying
sudo DRY_RUN=true ./deploy-mdm.sh. On Windows, set $DryRun = $true in the script. The preview prints each agent’s changes without writing them.A dry run still signs the employee in when needed, and its output can include their live credential. Do not share it.Check that the settings are locked
- macOS
- Linux
- Windows
Send a test request
Roll out to your fleet
- Widen gradually. After the pilot passes on each operating system, deploy to a small group, then to everyone.
- Schedule the script to run regularly, plus on demand. Each run refreshes device-login credentials and reapplies settings that employees changed, so run it often enough to refresh credentials before they expire; hourly is a common choice. On Intune, platform scripts run only once, so use Remediations or a scheduled task.
- Tell employees what to expect: a one-time browser sign-in, restarting their agents after the first run, and authorizing MCP servers inside each agent.
- Install agents in any order. Claude Code, Codex, Claude Desktop, and agents with managed settings are configured before installation. Agents configured through user settings are configured on the first run after they are installed.
Windows Subsystem for Linux
Claude Code and Codex running inside WSL read the distribution’s own/etc/claude-code and /etc/codex, not the Windows configuration. Add --wsl to the binary’s command in your script to also configure Claude Code and Codex in the employee’s WSL distributions.
- It is off by default because reaching a stopped distribution starts it.
- Running distributions are updated on every run; stopped ones at most once a day, so they can be up to 24 hours behind.
- Container distributions, such as
docker-desktop,rancher-desktop, andpodman-machine-*, are skipped. - Inside WSL this routes traffic but does not enforce it: anyone who can run
wsl.exeis root in the distribution. - WSL does not inherit Windows VPN or proxy routes, so check that the gateway is reachable from inside.
- Prompt blocks from native Windows hooks do not cover WSL.
wsl.exe -d Ubuntu cat /etc/claude-code/managed-settings.json for Claude Code, or wsl.exe -d Ubuntu cat /etc/codex/managed_config.toml for Codex.
Exit codes
The script exits with the binary’s exit code, so your MDM can report failures:0: configuration applied.1: the run failed. Check the script’s output and the log file; the next run retries. Configuration already written stays in place if the run failed after some agents were configured.2: invalid command-line flags or arguments. Check the binary’s command in your script.3: configuration applied, but a Skill inmdm.tomldoes not exist. Fix the Skill reference.
Customize your rollout
The settings you are likely to need are already in yourmdm.toml, commented out, and the rest are in the configuration reference. Uncomment what you need in the script’s TOML block and redeploy it. The settings below need more than one line of explanation. For agent-specific options, see:
Claude Code and Claude Desktop
Codex
Add MCP servers and Skills
Register the resources in TrueFoundry and grant employees access first. Then set the top-levelmcp_servers and skills lists in mdm.toml. Each takes one of three values:
- Every agent gets the shared lists. Set an agent’s own
mcp_serversorskillsto a list to replace them for that agent, or[]to deploy nothing to it.["@all"]is accepted only in the shared lists. - Pin a Skill version, as in
:1, for a fixed rollout, or omit it to follow the latest version. Some agents also read other agents’ Skill folders, so an empty list does not guarantee a Skill is hidden in that agent. - Deployed MCP servers are added alongside servers the employee added. To block other servers, see restrict Claude Code to gateway MCP servers and Codex MCP allowlists.
["@all"], a failed lookup keeps the existing configuration and retries on the next run. A successful lookup that finds nothing removes the resources it deployed earlier.
Monitor Cursor activity
[monitoring.cursor] enabled, the binary installs managed Cursor hooks that send prompts, agent responses, tool and MCP events, and session events to <gateway>/hooks/cursor with the employee’s credential. These events can contain prompt and tool content. Monitoring does not change Cursor’s model routing.
require_login = trueblocks agent prompts and tool and MCP calls when no credential is available. Delivery failures and gateway verdicts never block.- To remove the hooks, set
enabled = falseor delete the table, and run the script again. - For monitoring only,
mdm.tomlstill needs at least one agent table. Add[agents.cursor]withmcp_servers = []andskills = [], so nothing else is deployed to Cursor. Without those two lines, Cursor also gets the shared MCP servers and Skills.
Block an agent
Supported for Claude Code, Codex, and Cursor. List the agents in[restrictions] blocked_agents to stop employees from submitting prompts in them.
messageis what employees see when a prompt is blocked. If unset, they see “Your organization has disabled this application. Please use an approved alternative or contact your administrator.”- To remove every block, set
blocked_agents = []. If you delete the[restrictions]table instead, the blocks from the last run stay in place. - It blocks new prompts, not launching the app, manual editing, or Cursor Tab completions. Claude Code needs version 2.1.295 or later, and Codex may ask employees to trust the hook in
/hooks.
Monitor usage
Once agents route through the gateway, every model request and MCP tool call is logged with the employee, model, server, and tool, with no extra instrumentation.- Requests and metrics: see Request logging and Analytics for models, MCP servers, and guardrails.
- Your SIEM: export traces over OpenTelemetry to platforms such as Grafana, Datadog, or Splunk.
- Spending: set budget limits and rate limits per employee and team.
Data retention
The gateway controls what is logged and where it goes, including request logging and audit, independent of any setting on the device. Local transcripts and retention on the providers’ side are set separately:- Claude:
transcriptRetentionDaysin 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. - OpenAI: retention of prompts and outputs is governed by your agreement with OpenAI, and differs between API usage and ChatGPT subscription plans. See OpenAI’s managed configuration documentation for the admin controls on your plan.
Update a rollout
Edit the TOML block orRELEASE_TAG in your script and redeploy it. The next run applies the change; restart agents that read settings at launch. Each run makes the device match mdm.toml, so preview larger changes with a dry run on a pilot device first. MCP servers and Skills that are no longer selected are removed, while entries employees added themselves are kept.
Troubleshooting
~/.tf, dry-run output, or generated agent settings, which can contain credentials.
FAQ
Will employees need to sign in on every scheduled run?
Will employees need to sign in on every scheduled run?
An employee closed the browser sign-in window. What now?
An employee closed the browser sign-in window. What now?
Does deploying an MCP server sign the employee in to it?
Does deploying an MCP server sign the employee in to it?
/mcp in Claude Code or codex mcp login <server-name>.Can employees change the configuration or use other providers?
Can employees change the configuration or use other providers?
What happens if nobody is logged in?
What happens if nobody is logged in?
1, and the next scheduled run retries once an employee is logged in.Can employees also use personal setup?
Can employees also use personal setup?
Reference
Configuration reference
mdm.toml field, CLI flag, version requirement, and file path.