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
- 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 readsFOAM_MCP_TOKENfrom 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. - 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"
- Check the connection with
codex mcp list, or/mcpinside Codex. - Start
codexand type: Using foam, list my services and run a handful of queries. Codex callslist_tablesandrun_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.