MCP Servers
Learn about the Model Context Protocol (MCP) — connect Codex to GitHub, databases, and external APIs through secure, configurable server integrations.
What is MCP?
The Model Context Protocol (MCP) acts as a universal adapter for AI tools. It allows Codex to interact securely with remote APIs, local databases, and third-party services without exposing your credentials or data.
Think of MCP servers as plugins that extend what Codex can do beyond reading and writing files.
How MCP Works
- MCP Server — A lightweight process that exposes tools and data to the AI agent
- MCP Client — The Codex CLI, which connects to configured servers
- Tools — Specific actions the server exposes (e.g., "read pull request", "query database")
- Resources — Data sources the server can read from (e.g., database schemas, API docs)
Configuring MCP Servers
Create or edit your mcp.json configuration file. This can be project-level or global:
{
"mcpServers": {
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_your_token_here"
}
},
"postgres": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-postgres"],
"env": {
"DATABASE_URL": "postgresql://user:pass@localhost:5432/mydb"
}
}
}
}
GitHub MCP Server
The GitHub integration lets Codex interact with your repositories:
# Install the GitHub MCP server
codex mcp install github-server
Once configured, Codex can:
- Read Pull Requests — Analyze PR diffs and provide review comments
- Comment on Issues — Add analysis or suggestions to GitHub Issues
- Browse repository files — Read code from other repos for reference
- Check CI status — See if builds and tests are passing
Database MCP Server
Connect a read-only database tool so Codex can write accurate SQL:
# Install PostgreSQL MCP server
codex mcp install postgres-server
# Install MySQL MCP server
codex mcp install mysql-server
# Install Redis MCP server
codex mcp install redis-server
With a database MCP server, the agent queries your live schema — it knows exactly which tables exist, what columns they have, and their data types. No more guessing column names or writing invalid queries.
⚠️ Important: Always use read-only database credentials for MCP servers. This prevents the agent from accidentally modifying production data.
Listing and Managing MCP Servers
# List all configured MCP servers
codex mcp list
# Test a server connection
codex mcp test github
# Remove a server
codex mcp remove redis-server
What's Next
In the next episode, we'll learn about delegating tasks to the cloud — how Codex can act as a project manager, breaking large objectives into sub-tasks and dispatching them to multiple cloud agents.