codex-project
A reference page for the codex-project resource
The codex-project resource manages per-project Codex configuration. It writes a project-scoped AGENTS.md, settings, and MCP servers under a specific directory — leaving global configuration untouched. Use it alongside the codex resource, which handles installation.
Parameters
-
directory: (string, required) Path to the project directory. Configuration files are written relative to this path:
<directory>/AGENTS.md<directory>/.codex/config.toml
-
agentsMd: (string, optional) Content for
<directory>/AGENTS.md. Accepts inline text, anhttps://URL, or acodify://documentId:fileIdcloud URL. Codex walks from the project root down to the current working directory and concatenates anyAGENTS.mdfiles it finds, using them as project-specific instructions. -
config: (object, optional) Key-value pairs to merge into
<directory>/.codex/config.toml. On apply, the declared keys are written; on destroy, only the declared keys are removed. Supports the same keys as the global config, e.g.model,approval_policy,sandbox_mode,sandbox_workspace_write.- Note: Codex ignores
model_provider,openai_base_url,notify,otel, andprofilesin project-level config files for security reasons.
- Note: Codex ignores
-
mcpServers: (array, optional) MCP servers to register for this project under
[mcp_servers]in<directory>/.codex/config.toml. Each entry requires anameandtype, plus transport-specific fields:- stdio:
{ name, type: "stdio", command, args?, env?, envVars?, cwd?, startupTimeoutSec?, toolTimeoutSec? }— local process server - http:
{ name, type: "http", url, bearerTokenEnvVar?, httpHeaders? }— remote streamable-HTTP server
- stdio:
Example usage
Per-project AGENTS.md and sandbox policy
[
{
"type": "codex-project",
"directory": "~/projects/my-api",
"agentsMd": "# Project Instructions\n\nThis is a Node.js API. Always use async/await.\nRun `npm test` before committing.",
"config": {
"sandbox_mode": "workspace-write",
"approval_policy": "on-request"
}
}
]Per-project AGENTS.md with an MCP server
[
{
"type": "codex-project",
"directory": "~/projects/my-api",
"agentsMd": "# Project Instructions\n\nAlways check types with `npm run typecheck` before submitting.",
"mcpServers": [
{
"name": "project-db",
"type": "stdio",
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-postgres", "postgresql://localhost/mydb"]
}
]
}
]Per-project AGENTS.md from a remote URL
[
{
"type": "codex-project",
"directory": "~/projects/my-api",
"agentsMd": "codify://my-document-id:my-file-id"
}
]Or from a public HTTPS URL:
[
{
"type": "codex-project",
"directory": "~/projects/my-api",
"agentsMd": "https://raw.githubusercontent.com/my-org/dotfiles/main/AGENTS.md"
}
]Global install + per-project config together
[
{
"type": "codex",
"config": {
"model": "gpt-5.1-codex"
}
},
{
"type": "codex-project",
"directory": "~/projects/my-api",
"agentsMd": "# My API\n\nNode.js + TypeScript. Run `npm test` before any commit."
}
]Notes
- The
codexresource must be applied beforecodex-project(it declares a dependency automatically). If Codex is not installed, this resource will report as not present. - Multiple
codex-projectentries can coexist — each uniquedirectoryis a separate resource instance. - Destroying a
codex-projectresource removes only the per-project files (AGENTS.mdand the.codex/config.tomldirectory). The Codex binary and global configuration are left untouched. - The
configparameter merges only the declared top-level keys. Existing project config not in your Codify config is left untouched. - The
agentsMdparameter manages the entireAGENTS.mdfile. On destroy, the file is removed. - MCP servers are stored under
[mcp_servers.<name>]in<directory>/.codex/config.toml. Removing an MCP server from your config removes its table; other servers are untouched.