Skip to main content
Use your Mobile Device Management (MDM) system to connect employees’ AI clients to the TrueFoundry AI Gateway. One administrator-controlled TOML file selects the clients, models, MCP servers, Skills, and authentication method for a rollout. This guide starts with manual PAT onboarding: scheduled MDM runs do not open a browser. Employees sign in once from a terminal, and later MDM runs reuse their Personal Access Token (PAT). OIDC and automatic device login are alternatives. The setup tool configures clients; it does not install the clients or the MDM scheduler. Some clients support protected machine settings, while others receive user settings that setup reapplies. See supported clients for the difference.

Before you start

You need:
  • Administrator deployment access through Jamf, Mosyle, Kandji, Intune, SCCM, or another system that runs scripts as root or Administrator/SYSTEM.
  • Your control-plane URL, tenant name, and gateway URL. The control-plane URL opens your TrueFoundry console; the gateway URL receives model requests. Copy the gateway base URL from your organization’s Playground code snippet, including any path such as /api/llm.
  • Gateway model IDs that employees can use. Configure model and MCP permissions through Access Control. For Codex, use a suitable Virtual Model with a bare OpenAI model slug, such as gpt-5.4; see Codex model configuration.
  • Permission for employees to create PATs for manual onboarding. If your tenant requires a team owner, decide whether to set auth.pat_team or let employees select a team during sign-in.
  • Optional MCP servers and Skills already registered in TrueFoundry. Use the exact registry names and grant employees access. See MCP servers and Skills Registry.
The examples pin tfy-local-ai-setup v2.2.0, which includes standalone --config, manual PAT onboarding, MCP discovery, and additional clients. Review the release notes before changing the pin.

How the rollout works

A successful first MDM run does not mean every client is ready. In manual PAT mode, credential-dependent configuration waits for employee sign-in. Claude Code, Codex, and Claude Desktop managed settings are completed by a subsequent privileged run. Pilot the entire sequence before deploying broadly.

Deploy your first configuration

1. Prepare the TOML file

Save the following as mdm.toml in your MDM deployment package. Replace the URLs, tenant, and model IDs. This example configures Claude Code, Codex, and OpenCode; add claude-desktop to tools on macOS/Windows if required.
mdm.toml
api-key selects per-user authentication; it does not ask you to embed an API key in this file. Keep tokens and client secrets out of the TOML. The example starts without MCP servers or Skills so you can verify model access first, then add them. The explicit tools list configures those clients even if they are not installed yet. Omit a client’s ID to leave it out of the rollout. For Linux, leave out Claude Desktop.

2. Prepare the Claude Code policy template

Save this as base-settings.json alongside mdm.toml in your deployment package. This starter policy requires approval before writes and pushes and denies reads of SSH files. Review it with your security team and adjust it for your organization.
base-settings.json
The wrappers explicitly select this template. This avoids inheriting an existing machine policy or the binary’s built-in sandbox proxy settings. Gateway, model, auth, and MCP values are merged by the binary. See advanced client controls for more policy options.

3. Deploy the files and setup tool

Use your MDM to deliver mdm.toml and base-settings.json to the administrator-controlled directory in the relevant tab. Make both files readable by users and writable only by administrators. Do the same for any parent directories created for the deployment. Run the corresponding script as root or Administrator/SYSTEM. These scripts expect both input files to have already been delivered; they download the pinned binary only when it is missing or the saved release pin differs.
Deliver both files to /Library/Application Support/TrueFoundry/. Save this script in your MDM and run it as root. It supports Apple Silicon and Intel Macs.
deploy-mdm.sh
Keep the binary at that stable, administrator-owned path. Clients and user-context setup may call it later to retrieve credentials. Schedule the wrapper hourly, and allow an administrator to trigger it on demand after onboarding or a policy change. The tool installs no scheduler itself.
After installing the binary and delivering the TOML, invoke the binary directly with --dry-run:
Manual mode previews the policy and work available without credentials; it does not simulate a completed employee sign-in. The deployment wrappers above install files and apply configuration. Adding a dry-run flag to the binary invocation does not undo the wrapper’s installation steps.

4. Ask employees to sign in

After the first privileged run has saved the organization policy, give employees the following instructions. Run in a normal terminal as the employee, without sudo or elevation:
Complete the browser sign-in. If the tenant requires a team and IT did not set auth.pat_team, select an available team when prompted. To specify one explicitly, append --pat-team=engineering. The server checks whether the employee can create a PAT for that team. The command reuses a valid managed PAT on subsequent runs. An expired or revoked PAT requires sign-in to create a replacement. A temporary network or verification error does not create another PAT; retry when connectivity returns. On completion, the command reports that user setup is complete and administrator-owned updates finish on the next MDM run. Trigger that run for your pilot, then open a new terminal and restart the configured clients. If no user is signed in, user-owned work waits until a user session is available.

5. Verify the connection

  1. Check the MDM log. Confirm the post-login run completed. Exit 0 indicates success or a clean no-op; exit 1 indicates an error. Pending manual onboarding can still produce a successful scheduled run, so check the full onboarding sequence.
  2. Send a model request in each selected client. Ask: Reply exactly TFY-CHAT-OK. Do not use tools. Confirm there is no authentication or model error.
  3. Confirm the route. Open AI Gateway → Request Logs in TrueFoundry and find the request under the expected user and model. A response alone does not prove it went through the gateway.
  4. Check optional MCP servers and Skills. Authorize MCP servers in each client, then try a harmless read operation. Check the client’s Skills list; Desktop Skills require manual upload.
For other clients, follow the app’s authorization prompts and the relevant integration guide. VS Code can require API key entry through its model UI. Clients that use shell environment variables should be launched from a new terminal that has loaded the updated environment.

Supported clients

Managed means setup writes administrator-owned machine configuration. User means setup writes the employee’s configuration and reconciles it on later runs; users can edit those files. Skills are per-user even for managed clients. The platform list describes the setup writers. Install a compatible client version separately. Windows examples target native clients; WSL requires separate deployment into the distribution.
Client compatibility matters. Claude Code’s additive managedMcpServers needs Claude Code 2.1.259+. Claude Desktop managed MCP connectors need Desktop 1.2581.0+. On Windows, Codex gateway enforcement through requirements.toml needs Codex 0.156.0+; the companion machine config.toml supplies defaults on older versions, which users can override.

TOML configuration reference

Pass this file through --config=/absolute/path/mdm.toml. It is separate from personal mode’s ~/.tf/config.toml and the generated agents-policy.json. TOML and JSON are supported; YAML is not supported by the full MDM loader. Unknown keys are rejected before authentication or configuration writes.

Connection and client selection

Authentication

Shared models, MCP servers, and Skills

For MCP and Skill overrides, omitted means inherit and empty means disable. Do not assume the same empty-list behavior for model lists; supply a nonempty model list for model-list clients.

Client model fields

Only set options supported by the specific client. Unsupported options fail validation.

Precedence and unsupported fields

Explicit command-line flags override corresponding TOML values. For example, --codex-default-model=gpt-5.4 changes Codex’s model for that run. Keep scheduled overrides in your deployment package so the next run does not revert them.
  • --mcp-server replaces only the shared MCP list; per-client lists remain. --no-mcp suppresses the shared list and preserves per-client overrides.
  • --no-skills removes MDM-installed Skills, including per-client selections.
  • --agent replaces the additional-client selection from the file; Claude Code, Codex, and Desktop retain their separate selection flags. Use --claude-desktop=false, for example, to deselect Desktop.
  • --agents-config is the older partial input mode. It cannot be combined with --config.
  • [[mcp.custom]] is not propagated through the MDM policy in v2.2.0. Register the server in the gateway and use its registry name instead.
  • [restrictions] is not accepted by the full MDM --config parser in v2.2.0. Use the prompt-blocking CLI flags.

Practical examples

The following snippets replace or extend the matching sections of the baseline TOML. Do not append a second copy of an existing table.

Give clients different MCP servers and Skills

Claude Code receives GitHub and the pinned code-review Skill. Codex receives GitHub and Linear, but no Skills. OpenCode inherits both shared lists. Replace the names with accessible entries in your registries. These settings configure MCP connections; employees still authorize them in each client.

Discover each employee’s accessible MCP servers

Replace the baseline [mcp] table with:
After sign-in, setup lists registry servers and checks USE_MCP_SERVER permission to build each user’s list. Discovery refreshes on scheduled runs without opening a browser; it does not initiate MCP OAuth consent. A per-client mcp_servers list still overrides discovery. Failed or incomplete discovery retains existing MCP configuration. A successful discovery with no accessible servers removes previously discovered entries. The gateway continues checking authorization on requests independently of client refresh. Restart clients that need it to pick up changes.

Add another model-list client

Add qwen-code to the top-level tools list, then add:
Qwen Code uses its own model list and default, while OpenCode keeps [defaults]. Both inherit the baseline API-key/manual login method. Choose gateway model IDs and a wire protocol supported by your actual models.

Other authentication methods

OIDC

Create a public native OIDC client on your TrueFoundry control plane. With a PAT whose owner can manage tenant settings, send:
Replace the origin for a self-hosted control plane. Copy data.id from the response as the client ID. Replace the baseline authentication table with:
Use the exact issuer from <issuer>/.well-known/openid-configuration. Omit login = "manual" and any API-key overrides when using this all-OIDC example. Do not instruct these employees to run login --mdm; that command is for manual PAT policy. Claude Code receives apiKeyHelper; Codex receives an auth command pointing to the installed binary. Their first runtime sign-in opens a browser; subsequent requests reuse cached tokens or refresh them. Desktop uses its own native session. v2.2.0 defaults Desktop to access_token with openid profile email offline_access scopes; TrueFoundry rejects an ID token as the gateway bearer token. MCP discovery and authenticated Skill downloads still require usable credentials. Complete sign-in before expecting those operations to succeed on scheduled runs. Primary clients can override auth independently; all selected additional clients must agree on a single auth mode.

Automatic device login

Keep mode = "api-key" and remove login = "manual". The privileged run authenticates in the logged-in employee’s context, first trying their saved device-login refresh token. It can open a browser if sign-in is needed. Hourly runs keep the generated credentials current. This flow uses ~/.tf/refresh-token and ~/.tf/access-token, separately from the manual PAT store and OIDC’s ~/.tf/oidc-* caches. The login --mdm command applies only to manual PAT policy.

Advanced client controls

These options are CLI flags, not additional TOML keys. Add them to the wrapper’s binary invocation as needed.

Apply a Claude Code settings template

Use --settings-file=/absolute/path/base-settings.json to select your organization’s permission and sandbox policy. The binary merges gateway, model, auth, and MCP settings into that template. With no explicit template it reuses an existing managed settings file, otherwise its built-in baseline applies. Review the baseline before rollout: it includes denied shell/network and sensitive-file operations, approval rules, managed-only permission/hook rules, 14-day transcript retention, and a sandbox configuration with proxy ports 8080/8081. Supply your own template when those proxy services or restrictions do not match your environment. The starter template above provides a complete example without a sandbox proxy. For Claude Code, gateway MCP entries are additive. To restrict other MCP servers, configure allowedMcpServers/deniedMcpServers in your template. Deploy the template under administrator ownership, alongside the TOML. Review any Anthropic server-managed policies with your Claude administrator because they can change the effective policy.

Block new prompts in a client

Run as root/Administrator, independently or alongside setup:
On Windows, use the installed .exe from an elevated PowerShell terminal and omit sudo. Hooks block prompt submission, not launching apps, manual editing, Cursor Tab completion, or other clients. Claude Code’s fail-closed hook requires 2.1.295+; Codex hooks can require trust review through /hooks. Restart the client or start a new session after a change. Native Windows hooks do not cover WSL clients.

Other CLI options

Desktop tool search and 1M-context tuning require wrapper-level customizations; they are not full-TOML fields. The starter wrappers above leave these client defaults unchanged. If you add managed plist keys outside the binary, apply them after every binary run: the binary rebuilds and locks the Desktop plist. Claude Code’s [1m] model suffix does not substitute for Desktop’s model capability entries. Test tuning with your Desktop version before rollout.

Operate the rollout

Update the administrator-controlled TOML through MDM, then trigger the wrapper or wait for its hourly schedule. Keep changes to the release pin, TOML, settings templates, and CLI flags in the same deployment package. Restart clients that read configuration only at launch.

Files and credentials

The organization policy contains configuration, never PAT values. Manual PAT credentials are stored in the employee’s OS credential store, scoped to control-plane URL and tenant separately from personal mode. When that store is unavailable, the owner-only fallback is ~/.tf/personal-mdm-<account-hash>-pat. API-key mode can write credentials into generated client configuration. Protect those files and avoid sharing their contents. User reconciliation state, including pending work, is in ~/.tf/mdm-user.json. Skill bundles are cached under ~/.tf/cache/skills/<tenant>/<version-id> and installed into each client’s Skills directory. Desktop ZIPs are staged under ~/.tf/skills/claude-desktop. For a safe policy inspection, check selected IDs without printing generated credentials:

Failure and removal behavior

  • Employee has not signed in: manual mode saves intent and leaves credential-dependent work pending. Ask the employee to run login --mdm, then trigger the privileged run.
  • Credential verification or discovery fails: existing credential-dependent/MCP settings are retained for retry. Read logs for pending work; a successful initial scheduled run is not proof of completed onboarding.
  • Discovery succeeds with an empty result: previously discovered MCP entries are removed. This differs from a failed discovery.
  • MCP or Skill selection changes: later reconciliation removes entries installed by this tool that are no longer selected. Pinned Skills stay at the chosen version; unpinned references can update on later runs. Cached bundles are reused, although registry metadata checks can still occur.
  • A client is removed from tools: tracked additional-client settings are cleaned up through reconciliation. Do not assume this removes the primary clients’ legacy managed files. To decommission Claude Code, Codex, or Desktop, stop scheduled reapplication and explicitly remove the protected files/registry policy through your MDM’s administrator workflow.
There is no single fleet-wide uninstall command in this guide. Personal-mode uninstall is not an MDM decommissioning workflow. Remove configured prompt restrictions with --unblock-agent before retiring the binary. Revoke PATs in TrueFoundry when access is no longer needed.

FAQ

The privileged setup has not saved a manual-onboarding policy yet. Deliver the TOML and run the MDM wrapper first. Also confirm the employee is using the administrator-installed binary rather than an older copy on PATH.
User sign-in cannot modify administrator-owned settings. Trigger the next privileged MDM run, check its log, and restart the client. Also verify the employee can access the selected gateway model. VS Code may require an additional API key action in its model UI.
With auth.login = "manual", scheduled runs do not open a browser and do not mint replacement PATs. They reuse the saved PAT. When it expires or is revoked, the employee runs login --mdm again. Automatic device login and OIDC have different refresh behavior.
It depends on the client’s channel and version. Protected managed settings enforce the controls the client supports. User-channel settings can be edited and are reapplied later. MCP deployment is not automatically an allowlist, and configuring a gateway does not itself block network access to other providers. Use the client’s policy controls and your organization’s network controls where needed.
No. Discovery selects accessible servers and deployment writes connection details. Employees still complete each client’s MCP authorization flow. Gateway permissions continue to apply independently.
The v2.2.0 MDM policy propagates gateway registry names. It does not propagate mcp.custom. Register supported remote servers in the gateway and reference their names. Local server controls are client-specific; Desktop local MCP can be disabled with its CLI flag.
A per-client mcp_servers or skills list replaces the shared list. An explicit empty list disables that selection. Remove the per-client field to inherit again, and check whether your wrapper passes overriding CLI flags.
Setup prepares upload-ready ZIP files under ~/.tf/skills/claude-desktop. Upload them through Desktop’s Skills UI. Other supported clients receive Skills in their own directories; deploying a new ZIP does not replace a previously uploaded Desktop Skill inside the app.
User-context work waits for an employee session. Credential-dependent managed writes may also remain pending. Run the pilot with an employee signed in, then verify the next scheduled run completes the remaining work. Do not treat device-level script success as proof that every user’s profile has been configured.
Personal setup recognizes clients listed in the organization policy and leaves their management to IT. Managed PAT credentials and applied user state are separate from personal-mode state. Use personal setup for clients outside the managed policy and review any client-native policy precedence.
Collect the setup release, OS and client versions, sanitized TOML, relevant MDM log errors, and the stage that failed: deployment, employee login, privileged refresh, model request, MCP authorization, or Skill installation. Do not include PATs, token-cache contents, or generated client files containing credentials.