# Environment

- `PAPER_FETCH_ENV_FILE`: Optional path to an explicit environment file. The default user config file is resolved with `platformdirs` and is outside the repo; repo-local config files are not auto-loaded.
- `PAPER_FETCH_SKILL_USER_AGENT`: Optional custom HTTP `User-Agent` for non-browser metadata/API requests; when unset, runtime uses `paper_fetch.config.DEFAULT_USER_AGENT`. If explicitly set and `PAPER_FETCH_BROWSER_USER_AGENT` is unset, browser contexts reuse this value for compatibility.
- `PAPER_FETCH_BROWSER_USER_AGENT`: Optional browser-only `User-Agent` override for managed Chromium/Playwright contexts. Leave unset to use the browser's own UA. For AGU/Wiley Cloudflare challenge issues, set this to a normal Chrome UA.
- `CROSSREF_MAILTO`: Recommended contact email for Crossref polite pool requests.
- `ELSEVIER_API_KEY`: Required for official Elsevier full-text access.
- `WILEY_TDM_CLIENT_TOKEN`: Optional Wiley Text and Data Mining client token for the official Wiley PDF lane; browser PDF/ePDF fallback can still run without it when the local runtime is ready.
- `CLOAKBROWSER_CDP_ENDPOINT`: Optional explicit browser endpoint. When set, browser workflows attach to that already-running Chrome/CloakBrowser, borrow its existing browser context, and serialize browser-backed asset downloads. When unset, paper-fetch uses `cloakbrowser.ensure_binary()` to download/locate Chrome and starts one managed local CDP browser per runtime browser config for HTML fetches, browser-backed asset downloads, and seeded PDF/ePDF fallbacks. Runtime-shared browser-backed assets open isolated contexts/pages serially to avoid cross-thread Playwright sync object reuse; ordinary HTTP asset downloads can still run concurrently.
- `PAPER_FETCH_AMS_STORAGE_STATE_JSON`: Optional AMS browser storage-state override. `paper-fetch auth ams` uses the common browser-provider auth flow and saves to `publisher-browser-profiles/ams/storage-state.json` by default. The JSON captures browser storage, not portable credentials, and may expire or fail on another machine/session.
- `CLOAKBROWSER_BINARY_PATH`: Optional path to a preinstalled Chrome/CloakBrowser binary; cloakbrowser uses it instead of downloading its bundled Chromium.
- `CLOAKBROWSER_PROFILE_DIR`, `CLOAKBROWSER_USER_DATA_DIR`, `CLOAKBROWSER_HEADLESS`: Optional controls for the managed Chrome startup directory, storage-state location, and headed/headless mode when `CLOAKBROWSER_CDP_ENDPOINT` is unset. Default managed headless startup ensures Chrome receives `--headless=new`; set `CLOAKBROWSER_HEADLESS=0` only for deliberate headed runs. If no directory env is set, browser providers default to provider-scoped `publisher-browser-profiles/<provider>/storage-state.json`; storage-state is the primary reused state, not the full browser profile.
- `PAPER_FETCH_WILEY_STORAGE_STATE_JSON`, `PAPER_FETCH_WILEY_PROFILE_DIR`: Optional Wiley auth/profile overrides. Prefer the default provider-scoped storage-state; when manual verification is needed, run `paper-fetch auth wiley [--url ...]` and retry the fetch.
- `CLOAKBROWSER_TIMEOUT_MS`: Optional override for browser workflow per-request timeout. Defaults to `120000`.
- IEEE dynamic HTML / direct HTTP PDF / seeded-browser PDF fallback does not use an IEEE API key; full text availability still depends on the current environment's lawful IEEE Xplore access context. The browser PDF fallback only runs after non-PDF PDF candidates and fails closed on access, challenge, or temporary unavailable pages.
- `PAPER_FETCH_DOWNLOAD_DIR`: Overrides the default CLI/MCP download directory; otherwise downloads use the user data directory, with CLI falling back to `live-downloads` only if that directory cannot be created.
- `XDG_DATA_HOME`: Changes the user data base used for default downloads and formula tools; otherwise the platform default from `platformdirs` is used.
- `PAPER_FETCH_FORMULA_TOOLS_DIR`: Overrides the directory used to find optional formula backends.
- `PAPER_FETCH_RUN_LIVE`: Test-only flag for live publisher integration checks.
- Formula backend env such as `MATHML_CONVERTER_BACKEND`, `TEXMATH_BIN`, `MATHML_TO_LATEX_NODE_BIN`, and `MATHML_TO_LATEX_SCRIPT` only affects MathML-to-LaTeX conversion backends. The default backend is `texmath`; when not explicitly selected, `texmath` failure falls back to `mathml-to-latex`. On Windows offline installs, keep `MATHML_TO_LATEX_NODE_BIN` pointed at the bundled Playwright driver Node instead of a bare `node` from PATH. Shared LaTeX normalization for common publisher macros runs independently of these variables.
- Advanced `mml2tex` support exists behind `MATHML_CONVERTER_BACKEND=mml2tex` plus `MML2TEX_*` Java/XSLT env vars; the default installer does not prepare that toolchain.
