Article

Set file and network limits for Codex MCP servers

For teams adding local Codex tools, set separate file and network permissions, prepare offline dependencies and check platform-specific limits.

Editorial illustration for Set file and network limits for Codex MCP servers: code brackets represent developer tools. Not documentary evidence.

Codex’s command permissions do not automatically constrain a local MCP tool server. Developers and IT teams can give that server its own file and network limits by launching it through codex sandbox with a separate permission profile. OpenAI documents this setup in its November 18, 2026 sandbox explanation; that dates the explanation, not a new feature launch.

Check that the server runs locally

Model Context Protocol (MCP) connects an assistant to tools. This guide covers stdio servers: programs started locally and connected through their input and output streams. In Codex’s MCP configuration, command and args specify that launch; url specifies an HTTP connection instead. A local wrapper does not configure the remote service’s sandbox.

Inspect your existing ~/.codex/config.toml and preserve unrelated settings. Confirm that the client can find the Codex executable. If the server selects another execution environment, establish where it actually runs before applying a workstation recipe.

List the runtime files it must read, directories it must modify and services it must contact. Keep three decisions separate: whether the integration may load, what its process may access, and which tool actions you permit.

Prepare dependencies before turning off networking

The following templates adapt OpenAI’s memory-server example. Replace REVIEWED_VERSION with a specific package release your team has reviewed, consistently in both templates. Replace /ABSOLUTE/PATH/TO/mcp-data everywhere with your chosen absolute directory. These placeholders are not runnable defaults.

Create that directory and populate the npm cache before the offline launch. This Bash preparation step downloads dependencies; the later server profile does not protect it retroactively. Review it as a separate installation step.

mkdir -p /ABSOLUTE/PATH/TO/mcp-data
npx -y --package=@modelcontextprotocol/server-memory@REVIEWED_VERSION -c true

The configuration below uses ~/.npm as the cache directory, following the example. Substitute your actual npm cache location. Windows installations also need appropriate paths and executable resolution.

Give the server its own permission profile

Permission profiles are still beta. They do not compose with legacy sandbox_mode and sandbox_workspace_write settings. A loaded sandbox_mode or --sandbox can override default_permissions; managed profile requirements are an exception. Review the loaded configuration rather than assuming the chat’s permission label describes the server.

Merge this TOML template into the appropriate configuration, replacing an existing memory-server entry rather than duplicating it. It selects memory-mcp for this launch without making it the coding session’s default:

[permissions.memory-mcp.filesystem]
":root" = "read"
"~/.npm" = "write"
"/ABSOLUTE/PATH/TO/mcp-data" = "write"

[permissions.memory-mcp.network]
enabled = false

[mcp_servers.memory]
command = "codex"
args = [
  "sandbox",
  "--permission-profile",
  "memory-mcp",
  "--",
  "npx",
  "--offline",
  "@modelcontextprotocol/server-memory@REVIEWED_VERSION"
]

[mcp_servers.memory.env]
MEMORY_FILE_PATH = "/ABSOLUTE/PATH/TO/mcp-data/memory.jsonl"

The launcher is now Codex; the original server command follows --. The CLI reference documents --permission-profile in the singular. It is different from --profile, which selects a configuration-profile file. Confirm your installed CLI’s help before using the template; a universal minimum version for this complete recipe is not established here.

Understand what the profile leaves accessible

The ":root" = "read" rule deliberately retains broad reads, subject to operating-system permissions. Writes are limited to the specified cache and data locations, and networking is disabled. This is not a rule allowing reads only inside the data directory. The filesystem permission definitions distinguish those grants.

The practical implication is that an offline tool server is not an offline assistant. The server can still return readable information as a tool result. Codex’s model connection, hosted search and connectors have separate network controls. If confidentiality is the goal, review readable paths and tool outputs as well as direct connections.

For a server that genuinely needs an API, define an online profile with only the necessary destinations. Domain filtering requires an active proxy: network.enabled = true alone is insufficient. Enable features.network_proxy or the administrator-managed equivalent. An allowed destination is not a restriction on which records or actions a service permits.

Hosted integrations therefore still need their own access review. Our guide to what Apify can access through a Notion connector illustrates that separate permissions question; the local wrapper does not replace service authorization.

Check the operating system and managed policy

Codex uses different enforcement mechanisms by platform: Seatbelt on macOS, and bubblewrap plus seccomp on Linux and WSL2. A Linux host or container can block the operations the sandbox needs. Native Windows has MXC and legacy alternatives; the same configuration text is not evidence of identical enforcement everywhere.

The Windows compatibility documentation says the legacy unelevated sandbox has weaker network isolation and cannot enforce denied read paths. MXC managed networking requires allow_local_binding = true and permits host-loopback connections—connections to services on the same computer. Review those limits before adopting a policy that assumes they are blocked.

For wider deployment context, see our explanation of Microsoft Execution Container boundaries. Use the current Codex compatibility documentation for the actual client setup.

On managed devices, include --include-managed-config alongside --permission-profile when resolving the wrapper’s policy, as described in the sandbox command reference. Have the administrator review the wrapped invocation, not just the launcher name. Managed profile allowlists require Codex 0.138.0 or later; that is a policy-mechanism requirement, not the minimum version of every step above.

Check a live tool call and the intended denials

Restart the affected server so its revised launch takes effect. Inspect /mcp and make a harmless real tool call. Codex can show a cached tool catalogue, so a listed tool or successful session start does not by itself establish a live connection.

Use disposable data for these acceptance checks; they are checks to perform, not reported test results:

  • Record the CLI version, operating system, sandbox implementation, loaded configuration, selected profile and server command without credentials.

  • Under the same profile, confirm a write succeeds in the intended data directory and is refused in a directory without write permission.

  • If you narrowed read access, check a synthetic denied file. Do not use private documents or credentials as probes.

  • For the offline profile, check that a benign outbound request is refused. For an online profile, check both a permitted destination and one outside the allowlist.

  • Confirm the actual MCP operation still works after restart. A working tool and a blocked resource access are separate results.

If you add deny-read wildcard rules, consider process lifetime. On Linux, WSL and Windows MXC/elevated, matches are collected when each sandboxed process starts; later-created matching files may remain readable. A new chat does not prove that a reused server process restarted.

If startup fails, inspect the cache, paths, runtime dependencies and platform or managed-policy requirements. Set the affected server’s enabled = false while troubleshooting if necessary; that preserves its configuration. Keep the integration disabled until both its useful operation and the intended access limits work on the target machine.