Answer: You add an MCP server to Codex with the CLI by running `codex mcp add --env VAR1=VALUE1 --env VAR2=VALUE2 -- `. For example, to add Context7 you can run `codex mcp add context7 -- npx -y @upstash/context7-mcp`. Status: Confirmed Entry: tool/codex/commands-and-shortcuts/add-mcp-server-cli Revision: 1 Digest: sha256:7c64dfd276b60e1f (changes whenever the content changes) Timeline: Created: 2026-11-13T03:51:13Z Last changed: 2026-11-13T03:51:13Z Last verified: 2026-11-20T13:39:32Z Next check: 2026-11-21T13:39:32Z Check interval: Daily Expected change: No fixed schedule Data: Field | Value | Source | As of CLI command | codex mcp add --env VAR1=VALUE1 --env VAR2=VALUE2 -- | [1] | 2026-11-20 Example command | codex mcp add context7 -- npx -y @upstash/context7-mcp | [1] | 2026-11-20 Sources: [1] OpenAI. "Model Context Protocol". https://learn.chatgpt.com/docs/extend/mcp.md Role: primary. Accessed: 2026-11-20T13:39:32Z Quote: "codex mcp add --env VAR1=VALUE1 --env VAR2=VALUE2 -- " (Supports: CLI command) Quote: "codex mcp add context7 -- npx -y @upstash/context7-mcp" (Supports: Example command) Snapshot SHA-256: faf9407740483f7ee27ac4d0db08a9d15510b3d241251edc9d00cf7b35c29e3b (captured 2026-11-13T03:51:12Z) Verification: Method: Automated extraction from [1] with deepseek-flash (JSON output, thinking disabled). Every value was checked by code to appear verbatim in a quoted passage of [1]. On this check the text of [1] was unchanged since 2026-11-13T03:51:13Z, so the values verified then were kept. Cross-check: not-available at 2026-11-20T13:39:32Z. No independent second source is configured for this entry Last successful check: 2026-11-20T13:39:32Z Last attempt: 2026-11-20T13:39:32Z Notes and limitations: Extracted automatically from a single official source (section "Add an MCP server"). Related: https://latestn.com/tool/codex/commands-and-shortcuts/assign-key-binding-codex-ide How do I assign or change a keyboard shortcut for a Codex command in the VS Code IDE extension? https://latestn.com/tool/codex/commands-and-shortcuts/available-slash-commands-codex-ide Which slash commands are available in the Codex IDE extension? https://latestn.com/tool/codex/commands-and-shortcuts/cli-one-off-overrides How do I override Codex configuration options for a single run from the CLI? https://latestn.com/tool/codex/agents-and-automation/run-remediation-noninteractive How do I run Codex security remediation without interaction? https://latestn.com/tool/codex/agents-and-automation/trigger-subagent-workflows How do I enable or trigger subagent workflows in Codex and ChatGPT? https://latestn.com/tool/codex/commands-and-shortcuts/accept-composer-prediction How do I accept a composer prediction in the Codex desktop app? https://latestn.com/tool/ All entries in AI tools Change log: Time | Event | Change | Source 2026-11-13T03:51:13Z | added | Entry created | — Changes for this entry as a feed: https://latestn.com/tool/codex/commands-and-shortcuts/add-mcp-server-cli/latest Challenge this entry: Open challenges: None How: If a value here is wrong or out of date, send what is wrong and a link to evidence. Challenges are queued and checked against the evidence; they do not change the entry by themselves. If the entry changes as a result, the change log says so. Form: https://latestn.com/dispute/tool/codex/commands-and-shortcuts/add-mcp-server-cli POST: https://latestn.com/dispute/tool/codex/commands-and-shortcuts/add-mcp-server-cli with claim, evidence_url, and optionally field and contact (form-encoded or JSON) GET: https://latestn.com/dispute/tool/codex/commands-and-shortcuts/add-mcp-server-cli?claim={what is wrong}&evidence_url={link} How to cite: LatestN. (2026). How do I add an MCP server to Codex with the CLI? Revision 1, last verified 2026-11-20T13:39:32Z. https://latestn.com/tool/codex/commands-and-shortcuts/add-mcp-server-cli (accessed 2026-11-21T09:59:01Z). @misc{LatestN_tool_codex_commands_and_shortcuts_add_mcp_server_cli_r1, title = {How do I add an MCP server to Codex with the CLI?}, author = {{LatestN}}, year = {2026}, howpublished = {\url{https://latestn.com/tool/codex/commands-and-shortcuts/add-mcp-server-cli}}, note = {Revision 1; digest sha256:7c64dfd276b60e1f; last verified 2026-11-20T13:39:32Z; accessed 2026-11-21T09:59:01Z} } Reuse: License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/) Attribution: Copying and adapting are allowed, including commercially, if you credit LatestN and link to the entry you used. Each entry ends with a ready-made citation. URL: https://latestn.com/tool/codex/commands-and-shortcuts/add-mcp-server-cli