Codex can do more than read and edit files: an MCP server gives it outside tools, a skill gives it a recipe it loads when a task matches, and a custom agent is a helper it hands work to. Each lives in its own file and format. This lesson writes one of each.
Add an MCP server
Open Config Studio for Codex and press MCP servers. One server is one [mcp_servers.<name>] table in config.toml:
- Name it: a short name, such as
docs. - Command and Arguments for a local server (
npx, then-yand the package on the next line), or URL for a remote one. Bearer token comes from names the environment variable that holds its token, so the token itself never goes in the file. - Only these tools keeps the server to the tools you list; Never these tools blocks some.
- Before one of its tools runs decides whether Codex asks: auto, prompt, writes or approve.
Give a slow server more time with Startup timeout (s), and turn on Fail startup if it cannot start for a server Codex must not run without.
Write a skill
Press Skills. A skill is a folder with a SKILL.md:
- Where it lives: yours in
~/.agents/skills, or the repository's in.agents/skillsso everyone gets it. - Name: the folder name, such as
release-notes. You can call it by name with$release-notes. - When to use it: the line Codex reads to decide whether the skill fits a task. Say what it does and when; most of the work is here.
- Instructions: the steps, in Markdown.
Leave Codex may pick it on its own on to let Codex load it when a task matches; off, it runs only when you name it.
Make a custom agent
Press Custom agents. An agent is one TOML file Codex can hand work to:
- Where it lives: the repository's
.codex/agents, or yours in~/.codex/agents. - Name, When to use it and Its instructions: who it is, when Codex should use it and how it works.
- Model, Reasoning effort and Sandbox only if it differs from the session that starts it. A reviewer is safer read-only.
A name that matches a built-in agent (default, worker, explorer) replaces it.
Set defaults for subagents
Subagent defaults writes the [agents] table: Most agents open at once, Default model for agents and Default effort for agents. A custom agent's own file beats these for that agent.
Next: install and share a Codex setup, from a starter pack to one install script.