This guide provides the quick setup procedure for adding the Context7 MCP (Model Context Protocol) server to the OpenAI Codex programming agent. Context7 enables the agent to access real-time, up-to-date documentation for libraries and frameworks (e.g., Next.js 15, Tailwind v4, Supabase), preventing AI hallucinations.
Run the following command in your terminal (WSL2/Linux/macOS) to automatically register the server:
codex mcp add context7 npx -y @upstash/context7-mcp
If you have a free API Key from Context7 for higher rate limits, use the following version:
codex mcp add context7 npx -y @upstash/context7-mcp --env CONTEXT7_API_KEY=your_api_key_here
To confirm that the server is active and recognized by Codex, use the list command:
codex mcp list
Once installed, you can trigger the documentation search directly in your interactive Codex prompt using the keyword “use context7”.
Prompt Examples:
How do I set up a middleware in Next.js 15? use context7Show me a Stripe Checkout integration example. use context7Refactor this component using Tailwind v4 standards. use context7| Safety Tip | Always run Codex inside a Git-initialized folder. This allows you to use git reset to undo any unwanted file modifications made by the agent. |
|---|