Codex
Add the Imagifly MCP server to OpenAI Codex CLI.
Codex is OpenAI's coding agent. It works in your terminal through Codex CLI, or in a cloud sandbox that can write code, run commands and open pull requests. Connecting Imagifly gives it image and video generation alongside its coding tools.
- Website: openai.com/codex
- Repository: github.com/openai/codex
- MCP guide: developers.openai.com/codex/mcp
Add the server
IMAGIFLY_API_KEY./mcp.export IMAGIFLY_API_KEY="imf_your_key_here"
codex mcp add imagifly \
--url https://imagifly.net/api/mcp \
--bearer-token-env-var IMAGIFLY_API_KEYCodex reads the token from the environment variable at connect time, so the key never appears in ~/.codex/config.toml.
Config file
The CLI writes this entry to ~/.codex/config.toml:
[mcp_servers.imagifly]
url = "https://imagifly.net/api/mcp"
bearer_token_env_var = "IMAGIFLY_API_KEY"
enabled = true
startup_timeout_sec = 20| Field | Purpose |
|---|---|
url | Remote MCP endpoint. |
bearer_token_env_var | Environment variable holding the bearer token. |
enabled | Set false to keep the entry but disable it. |
startup_timeout_sec | How long Codex waits for the server during startup; the default is 10. |
http_headers / env_http_headers | Static headers, or headers read from environment variables. |
Codex has no `--header` flag
Use bearer_token_env_var for the API key. If you need additional headers, add them as http_headers in config.toml.
Verify
codex mcp listInside a session, /mcp shows each server and its tools. A working Imagifly entry lists the six generation tools.
Try it
Use imagifly to list the video models, then generate a 5 second clip of fog rolling over a pine forest.The agent calls list_video_models, picks a model with a supported 5-second duration, calls generate_video, then polls get_video_generation.