Clients
Analyze PCAP files in OpenAI Codex
Tested with Codex CLI 0.172.0 · Updated
OpenAI Codex works with the PcapAI MCP server from the CLI, the IDE extension and the ChatGPT desktop app, which share one configuration file. Three lines of config.toml connect it; one setting lets the capture upload through Codex's sandbox. Then Codex can analyze PCAP files for you, and asks before it spends a report credit.
You need a token in the environment variable PCAPAI_TOKEN; the install guide shows how to create and store one.
Add the server to Codex
Run this once. It adds the server to ~/.codex/config.toml, the file the CLI, the IDE extension and the ChatGPT desktop app share:
codex mcp add pcapai --url https://pcapai.com/mcp --bearer-token-env-var PCAPAI_TOKEN
The command writes these lines, which you can also add by hand. bearer_token_env_var holds the name of the variable, not the token: Codex reads the variable when it starts and sends it in the Authorization header.
[mcp_servers.pcapai]
url = "https://pcapai.com/mcp"
bearer_token_env_var = "PCAPAI_TOKEN"
For one project only, put the same lines in .codex/config.toml in the project folder; Codex reads project configuration in projects you have marked as trusted. Start Codex from a shell where PCAPAI_TOKEN is set: if the variable is missing at start, the server fails to connect and Codex says so.
Let the upload through the sandbox
Codex runs shell commands in a sandbox that has no network access by default. The MCP calls themselves are not affected, but the curl command that uploads the capture to its signed link is a shell command, so it needs network access. Either approve it when Codex asks, or allow network access for commands in the workspace:
[sandbox_workspace_write]
network_access = true
For a single run, pass the same setting on the command line: codex -c 'sandbox_workspace_write.network_access=true'. Network access applies to every command Codex runs in that sandbox, not only the upload, so prefer approving the command if you work in a repository you do not fully trust.
Check the connection
List the configured servers from a terminal. pcapai should be there with its URL, PCAPAI_TOKEN as the bearer token variable and the status enabled; this command reads the configuration and does not connect yet.
codex mcp list
In an interactive session, type /mcp to see whether the server connected and which tools it offers. Then ask "Show my PcapAI account": Codex calls get_account and answers with your plan, the credits left and the largest capture you can upload.
Analyze a capture
Describe the problem and point Codex at the file:
Analyze ./workstation.pcap in security mode. Is 10.2.3.101 compromised? For each finding, tell me what was seen and the MITRE ATT&CK technique.
Codex calls upload_capture, runs the upload command, then analyze_capture, and explains the free summary. Codex gives each tool call up to 60 seconds; PcapAI's tools wait at most 25 seconds and then answer that the engine is still working, so Codex asks again with get_analysis instead of timing out. The evidence, the hosts and the PDF need an unlock, and Codex asks before it spends the credit. More requests are on the example prompts page.
To see the whole flow first, watch the two recorded sessions: a slow server and a compromised host. They were recorded in Claude Code; Codex calls the same tools and gets the same answers.
Run it from scripts with codex exec
codex exec runs one request without the interactive interface, which suits scheduled checks and CI jobs that collect captures:
codex exec "Analyze ./capture.pcap with the PcapAI tools in troubleshooting mode \
and print the verdict and each problem of the free summary."
Nobody is there to answer the credit question in a script, so choose the token's setting on purpose: Never spend credits for jobs that only need the free summary, Unlock without asking for jobs that must produce the PDF. Each job's analyses count toward the account's 20 a day, and the sandbox still needs network access for the upload.
If it does not work
- The server fails to connect at start:
PCAPAI_TOKENwas not set in the shell that started Codex. Check it withecho ${PCAPAI_TOKEN:0:11}, which must printpcapai_pat_. - The upload fails or "has not reached storage yet": the sandbox blocked the network. Approve the command or allow network access as shown above.
- The token is revoked, expired or unknown: create a new one in your profile, update the variable and restart Codex.
Every server message with its fix is on the troubleshooting page.
Was this page helpful?
Thanks. Missing something? Tell us what.