Inspiration
An AI agent that opens a web page pays for all of it: scripts, styles, trackers, navigation, and somewhere in the middle, the text it wanted. A protocol built for exactly what agents need (typed menus, plain documents, search) already existed in 1991. So we brought Gopher back, for a reader that did not exist then.
What it does
Gopherhole is a gateway that recompiles ordinary web pages into Gopher menus (RFC 1436). One process serves the same menus three ways:
- Real Gopher on TCP port 70.
printf '\r\n' | nc 136-87-128-176.sslip.io 70returns the root menu. - An MCP server with three tools,
menu,readandsearch, each with an optional token budget. - A web client styled as a phosphor terminal, with a gauge that shows where a page's bytes went and a replay of the recorded benchmark runs.
A page becomes a tree. Headings become menus, prose becomes documents with a size hint, navigation links move to their own menu, and a single-field search form becomes a Gopher search item. The agent reads a small root menu, then only the branch it needs. Text taken from a page can never create or alter a menu item, and content a sighted reader would not see is dropped.
What we measured
Every number comes from files in the repository (bench/results/).
- Tasks run by a model. 20 question-answering tasks (14 on a bundled synthetic site, 6 on real sites) on Claude Opus 5.5, in three arms. The markdown reader and Gopherhole each answered 60 of 60 runs correctly. Input tokens, summed over per-task medians: 1,000,806 for the markdown reader, 329,721 for Gopherhole, and 12,738,267 for raw HTML (one run per task).
- Where it lost. Gopherhole used more tokens than the markdown reader on 2 of the 20 tasks, including a question about RFC 1436, a page that is already lean. It also makes about twice as many tool calls.
- Hidden instructions. The synthetic site plants 14 instructions aimed at AI agents. 14 reach a model through raw HTML, 13 through markdown, 4 through Gopherhole. It reduces hidden-text prompt injection; it does not prevent prompt injection.
How we built it
TypeScript on Node.js, as npm workspaces: a pure core (Gopher codec, HTML compiler, renderer with token budgets), a web adapter (allowlist, private-address guard with pinned connections, robots.txt, cache), a server (Gopher daemon, HTTP API, MCP endpoint), a React client, and a benchmark runner. The eight protocol invariants are covered by property-based tests.
The first version of that code base was written with Claude Code. We then moved the work into Kiro: steering files for the project's rules, a custom agent with hooks and the project's own MCP endpoint as a server, and features built by Kiro from specs it wrote first (the Google Cloud deployment, a fix to how the benchmark reports run counts, a Kiro power, and property tests for the codec). Kiro also uses Gopherhole itself: with the deployed gateway as its MCP server, it learned the Kiro power format by reading kiro.dev through Gopherhole, and derived 11 correctness properties for our codec from RFC 1436 read the same way, adding 14 property tests for the gaps. Every Kiro session, including the corrections we sent back, is logged in docs/kiro-log.md.
Challenges we ran into
- Making it impossible for page text to forge a menu line, and proving it with hostile inputs.
- Running a public proxy safely: an allowlist, refusing private addresses, and connecting only to the address that was checked.
- Real pages. The Gopher RFC itself is one big preformatted block with headings marked by spans; it compiled to a single document until the compiler learned that format.
- Keeping the benchmark fair. The baseline is a whole-page markdown conversion with links kept, not an article extractor that cannot follow links.
Accomplishments that we're proud of
- RFC 1436, served back over Gopher as a navigable tree, on a real port 70.
- A benchmark that reports its losses as well as its wins, with every raw trace in the repository.
What we learned
A tree pays off on long pages and multi-page tasks, and costs extra round trips on short ones. On a page that is already lean it can lose.
What's next for Gopherhole
Hiding search items that a site's robots.txt forbids, catching more kinds of hidden text, and an agent view in the client that shows exactly what a model receives.
Built With
- fast-check
- google-compute-engine
- gopher
- kiro
- mcp
- nginx
- node.js
- react
- typescript
- vite
- vitest