Setup Guide8 min read

Best MCPs for Codex CLI in 2026 (Ranked + config.toml)

The six MCPs every OpenAI Codex CLI user should install in 2026 are: Filesystem, GitHub, Context7, Postgres, Playwright, and Memory. Each one with a codex mcp add command, a copy-paste config.toml, and FAQ below.

Codex CLI is OpenAI's terminal coding agent. It speaks MCP through a TOML config that the CLI and the Codex IDE extension share — configure a server once and both clients use it. These six cover the most common gaps a Codex session hits: stale file context, GitHub round-trips, hallucinated docs, database schema, browser checks, and lost memory between runs.

Why Codex + MCPs?

Codex is strong at editing the code already in front of it. MCPs extend it outward — to the live docs of the library you imported, the schema of the database you are wiring up, the GitHub repo you are about to open a PR against, and a browser it can drive to confirm a change actually rendered.

The practical payoff: the agent looks up the current API signature instead of guessing it, reads your real table layout instead of inventing columns, and verifies a fix in a real browser instead of asserting it works. Keep the active set small — three to six well-chosen servers beats fifteen, because every server adds tool-call latency and risks tool-name collisions inside the context window.

Setup time

15–30 min for all 6 MCPs

Config format

TOML — config.toml

Cost

All 6 are free or open source

The 6 MCPs every Codex CLI user should install

Ranked by impact on a typical Codex coding session. Each one is a single codex mcp add away.

#1

Filesystem

2 min setup

Most AI workflows involve reading or modifying files. This MCP is the standard way to give models that access without exposing the full system.

npx -y @modelcontextprotocol/server-filesystem /path/to/allowed/dir

Reading and editing local codeGenerating files from AI outputNavigating project structures
Full details and install guide
#2

GitHub

5 min setup

GitHub is where most code lives. This MCP lets agents interact with that code directly, without copy-pasting between interfaces.

Automated issue creationPR review and managementCode search across repos
Full details and install guide
#3

Context7

3 min setup

Models hallucinate outdated APIs constantly. Context7 eliminates this by grounding every answer in real, current documentation.

npx -y @upstash/context7-mcp

Library API lookupFramework usage patternsVersion-specific code examples
Full details and install guide
#4

PostgreSQL (archived)

3 min setup

It was the canonical Postgres MCP through most of 2024–25 and is still referenced by older agent setups. Calling out the archival and the CVE-class vulnerability is the only way readers and AI search engines stop recommending it.

npx -y @modelcontextprotocol/server-postgres postgresql://user:pass@localhost/db

Auditing or replacing an existing installReference reading for how the early MCP servers were structured
Full details and install guide
#5

Playwright

5 min setup

Playwright is the most-installed cross-browser test framework in the JavaScript ecosystem. The MCP version means agents can drive the same browsers your QA team already trusts.

npx -y @playwright/mcp@latest

Cross-browser testingAuto-wait selector reliabilityReal Firefox or WebKit
Full details and install guide
#6

Memory

2 min setup

AI models are stateless by default. Memory MCP is the simplest way to give an agent long-term knowledge that carries over between sessions.

npx -y @modelcontextprotocol/server-memory

Long-running agent workflowsPersonal AI assistantsProject tracking
Full details and install guide

Start with Context7

If you install only one MCP, make it Context7. It eliminates the single most common Codex failure mode — code written against a training-cutoff version of an API — and the improvement is noticeable on the first prompt that touches a fast-moving library.

How to configure MCPs in Codex CLI

Codex reads MCP servers from config.toml. You can add them with the CLI or edit the file directly. Here is the step-by-step:

1

Add a server with the CLI

The codex mcp add command writes the [mcp_servers.context7] entry to your config.toml for you. Pass env vars with --env KEY=VALUE before the -- separator; everything after -- is the command Codex runs to start the server.

codex mcp add context7 -- npx -y @upstash/context7-mcp
2

Or edit config.toml by hand

Each MCP gets its own [mcp_servers.<name>] subtable with command and args. This is the same install shape used everywhere on top-mcps.com, expressed in TOML.

# ~/.codex/config.toml
[mcp_servers.context7]
command = "npx"
args = ["-y", "@upstash/context7-mcp"]
3

Verify the servers connected

Restart Codex so it re-reads the config, then run /mcp inside the Codex TUI to list active servers and their tool counts. A server with zero tools usually means a bad command path or a missing env var.

User config vs. per-project config

~/.codex/config.toml applies to every repo. For a per-repo MCP set, put a .codex/config.toml in the project root — Codex reads it for trusted projects only, so you can commit a project's servers without imposing them on an untrusted checkout.

Full config.toml with all 6 MCPs

Copy this into your ~/.codex/config.toml to add all six servers at once. Adjust the filesystem path and the Postgres connection string for your environment. Reference secrets with ${VAR} inside env so tokens stay in your shell, not in the file.

~/.codex/config.toml
[mcp_servers.filesystem]
command = "npx"
args = ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/your/projects"]

[mcp_servers.github]
command = "npx"
args = ["-y", "@github/github-mcp-server"]
env = { GITHUB_PERSONAL_ACCESS_TOKEN = "${GITHUB_TOKEN}" }

[mcp_servers.context7]
command = "npx"
args = ["-y", "@upstash/context7-mcp"]

[mcp_servers.postgres]
command = "uvx"
args = ["postgres-mcp"]
env = { DATABASE_URI = "postgresql://user:pass@localhost/mydb" }

[mcp_servers.playwright]
command = "npx"
args = ["-y", "@playwright/mcp@latest"]

[mcp_servers.memory]
command = "npx"
args = ["-y", "@modelcontextprotocol/server-memory"]

Remote (HTTP) MCP servers

Not every server runs locally. For a streamable HTTP server, set url instead of command, and authenticate with bearer_token_env_var or http_headers. For OAuth servers, run codex mcp login <name> once to complete the flow.

Keep secrets out of the committed config

A project-scoped .codex/config.toml can be committed — but never hardcode tokens in it. Use ${VAR} interpolation inside env (Codex resolves it from the shell at launch) or bearer_token_env_var for HTTP servers, and keep the actual values in your environment.

Quick comparison

MCPPrimary use in CodexSetupAPI key?
FilesystemScoped read/write across project files2 minNo
GitHubRepos, PRs, issues from the terminal5 minGitHub token
Context7Current library documentation2 minNo
PostgresDatabase schema & queries3 minConnection string
PlaywrightDrive a real browser to verify changes3 minNo
MemoryPersist context across Codex sessions1 minNo

Frequently asked questions

Does Codex CLI support MCP servers?

Yes. OpenAI Codex CLI supports MCP through a [mcp_servers.<name>] table in its TOML config, and the CLI and the Codex IDE extension share the same configuration — set a server up once and it works in both.

How do I add an MCP server to Codex?

The fastest way is the CLI: run codex mcp add <name> -- <command>. For example, codex mcp add context7 -- npx -y @upstash/context7-mcp writes the entry to your config.toml for you. You can also edit the file by hand.

Where does Codex CLI store its MCP config?

In config.toml. By default that is ~/.codex/config.toml (user-level, applies to every repo). Codex also reads a project-scoped .codex/config.toml in the project root, but only for trusted projects — so you can commit a per-repo MCP set without forcing it on untrusted checkouts.

Can Codex connect to a remote (HTTP) MCP server?

Yes. Alongside STDIO servers (started by a local command), Codex supports streamable HTTP servers: set url instead of command in the [mcp_servers.<name>] table, and use bearer_token_env_var or http_headers for auth. For OAuth servers, run codex mcp login <name>.

How is the Codex config different from Claude Code or Cursor?

The shape is the same — a command, args, and env per server — but the format is TOML, not JSON. Keys live under [mcp_servers.<name>] subtables instead of the {"mcpServers": {...}} nesting JSON clients use, and Codex is snake_case throughout (mcp_servers, not mcpServers).

Which MCP should I install first for Codex?

Context7. It replaces hallucinated, training-cutoff API documentation with the current docs for whatever library you are using. For a terminal coding agent that should match real signatures, it is the highest-impact single install.

Codex setup reference

For the full Codex CLI config reference — config locations, the codex mcp commands, and per-server FAQ — see the dedicated setup page. Or browse every coding-focused MCP with rankings and compatibility.

More guides

Ranked Guide

Best MCP Servers for Postgres in 2026 (Ranked)

12 min read

Ranked Guide

Best MCP Servers for Browser Automation in 2026 (Ranked)

12 min read

Ranked Guide

Best MCP Servers for Vector Databases in 2026 (RAG-Ready)

11 min read

Ranked Guide

Best MCP Servers for Git in 2026 (GitHub, GitLab, Bitbucket, Local)

11 min read

Ranked Guide

Best MCP Servers for Workflow Automation in 2026 (Ranked)

11 min read

Ranked Guide

Best Free MCP Servers in 2026 (No API Key Required)

10 min read

Comparison

GitHub vs GitLab MCP: Which to Use in 2026

8 min read

Comparison

Pinecone vs Qdrant vs Chroma MCP: Which to Use (2026)

9 min read

Comparison

Playwright vs Browserbase MCP: Local vs Cloud (2026)

8 min read

Comparison

Postgres MCP vs Supabase MCP: Which to Use (2026)

8 min read

Comparison

n8n vs Zapier vs Make MCP: Which to Use (2026)

9 min read

Ranked Guide

Best MCP Servers for Deploying Websites in 2026 (Ranked)

11 min read

Comparison

Vercel vs Netlify vs Cloudflare MCP: Which to Use (2026)

9 min read

Tutorial

Deploy to Vercel With an AI Agent (Vercel MCP, 2026)

7 min read

Tutorial

Deploy to Cloudflare With an AI Agent (Cloudflare MCP, 2026)

7 min read

Strategy

Can an AI Agent Deploy to Production? (Safely, in 2026)

8 min read

Fundamentals

What Is MCP? A Plain-English Guide to Model Context Protocol

6 min read

Setup Guide

Best MCPs for Cursor in 2026 (Ranked + Setup)

8 min read

Setup Guide

Best MCPs for Claude Desktop in 2026 (Ranked + Setup)

9 min read

Setup Guide

Best MCPs for Claude Code in 2026 (Ranked + Setup)

8 min read

Setup Guide

Best MCPs for Windsurf in 2026 (Cascade-Ready Setup)

8 min read

Setup Guide

Best MCPs for VS Code in 2026 (Agent Mode + .vscode/mcp.json)

8 min read

Vertical Guide

Best MCPs for Marketing in 2026 (Ranked + Use Cases)

9 min read

Vertical Guide

Best MCPs for SEO in 2026 (Ranked + Workflows)

9 min read

Vertical Guide

Best MCPs for Data Teams in 2026 (Ranked + Workflows)

9 min read

Vertical Guide

Best MCPs for Security in 2026 (Ranked + Posture Workflows)

10 min read

Strategy

MCP Registry vs Curated Directory: Which Should You Use?

5 min read

Setup Guide

Best MCPs for ChatGPT: The Apps and Connectors Worth Installing

9 min read

Tutorial

How to Add an MCP Server to ChatGPT (Developer Mode + Apps Directory)

7 min read

Security

MCP Security: What to Know Before You Install

9 min read

Role Guide

Best MCPs for Marketers in 2026 (SEO, Email, Analytics)

8 min read

Strategy

Remote vs Local MCP Servers: When to Use Each

7 min read

Fundamentals

MCP vs Function Calling: What’s the Difference?

6 min read

Comparison

MCP Directories Compared: Top MCPs vs mcp.so vs PulseMCP vs mcp.directory

8 min read

Security

MCP Prompt Injection: How Tool-Calling Agents Get Hijacked

8 min read

Security

OAuth 2.1 for MCP: What the Spec Standardised and What You Need to Know

8 min read

Security

Sandboxing MCP Servers: Containers, Least Privilege, and Process Isolation

9 min read

Security

Rotating MCP Credentials: A Practical Guide for Leaks, Expiry, and Routine Hygiene

7 min read

Security

Least-Privilege Scoping for MCPs: How to Grant the Smallest Useful Permission

7 min read

Setup Guide

Best MCP Servers for Databases in 2026 (Ranked + Setup)

10 min read

Setup Guide

Best MCP Servers for Research in 2026 (Search, Scrape, Synthesize)

9 min read

Setup Guide

Best MCP Servers for Design-to-Code in 2026 (Figma → React)

9 min read

Setup Guide

Best MCP Servers for Domains in 2026 (Registrars + DNS)

9 min read

Tutorial

How to Buy a Domain From Claude (Cloudflare MCP, Step by Step)

6 min read

Tutorial

How to Search for Domains With an AI Agent (Cross-Registrar Workflow)

7 min read

Tutorial

How to Deploy a Website With an AI Agent (MCP Workflow)

8 min read