
Prerequisites
- OpenAI Codex installed and signed in
- An AdsGateway account
- A connected Meta Ads account in AdsGateway for analytics and tracking workflows
Connect AdsGateway
Add AdsGateway MCP server
Click Add server and choose Streamable HTTP.Use:
- Name:
Ads Gateway - URL:
https://ads-gateway.onrender.com/mcp
CLI setup (optional)
Manual config (advanced)
Codex stores MCP servers inconfig.toml.
Add this block to your Codex config without removing any existing MCP servers:
Default config path is
~/.codex/config.toml (macOS/Linux). On Windows, it’s typically C:\\Users\\<you>\\.codex\\config.toml. Codex also supports project-scoped config at .codex/config.toml inside a repo.Copy/Paste Agent Prompt (MCP Install)
Use this prompt in Codex if you want the agent to configure MCP safely:Guardrails
- Preserve existing MCP servers and unrelated Codex settings.
- Use the canonical URL:
https://ads-gateway.onrender.com/mcp. - Avoid duplicate server keys (prefer
mcp_servers.ads_gateway). - After changes, restart MCP and verify authentication.
Use AdsGateway for Analytics
Use this sequence:- Connect AdsGateway MCP in Codex.
- Authenticate and connect Meta.
- Select the ad account you want to analyze.
- Run analytics/journey prompts.
- Account management
List my Meta ad accountsWhich account am I currently using?
- Performance insights
Give me an account summary for the last 7 daysAre there any anomalies in my ad performance?
- Journey reports
Generate an ad report for ad <id> since 2026-02-01 until 2026-02-07
- Creative analysis
Analyze the creative for ad <id>
Use AdsGateway for Tracking (Pixel + CAPI)
Use this sequence:- Start:
setup_meta_trackingwith yoursite_url. - Complete each
next_action. - Confirm required checkpoints:
confirm_pixel="CONFIRM_PIXEL"confirm_event_plan="CONFIRM_EVENT_PLAN"confirm_create_site="CREATE_SITE"
- Save your one-time
sk_key. - Implement snippets/server forwarding from
meta_tracking_snippets_get. - Send test event using
confirm_send_test_event="SEND_TEST_EVENT". - Run
meta_tracking_setup_auditand follownext_actions.
Verify Analytics
Run:Verify Tracking
Run both checks:- Send a test event from the setup flow.
- Audit setup health:
Troubleshooting
- Codex shows “No custom MCP servers connected” after config edits:
- fully quit Codex and reopen it, then re-check MCP settings
- verify the server exists with:
codex mcp list
- Auth popup issues:
- allow popups and retry Authenticate
- re-auth with:
codex mcp logout ads_gatewaythencodex mcp login ads_gateway
- OAuth callback restrictions:
- Codex uses a local callback
http://127.0.0.1:<port>/callback - if your OAuth allow-list requires a fixed callback port, set
mcp_oauth_callback_portinconfig.toml
- Codex uses a local callback

