MCP Directory

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.

Hua·June 30, 2026·6 min read
An African man coding on a desktop and laptop in a Nairobi office setting, showcasing modern technology.
Photo by Naboth Otieno on Pexels

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:

TemptationVerdictWhy
Every server that looks coolSkipTools compete for attention; past ~40 the agent degrades.
Two servers doing the same jobSkip oneGitMCP and Octocode is usually redundant.
Broad "do everything" serversTrimEnable only the tool groups you use, if the server supports it.
Graphlit for pure codingSkipIt's RAG for org knowledge, not code correctness.
Community server for a critical write pathWeigh itPrefer 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.

FAQ

Is Codex CLI free to use MCP servers, and are they safe?

The MCP servers themselves are mostly free and open source — GitMCP asks for nothing and needs no auth for public repos. Safety depends on the server: prefer official servers (like GitHub's) on any write path where the agent can mutate your data, and treat community servers as read-only helpers with a small blast radius. Never paste real tokens into a server you haven't vetted, and scope personal access tokens as tightly as the task allows.

Where do I configure MCP servers in Codex CLI?

In ~/.codex/config.toml, under [mcp_servers.<name>] TOML tables — not a JSON mcpServers block like Claude Desktop or Cursor use. Each entry takes a command and args array for local stdio servers, or a url for remote ones. That JSON-vs-TOML difference is the most common thing people get wrong when porting a config to Codex.

How many MCP servers should I add to Codex?

As few as do the job — usually three or four. The constraint is total tools, not servers: most clients get vague and slow past roughly 40 exposed tools, so a single broad server can matter more than three tiny ones. Count tools, not entries, and drop any server whose tools you never see the agent call.

Do I need Docker to run the GitHub MCP server with Codex?

No. Docker is only one of two options — you can instead point Codex at GitHub's hosted remote endpoint (https://api.githubcopilot.com/mcp/) over OAuth and skip the local container entirely. Choose Docker when you need a tightly scoped token or offline access; choose remote when you want nothing running locally.

What's the difference between GitMCP and Octocode for Codex?

GitMCP is a hosted remote server that turns any GitHub repo into a live documentation source, best for grounding the model in a third-party library. Octocode is a local stdio server with 14 tools including LSP intelligence (Go to Definition, Find References), best for tracing symbols across your own codebase. Use GitMCP for external docs, Octocode for your repo — you rarely need both.

Put this into practice

Browse MCP servers by capability, or check your own setup's tool budget and security.

More essays