Docs

Codex

Add the Foam MCP server to Codex. Codex reads the token from your environment each time it connects.

Before you start

You need your personal Foam MCP token in FOAM_MCP_TOKEN. If you have not done that yet, follow Get your token first.

Add Foam to Codex

  1. Run:
    codex mcp add foam --url https://api.foam.ai/mcp --bearer-token-env-var FOAM_MCP_TOKEN
    Codex stores the variable name, not the token, and reads FOAM_MCP_TOKEN from your environment each time it connects. Launch Codex from a shell where the variable is set. If you use the Codex extension in VS Code or Cursor, launch the editor from that shell too.
  2. The command writes this to ~/.codex/config.toml. You can add it by hand instead:
    [mcp_servers.foam]
    url = "https://api.foam.ai/mcp"
    bearer_token_env_var = "FOAM_MCP_TOKEN"
  3. Check the connection with codex mcp list, or /mcp inside Codex.
  4. Start codex and type: Using foam, list my services and run a handful of queries. Codex calls list_tables and run_query. You should see your services listed and rows returned.

If Codex says the token variable is not set

Export FOAM_MCP_TOKEN in your shell profile, open a new terminal, and restart Codex (and your editor, if you use the Codex extension) so it inherits the variable.