Best MCP Servers for Codex CLI (2026)
Codex CLI is a coding agent — feed it servers that make code better, not a junk drawer of tools that dilute its attention.

The best MCP servers for Codex CLI are the ones that make its code more correct: GitHub for source control, GitMCP or Octocode to kill hallucinated APIs, and a package or SQL server only if your work actually touches them. Codex is a coding agent, so the bar is simple — does the server sharpen the code it writes? If not, skip it. Every tool you add competes for the same attention budget, and past roughly 40 exposed tools most clients get vague and slow (the same tool-limit math that bites Cursor applies here). Below is what to add, what to skip, and the exact config.
How Codex CLI loads MCP servers
Codex CLI reads MCP servers from TOML, not JSON — put them in ~/.codex/config.toml under [mcp_servers.<name>] tables. That's the one gotcha that trips people coming from Claude Desktop or Cursor, which both use mcpServers JSON blocks. The shape is otherwise familiar: a command, an args array, and an env table.
A minimal local server looks like this:
[mcp_servers.package-registry]
command = "npx"
args = ["-y", "package-registry-mcp"]
Most servers you'll add run exactly like that — a local process Codex spawns and talks to over stdio. That's the norm, not the exception: roughly 90% of MCP servers run locally over stdio, so you're mostly configuring commands, not URLs. Remote servers (GitMCP, GitHub's hosted endpoint) are the minority and take a URL instead. If you'd rather not hand-write TOML, the config generator emits a correct block per client.
Start with GitHub — official, and the one everyone needs
Add the GitHub MCP Server first; it's GitHub's own official server and the single most useful add for a coding agent. It lets Codex read repos and code, manage issues and pull requests, and inspect Actions workflows — the daily loop of real development. It replaces the deprecated @modelcontextprotocol/server-github reference package, so if you've got that pinned anywhere, migrate.
You have two ways to run it. Local via the ghcr.io/github/github-mcp-server Docker image with a personal access token, or GitHub's hosted remote at https://api.githubcopilot.com/mcp/ over OAuth. Pick remote if you want zero local moving parts; pick Docker if you need to scope the token tightly or work offline against a self-hosted setup.
[mcp_servers.github]
command = "docker"
args = ["run", "-i", "--rm", "-e", "GITHUB_PERSONAL_ACCESS_TOKEN", "ghcr.io/github/github-mcp-server"]
env = { GITHUB_PERSONAL_ACCESS_TOKEN = "ghp_..." }
One caution: this server exposes a lot of tools. If you only ever read PRs and file issues, that's fine, but it eats a chunk of your budget — keep the rest of your list lean to compensate.
Stop the hallucinated APIs: GitMCP or Octocode
The highest-value non-GitHub add is a server that grounds Codex in real code so it stops inventing function signatures. Two good options, and they solve slightly different problems.
GitMCP is a free, hosted remote server that turns any GitHub repo or Pages site into a live documentation source. Point Codex at https://gitmcp.io/{owner}/{repo} for one project, or the generic https://gitmcp.io/docs to switch repos freely. No install, no auth for public repos — it's the fastest way to make the model answer from a library's actual source instead of its training-data guess. It's community-maintained, not official, but it's open source and asks for nothing.
[mcp_servers.gitmcp]
url = "https://gitmcp.io/docs"
Octocode goes deeper for local work. It's a community server exposing 14 tools across three surfaces: GitHub search, local tools (ripgrep search, directory browsing, file finding in your workspace), and LSP intelligence — Go to Definition, Find References, Call Hierarchy. That LSP layer is the differentiator: Codex can trace a symbol across your actual codebase instead of grepping blind. Use GitMCP to understand a third-party library; use Octocode to understand your own repo.
Don't add both unless you genuinely need remote-docs and deep local tracing — for most people, Octocode alone covers the local case and GitMCP covers the external one.
Situational adds: packages, SQL, and RAG
Add these only if your work touches them — each is genuinely useful in its lane and pure overhead outside it.
- Package Registry MCP Server — searches NPM, crates.io, NuGet, PyPI, and Go for up-to-date package info, plus the GitHub Security Advisory Database. Worth it if Codex keeps suggesting stale versions or you want it to check advisories before pinning a dependency. Community-maintained, stdio.
- Anyquery — a SQLite engine that runs SQL over files, databases, and 40+ apps. Its MCP surface is deliberately tiny: three tools (
listTables,describeTable,executeQuery), so it's cheap on your budget while letting Codex explore a schema and run real queries. The three-tool footprint is a feature — most servers should be this disciplined. - Graphlit MCP Server — RAG over Slack, Notion, Jira, Linear, GitHub, and Google Drive. This is a heavier, product-team tool, not a coding add. Reach for it if Codex needs context from your org's knowledge, not to write better functions. If that's your case, it earns its slot; otherwise skip it.
What to skip
Skip anything that doesn't make the code better, and skip duplicates of a capability you already have. Concrete rules from shipping these:
| Temptation | Verdict | Why |
|---|---|---|
| Every server that looks cool | Skip | Tools compete for attention; past ~40 the agent degrades. |
| Two servers doing the same job | Skip one | GitMCP and Octocode is usually redundant. |
| Broad "do everything" servers | Trim | Enable only the tool groups you use, if the server supports it. |
| Graphlit for pure coding | Skip | It's RAG for org knowledge, not code correctness. |
| Community server for a critical write path | Weigh it | Prefer the official GitHub server where it exists. |
The official-vs-community line matters most on write paths. GitHub's server is official — reach for it over a community clone when the agent can mutate your repo. For read-only helpers like GitMCP or Octocode, community is fine; the blast radius is small. For the full landscape, browse the best MCP servers directory or the coding-agents shortlist, which filters for exactly this use case.
My default Codex stack: GitHub (official), Octocode for local tracing, and one situational server for whatever the current project needs. Three servers, well under the tool budget, every tool earning its place.