Back to Articles
GuideJanuary 2026

Using Polydev with OpenAI Codex CLI

Get multi-model AI perspectives directly in your terminal. When you need different viewpoints on a bug, architecture decision, or code review, Polydev queries multiple AI models in parallel.

Works across all IDEs: Polydev uses the universal Model Context Protocol (MCP) standard. The same MCP server powers Codex CLI, Claude Code, Cursor, Windsurf, and Cline. Just add it to your MCP config and mention "polydev" or "perspectives" in any prompt.

npx polydev-ai@latest
$ codex mcp list

Available MCP Servers:
──────────────────────────────────────────────────
  polydev     ✓ enabled   Multi-model AI perspectives
  exa         ✓ enabled   Web search
  github      ✓ enabled   GitHub integration
  supabase    ✓ enabled   Database queries
  vercel      ✓ enabled   Deployment management
  memory      ✓ enabled   Knowledge graph
  filesystem  ✓ enabled   File operations

Codex CLI with Polydev MCP server enabled

Install in 60 seconds

1 Install Polydev (requires Node.js):

npm install -g polydev-ai

2 Authenticate — run from any terminal, opens your browser:

polydev-ai login

Alternative: get your token manually from polydev.ai/dashboard/mcp-tokens

3 Add Polydev to your Codex config. Edit ~/.codex/config.toml:

[mcp_servers.polydev]
command = "npx"
args = ["-y", "polydev-ai@latest"]
tool_timeout_sec = 400
startup_timeout_sec = 120

If you got your token manually, add an env section: [mcp_servers.polydev.env] with POLYDEV_USER_TOKEN = "pd_xxx"

4 Verify with codex mcp list

What Polydev adds

MCP Tool

polydev.get_perspectives — queries multiple AI models in parallel

Response time

10-40 seconds (parallel queries to multiple providers)

Use cases

Debugging, architecture decisions, code reviews, security analysis

Example: useEffect debugging

Running codex exec "Use polydev to get perspectives on: What causes React useEffect infinite loops?"

polydev.get_perspectives success in 39.15s:

🟢 **Local CLI Response** (gemini-3-flash-preview)
I will search the codebase for useEffect usage to provide relevant examples.
*Latency: 17582ms | Tokens: 66*

---

🟢 **Local CLI Response** (claude-haiku-4-5)

## React useEffect Infinite Loops

useEffect infinite loops happen when the dependency array causes the
effect to repeatedly trigger itself. Here are the main causes:

### 1. Objects and Functions in Dependencies
React compares dependencies using Object.is(), which checks reference
equality, not value equality.

// ❌ Infinite loop
useEffect(() => {
  setUser({ name: 'John', age: 30 });
}, [user]); // Creates a new object each time

// ✅ Correct
const initialUser = { name: 'John', age: 30 };
useEffect(() => {
  setUser(initialUser);
}, []); // Only runs once

### Key Takeaway
The dependency array tells React "only run this effect when these
values change." If your effect updates one of those dependencies,
it triggers itself again → infinite loop.

*Latency: 31520ms | Tokens: 1150*

How to use it

Just mention "polydev" or "perspectives" in your prompt. Codex will call the get_perspectives MCP tool — the same tool that works in every MCP-compatible IDE:

Debugging

"Use polydev to debug this infinite loop"

Architecture

"Get perspectives on: Redis vs PostgreSQL for caching?"

Code review

"Use polydev to review this API for security issues"

Interactive vs non-interactive

Interactive mode — opens a session for follow-up questions:

codex "Use polydev to analyze this codebase"

Non-interactive (exec) — runs once and exits, good for scripts:

codex exec "Use polydev to get perspectives on JWT vs session auth"

Handy shell aliases

Add to ~/.zshrc or ~/.bashrc:

# Quick multi-model consultation
alias poly='codex exec "Use polydev:"'

# Usage:
# poly "best way to implement caching?"
# poly "review this auth code: $(cat auth.ts)"

Auto-Invocation with AGENTS.md

Make Codex automatically consult Polydev when you're stuck. Create an AGENTS.md file in your project root:

# Auto-Invoke Polydev for Multi-Model Perspectives

When the user encounters any of these situations, automatically
use the polydev MCP tool (get_perspectives) to consult multiple
AI models before responding:

1. User says "stuck", "confused", "not sure", or "can't figure out"
2. Comparison questions: "Should I use X or Y?"
3. Security or code review requests
4. After 2-3 failed debugging attempts
5. Architecture or design decisions
6. Performance optimization questions

Example: If user says "I'm stuck on this auth bug", call
polydev.get_perspectives with the problem context before answering.

How it works: Codex CLI reads AGENTS.md from your project root at session start. These instructions tell Codex when to automatically call Polydev. Bonus: AGENTS.md also works in Windsurf — share the same rules file across both IDEs.

Troubleshooting

MCP not showing in list?

Check ~/.codex/config.toml syntax. TOML is strict—use double quotes, not single quotes.

codex mcp list

Token not found?

Set it in both config.toml and your shell. Verify with:

echo $POLYDEV_USER_TOKEN

npx path issues?

Use the full path. Find it with:

which npx

Slow responses or timeout errors?

Polydev queries multiple AI models which can take up to a few minutes for complex prompts. Make sure your config includes the timeout settings:

# In ~/.codex/config.toml under [mcp_servers.polydev]
tool_timeout_sec = 400
startup_timeout_sec = 120

Without these settings, Codex CLI defaults to 60 seconds which may not be enough for multi-model queries.

Ready to try it?

Free tier: 500 messages/month