Browse a web page
Job: you need the content of a public page (or a short chain of pages) without dumping raw HTML into the prompt. Use browse. It fetches the page, defaults to markdown, and can run a short script of verbs (links, go N, show, forms, submit) against it.
Same network policy as curl (allow-list / full-internet flag). Private and reserved IPs (including localhost) are always blocked. Form submit and click do not run page JavaScript.
Skill source of truth: /skills/browse.md.
Before you start: sessions belong to your caller
Pass caller (your name, for example caller: reed) on every bash_exec call. A browse session lives on that caller:
- After
browse URL, your nextbash_execcall from the same caller is a browse verb, untilquitorpark. - Another caller (for example
scout) never sees your session. Its calls stay plain bash. - The default shell (no
caller) is its own scope. A leftover session there never takes over a call that setscaller, and yours never takes over the default shell. browse jobsandbrowse resumeonly see this caller's sessions.browse jobs --allandbrowse drop --allcover the whole account.
Two ways to drive it:
| Style | Use when | Shape |
|---|---|---|
| One-shot | You know the steps up front (most jobs) | browse URL -- 'verbs; quit' in one call |
| Interactive | You need to read a page before deciding the next verb | browse URL in one call, verbs in the next call |
The REPL starts on the call after browse URL or browse resume. Verbs placed later in the same call run as bash and fail with command not found. Put them in the -- 'script' instead, or in the next call.
Done looks like
browse https://sails.app/guides -- 'go 3; status; quit'
The call opens the page (status 200), follows link 3, prints the new page's status, and ends the session. browse status afterward prints browse: no active session.
Worked example 1: one-shot open, follow, close
browse https://sails.app/guides -- 'go 3; status; quit'
Real output, trimmed (page bodies and title: lines cut):
browse: https://sails.app/guides (200)
format: markdown links: 36 forms: 0 buttons: 1
…page body as markdown, truncated…
next: go N | links | buttons | show | park
browse: https://sails.app/guides/how-to (200)
format: markdown links: 36 forms: 0 buttons: 1
…new page body, truncated…
next: go N | links | buttons | show | back | park
browse: https://sails.app/guides/how-to
status: 200
format: markdown
links: 36
forms: 0
buttons: 1
history: 1
selected_form: -
next: go N | links | buttons | show | back | park
browse: quit
What to notice:
- Opening a page and
go Nboth print the page body. Long bodies end with a[truncatedline that points you toshow. linksprints one line per link: index, link text, then the absolute URL. Indexes start at 0. On this page,0ishttps://sails.app/,1is/guides/,2is/contact, and3is/guides/how-to.history: 1meansbackwill return to the first page.quitprintsbrowse: quitand closes the session.
Run links first when you do not know the index. Link numbers depend on the page, and pages change. https://example.com now has 0 links, so go 0 there fails.
Worked example 2: interactive, park, resume
Call 1 (caller: reed) opens the page and leaves the REPL active:
browse https://sails.app/guides
Call 2 (caller: reed) is read as browse verbs:
go 3; status; park guides
The last line of the reply:
browse: parked #1 name=guides (…) https://sails.app/guides/how-to
next: browse jobs | browse resume 1 | browse drop 1
Meanwhile a call from caller: scout is still plain bash, and only --all shows your park:
$ echo still-bash; browse jobs; browse jobs --all
still-bash
browse: no parked sessions
browse: sessions (all callers)
parked #1 name=guides caller=reed https://sails.app/guides/how-to (…)
browse resume guides from scout fails with browse: no parked sessions (exit 1). Resume never crosses callers.
Back on caller: reed, call 3 resumes (it prints the page), and call 4 finishes:
browse resume guides
status; quit
Plain host and non-200 pages
browse example.com assumes https://. A page that returns an error still opens, and the status is in the first line:
browse: https://sails.app/guides.md (404)
format: markdown links: 0 forms: 0 buttons: 0
file not found
Check that status before you trust the body. The session is open even on a 404, so quit it.
Forms (no JavaScript)
browse https://example.com/login -- 'forms; form 0; fill email=ada@example.com; submit; show; quit'
forms lists forms. form N selects one (0-based) and shows fields. fill k=v … sets values. submit / submit N sends a GET or POST, per the form method. A click N that only works through JavaScript returns a clear error. A failed go or submit leaves you on the previous page with the REPL still active.
Do not put a real password in a script. Collect credentials with secret open (see Store a secret) and call the site's API with curl and an ssec_ token instead.
Park, resume, and clean up
Park keeps HTML, markdown, forms, history, and format on the MCP tenant, per caller. It is not written to disk and has no cookie jar. It is lost if the tenant session is evicted.
browse jobs # or: browse ls (this caller only)
browse resume guides # or: browse fg 1 (this caller only)
browse drop 1 # discard one of this caller's parks
browse jobs --all # every caller's active + parked sessions
browse drop --all leftover # drop that park from any caller
browse drop --all # drop every park and end every REPL on the account
- Starting
browse <url>while this caller has an active session auto-parks it. It gets the next number (#2,#3, …). browse resumedoes not take a-- script. Send verbs in the next call.park [name]/bg [name]are verbs inside a session, for examplebrowse URL -- 'fill email=ada@example.com; park login'.browse drop --all NAMEerrors if the name matches parks on more than one caller. Use the number instead.browse drop --allwith no name also ends other agents' live sessions. Use it only when you own every caller on the account.
Real cleanup of a park another caller left:
$ browse drop --all leftover
browse: dropped #1 https://sails.app/guides (caller=scout)
$ browse jobs --all
browse: no sessions on this account
CLI (verified)
browse <url>
browse <url> -- <script> # one-shot: open URL then run browse statements
browse status
browse jobs | browse ls
browse jobs --all | browse ls --all
browse resume [id|name] | browse fg [id|name]
browse drop <id|name>
browse drop --all [id|name]
browse help
Verbs inside a session or script:
| Command | Meaning |
|---|---|
show | Current page body in the active format |
format md / format html | Sticky view mode (markdown also accepted) |
links | Numbered outbound links (0-based) |
go <url|N> | Navigate to a URL, or follow link N (open N still works) |
back | Previous page in history |
forms / form N | List forms / select form N and show fields |
fill k=v … | Set field values on the selected form |
submit / submit N | Submit form |
buttons / click N | List controls / activate button N (clickables alias) |
park [name] / bg [name] | Background this session; return to bash |
status | URL, title, status, format, counts, history, selected form |
quit | End the active session (parked ones stay) |
Successful replies end with a next: line suggesting follow-ups.
Notes that bite agents
- Default view is markdown (HTML to markdown; script and style stripped). Use
format htmlwhen attributes or structure matter. - Pages served as
text/markdownortext/plainopen as text.links/go Nalso follow[text](url)and HTML<link rel="alternate" type="text/markdown">. - A script stops at the first failing statement. The command exits
1, and the whole transcript goes to stderr. The session stays open on the last good page, so the nextbrowse <url>auto-parks it. Runbrowse jobsandbrowse drop Nafter a failed script. - Use the same
calleron every call. Switching labels mid-task strands your session on the old one; find it withbrowse jobs --all. - REPL priority:
debugwins overbrowse;browsewins overlogs. browseis a workspace command. You do not need a separatesailsshell binary.
Failure modes
| What you see | What it means | What to do |
|---|---|---|
Network access denied: private or reserved endpoint: 127.0.0.1 | Private, reserved, or localhost address | Use a public host |
| Network / allow-list error | Host not allowed | Use a host on the allow-list, or the full-internet flag your workspace already uses for curl |
browse: no links | The page has no links | Use show, or go <url> directly |
link N out of range (0-M) | Indexes are 0-based, or the page has fewer links | Run links, then go 0 to go M |
stopped at statement 3 of 3 then session still active … REPL did not close | A verb failed; session left open | Add quit, or browse drop N once it is parked |
status: command not found right after browse URL or browse resume in the same call | The REPL starts on the next call | Use browse URL -- 'verbs', or send the verbs in the next call |
browse: no parked sessions but you parked one | It was parked under another caller (or none) | browse jobs --all, then switch back to that caller or browse drop --all NAME |
browse: unknown command for a shell command such as echo | This caller is in the browse REPL | Send quit or park from the same caller |
Page opens with (404) and file not found | The URL is wrong; the session is still open | Fix the URL; quit |
| Click / submit needs JS | Control is client-side only | Use a real form submit, or fetch the API the page calls |
Parked session missing from --all too | Tenant session was evicted | Open the URL again; park is in memory only |
Related
- Outbound shell to a real host: SSH to a host
- Fetching bytes into the workspace: Send a file (
transfer) - Credentials for a site's API: Store a secret
- Skill:
/skills/browse.md