Anyfetch · setup guide

Codex CLI fetch URL: how to make Codex read a web page

Codex CLI can search the web, but it has no tool of its own that fetches a URL from your machine and returns the page. This guide shows what Codex can do alone, where curl stops, and how to add a fetch tool in one command.

Anyfetch 0.8.0 · Tested 2026-10-12

Direct answer

Codex CLI has no fetch tool of its own. It has a hosted web search, which uses a cached index by default and does not fetch arbitrary pages live. To read one URL from your machine, Codex must run curl in its shell, and the default sandbox has network access off. curl also gets 403 from a large part of the web: in our test of 97 popular sites that block AI agents, curl read 46. To give Codex a fetch tool, add Anyfetch as an MCP server: codex mcp add anyfetch -- npx -y @aliasmode/anyfetch mcp. Anyfetch is free, needs no API key, and read 82 of the same 97 sites.

46 of 97Sites read by curl
82 of 97Sites read by Anyfetch
No API keyFor search and for fetch

What Codex CLI can do alone

Web access in Codex CLI with no extra tools, from the Codex documentation.
TaskWhat Codex hasLimit
Search the webA hosted web_search toolLocal sessions use a cached index by default. Start Codex with --search, or set web_search = "live", for live results.
Read one URLNo separate fetch toolCached search reads an index kept by OpenAI. It does not fetch arbitrary pages live. From your machine, the model must use the shell.
curl in the shellWorks when the sandbox has network accessThe default sandbox has network access off. Many sites refuse curl.

So a link in your prompt is often not enough. Codex can search for the page, or it can try curl. In the default cached mode, the search gives it what the index holds, which can be old or can be only a part of the page. curl gives it raw HTML when the site answers, and an error page when the site does not.

Add a fetch tool to Codex CLI

Anyfetch is a free, open-source MCP server from the AliasMode team. It gives Codex three tools: web_fetch, web_fetch_many, and web_search. Pick one of the three ways.

  1. With Node.js: one command, no install

    npx downloads the program for your system at the first start.

    codex mcp add anyfetch -- npx -y @aliasmode/anyfetch mcp
  2. With the installer

    The installer puts one program in ~/.local/bin and runs codex mcp add for you. It also connects Claude Code, Gemini CLI, Cursor, and the other agents it finds.

  3. By hand in config.toml

    Add the server to ~/.codex/config.toml. Use this when you manage the file yourself.

    [mcp_servers.anyfetch]
    command = "anyfetch"
    args = ["mcp"]
curl -fsSL https://aliasmode.github.io/anyfetch/install.sh | sh
irm https://aliasmode.github.io/anyfetch/install.ps1 | iex

Check that Codex reads the page

  1. Run codex mcp list. The list must show anyfetch.
  2. Start a new Codex session. Tools are loaded at the start of a session.
  3. Ask for a page that curl cannot read: “Use web_fetch to read https://www.reuters.com/technology/ and list the first three headlines.”
  4. Codex calls web_fetch and answers from the page. If it runs curl in place of the tool, name the tool in your prompt or in AGENTS.md.

Do you want Codex to use only Anyfetch for the web? Turn the hosted search off in ~/.codex/config.toml. Anyfetch has its own web_search, which uses Brave, Yahoo, and DuckDuckGo with no API key.

web_search = "disabled"

curl and Anyfetch on the same sites

Pages read, of 97 popular sites that block AI agents. Same server, same day, no proxy.
  1. Anyfetch82 of 97
  2. curl46 of 97

We read each of 97 popular sites once with each tool, on 2026-10-12, from one cloud server with no proxy. A page counts as read when the tool returns at least 500 characters of text and the text is not a bot check. Most of the sites refuse AI agents in some way. A few open sites, such as GitHub and Wikipedia, are in the list as a control. We make Anyfetch and we ran this test, so the list of sites, the script, and the result for every site are public. Run it yourself.

curl got HTTP 403 from 33 of the sites and 402 from 4. Anyfetch read 36 more sites than curl. We did not measure the hosted search of Codex, because our test server has no Codex login.

What Codex gets from web_fetch

  • Markdown in place of HTML. One Wikipedia article is 236,000 bytes of HTML from curl and 46,000 characters of Markdown from Anyfetch.
  • Only the parts that answer a question, when Codex gives a query with the URL. The default limit is then 5,000 characters.
  • PDFs as text, page by page.
  • A Reddit thread with every comment, a Stack Overflow question with its answers, and full Reuters and Bloomberg articles.
  • An error code when a page stays closed, such as challenge_required or http_error, so Codex does not guess.
anyfetch search "tokio select" --site docs.rs --time year
anyfetch fetch https://docs.python.org/3.15/whatsnew/3.15.html --query "sampling profiler rate"

Do you not want an MCP server? Put the two commands in AGENTS.md, and Codex runs them in its shell. The shell needs network access for that.

## Web access
- Search the web: `anyfetch search "<query>"`
- Read pages: `anyfetch fetch <url> [<url>...] --format markdown`

When Codex needs a browser

Anyfetch reads public pages. It does not log in, click, or run page scripts. For a task with an account, a form, or a web app, Codex needs a real browser. AliasMode gives Codex browser profiles with saved sessions through its own MCP server. Use Anyfetch to read, and AliasMode to act.

Frequently asked questions

Can Codex CLI fetch a URL?

Not with a fetch tool of its own. Codex CLI has a hosted web search and a shell. To read one URL from your machine it must run a command such as curl, or use a fetch tool from an MCP server such as Anyfetch.

Why does curl in Codex fail?

There are two common causes. The default sandbox of Codex has network access off, so curl cannot connect. With network access on, many sites answer curl with 403, because its request does not look like a browser request.

How do I add an MCP server to Codex CLI?

Run codex mcp add with a name and the server command, for example: codex mcp add anyfetch -- npx -y @aliasmode/anyfetch mcp. You can also add a [mcp_servers.name] table to ~/.codex/config.toml.

Does Codex web search read the full page?

Not by default. Local Codex sessions use cached search, which reads an index kept by OpenAI and does not fetch arbitrary pages live. Start Codex with --search for live results from the hosted tool. For the current text of one page from your own machine, use a fetch tool.

Does Anyfetch need an API key in Codex?

No. Search and fetch need no API key and no account. Anyfetch is open source under Apache-2.0.