CLI
Install, authenticate, and use the MrScraper CLI to retrieve pages as HTML, Markdown, or screenshots, search the web, and check account usage.
The MrScraper CLI provides terminal access to page retrieval, web search, and account usage. This guide covers installation, verification, authentication, output formats, environment variables, programmatic usage, and complete command details.
Requirements
- Node.js 20 or newer
- A MrScraper account for browser login, or an API key for non-interactive use
Package information
This page documents version 0.6.0. See @mrscraper/cli on npm for the current published version.
Installation
Install only the CLI globally:
npm install -g @mrscraper/cli@latest
mrscraper --versionInstall the CLI and all four MrScraper agent skills for every detected harness:
npx -y @mrscraper/cli@latest init --allInstall for one harness:
npx -y @mrscraper/cli@latest init --agent codexSupported IDs are claude-code, cursor, codex, grok, hermes,
opencode, openclaw, pi, and omp.
Copyable AI setup prompt
Read and follow https://github.com/mrscraper-com/cli/blob/main/skills/mrscraper/SKILL.mdFor an agent-controlled, non-interactive setup, skip authentication during bootstrap and start login separately:
npx -y @mrscraper/cli@latest init --agent codex --yes --skip-auth
mrscraper auth status --json
mrscraper loginCLI and skills only
mrscraper init installs the CLI and skill pack. It does not install or configure MCP.
init parameters
| Parameter | Default | Scope | Behavior |
|---|---|---|---|
--api-key <key> | — | Local | Saves the supplied key during bootstrap instead of browser login. |
--all | enabled | Local | Installs skills for every supported harness detected on this machine. |
--agent <id> | — | Local | Installs skills for one supported harness, even when its detection directory is absent. |
-y, --yes | off | Local | Keeps bootstrap non-interactive. Missing authentication is left for a later login. |
--skip-install | off | Local | Does not install the current CLI version globally. |
--skip-auth | off | Local | Performs no authentication step. |
--skip-skills | off | Local | Does not install the skill pack. |
--dry-run | off | Local | Prints intended actions without installing, authenticating, or copying skills. |
Refresh only the skills with mrscraper setup skills. It accepts --agent <id> for one harness and --dry-run; without --agent, it targets detected
harnesses.
Native plugins (optional)
The MrScraper CLI repository also provides skills-only native plugins for
Codex, Claude Code, and Cursor. Plugin installation is an alternative to
mrscraper init, not an additional setup step.
Choose one skill installation method
If npx ... init already installed the four MrScraper skills for an agent,
skip plugin installation for that agent. Enabling both methods can load
duplicate copies of the same skills.
Plugins do not install or authenticate the CLI. When using a plugin, install and authenticate the CLI separately:
npm install -g @mrscraper/cli@latest
mrscraper login- Claude Code: run
claude plugin marketplace add mrscraper-com/cli, then installmrscraper-cli@mrscraper. - Cursor: use
/add-plugin mrscraper-cliafter its public marketplace listing; until then, load the repository through Cursor's local plugin directory. - Codex: until its public plugin listing is available, use the local marketplace example from the CLI repository.
Verifying installation
After completing installation, verify that the CLI binary and commands are accessible in your environment:
mrscraper --version
mrscraper auth status --json
mrscraper account --jsonA successful account call confirms that the CLI can load its authentication
and reach the MrScraper service.
Skill pack reloading
Restart an agent harness or open a new terminal session after installing skills so it reloads the skill pack properly.
Authentication
Browser login
mrscraper loginThe CLI opens the MrScraper login page, waits for the local browser callback,
exchanges the returned code, and saves the provisioned API key in
~/.mrscraper/auth.json. Set MRSCRAPER_HOME to change the containing
directory.
API-key login
mrscraper login --api-key "$MRSCRAPER_API_KEY"Prefer environment variables to literal keys in shell history:
export MRSCRAPER_API_KEY="your-key"Authentication precedence for API commands is:
- Command
--token MRSCRAPER_API_KEYMRSCRAPER_API_TOKEN~/.mrscraper/auth.json
login parameters
| Parameter | Default | Scope | Behavior |
|---|---|---|---|
--api-key <key> | — | Local | Saves this API key and does not open browser login. |
--token <key> | — | Local | Deprecated alias for login's --api-key. |
--no-browser | off | Local | Prompts a human for an API key; requires an interactive terminal. |
--no-open | off | Local | Prints the browser URL without launching it. The callback server still waits. |
--timeout <seconds> | 180 | Local | Maximum time to wait for the browser callback. |
Auth status and logout
mrscraper auth status reports the credential currently available to the CLI.
It reads the local configuration without sending a test request. JSON output
uses the credential_configured field:
{
"credential_configured": true,
"auth_type": "api_key",
"path": "/home/user/.mrscraper/auth.json"
}mrscraper logout deletes local credential files. It does not revoke an API
key remotely.
Output contract
scraperAPI and webSearch return a consistent JSON envelope:
{
"status_code": 200,
"data": {},
"headers": {
"content-type": "application/json"
}
}The fields are:
status_codecontains the HTTP response code.headerscontains non-sensitive response headers.datacontains the response body. JSON responses are parsed; other bodies, such as HTML-onlyscraperAPIresults, remain strings.- Known credential metadata and sensitive response headers are redacted.
- HTTP and network failures remain JSON on stdout, set
error, and exit non-zero. - Progress messages use stderr so stdout remains machine-readable.
account presents account data as a normalized summary at data.account.
Environment variables
| Variable | Default | Purpose |
|---|---|---|
MRSCRAPER_API_KEY | — | Preferred API-key environment override. |
MRSCRAPER_API_TOKEN | — | Alternative API-key environment override. |
MRSCRAPER_HOME | ~/.mrscraper | Credential directory override. |
MRSCRAPER_API_BASE_URL | https://api.app.mrscraper.com/api/v1 | Development override for account and login. |
MRSCRAPER_FETCH_BASE_URL | https://api.mrscraper.com | Development override for scraperAPI and webSearch. |
The CLI also loads a .env file from the current working directory.
Programmatic use
The package exports the same three operations used by the commands:
import { scraperAPI, webSearch, account } from "@mrscraper/cli";
const token = process.env.MRSCRAPER_API_KEY;
const page = await scraperAPI({
token,
url: "https://www.scrapethissite.com/pages/simple/",
markdown: true,
});
console.log(page.data.markdown);
const results = await webSearch({
token,
query: "books",
country: "us",
numResults: 10,
});
for (const item of results.data.data) console.log(item.rank, item.title, item.url);
const status = await account({ token, timeout: 30 });
console.log(status.data.token_remaining);The functions return the same response envelope used by the CLI commands.
Programmatic calls require an explicit token and do not load saved CLI
credentials or .env files. They return an error result for HTTP or network
failures and throw for invalid arguments. Programmatic account results place
the summary directly in data, not in data.account. Programmatic options use
camelCase, such as browserRendering, homePage, waitForSelector,
waitUntil, maxRetries, tokenCap, and numResults.
CLI command list
scraperAPI
scraperAPI uses MrScraper's
Web Fetching to retrieve a known page as HTML,
Markdown, a screenshot, or a combination through:
GET https://api.mrscraper.com/The target URL, output flags, page options, and retry controls are all sent as query parameters.
HTML is requested by default. Requesting only HTML returns the page as a string
in data. Requesting Markdown or a screenshot returns an object in data with
an entry for each requested output, such as html, markdown, and
screenshot. At least one of --html, --markdown, or --screenshot must
remain selected.
mrscraper scraperAPI "https://www.scrapethissite.com/pages/simple/" | jq -r '.data'
mrscraper scraperAPI "https://www.scrapethissite.com/pages/simple/" \
--markdown --no-html | jq -r '.data.markdown'
mrscraper scraperAPI "https://www.scrapethissite.com/pages/simple/" --save page.htmlA screenshot is a base64-encoded JPEG; the x-status-code response header
carries the target page's status.
Browser rendering is automatic unless you set it: the service falls back to a
browser when needed. --browser-rendering forces a browser,
--no-browser-rendering disables it, and --screenshot always uses one.
Real-device routing (--super) is independent of browser rendering:
mrscraper scraperAPI "https://www.scrapethissite.com/pages/ajax-javascript/#2015" \
--browser-rendering \
--wait-for-selector ".film"
mrscraper scraperAPI "https://www.scrapethissite.com/pages/simple/" \
--super --geo-code ID --home-pagescraperAPI parameters
| CLI parameter | Default | API mapping | Behavior |
|---|---|---|---|
<url> | required | Query url | Target page URL. |
--html / --no-html | HTML requested | Query html | Requests or skips HTML content. |
--markdown | off | Query markdown=true | Requests Markdown content. |
--screenshot | off | Query screenshot=true | Captures a screenshot and forces browser rendering. |
--browser-rendering / --no-browser-rendering | automatic | Query browserRendering | Forces or disables browser rendering. |
--super | off | Query super=true | Selects real-device routing. |
--geo-code <code> | US | Query geoCode | Proxy country code. |
--proxy-country <code> | omitted | Query proxyCountry | Compatibility country option. |
--no-use-proxy | proxy allowed | Query useProxy=false | Does not use the service's configured proxy. |
--proxy <proxy> | omitted | Query proxy | Custom proxy as username:password@host:port. |
--wait-for-selector <selector> | omitted | Query waitForSelector | Waits for a CSS selector. |
--wait-until <event> | omitted | Query waitUntil | Waits for a page lifecycle event, such as domcontentloaded. |
--home-page | off | Query warmStart=true | Visits the site root before loading the target page. |
--block-resources | off | Query blockResources=true | Blocks images, CSS, and fonts. |
--bypass-proxy | off | Query bypassProxy=true | Loads static assets such as images, fonts and stylesheets outside the residential proxy to save bandwidth. |
--cookie-jar <config> | omitted | Query cookieJar | Cookie configuration string. |
--headers <json> | omitted | Query headers | Target page request headers as a JSON object. |
--max-retries <n> | 3 | Query maxRetries | Maximum retries; zero disables retries. |
--token-cap <n> | omitted | Query tokenCap | Running token total that stops further retries. The initial request always runs. |
--timeout <seconds> | 120 | Query timeout | Page timeout from 1 to 300 seconds. The command allows an additional 30 seconds to receive the response. |
--stream / --no-stream | API default | Query stream | Sets the streaming preference; the CLI still prints one JSON response. |
--discard-token-secret <secret> | omitted | Header x-discard-token-secret | Optional upstream header. |
--save <path> | omitted | CLI output | Saves data to a file: HTML as text, combined outputs as JSON. |
--token <key> | configured credential | Request headers | Overrides authentication for this command. |
Web Fetching usage is based on runtime and bandwidth: one plan token per 30
seconds and one plan token per 0.25 MB, rounded up per component. Resource
blocking can reduce bandwidth for text-focused pages. Use --max-retries and
--token-cap to balance retry reliability with usage. See the
Token Plan for the complete calculation.
webSearch
webSearch searches the web to retrieve real-time search results, including
relevant website URLs, titles, and descriptions.
mrscraper webSearch "e-menessaptieka.lv linkedin" --country us --num-results 10
mrscraper webSearch "web scraping best practices"The CLI sends this request:
curl --location 'https://api.mrscraper.com' \
--header 'x-api-token: {MRSCRAPER_API_TOKEN}' \
--header 'Content-Type: application/json' \
--data '{
"action": "websearch",
"query": "e-menessaptieka.lv linkedin",
"country": "us",
"numResults": 10
}'data contains success, message, and data. Each item in data.data has
rank, title, url, description, and source.
webSearch parameters
| CLI parameter | Default | API mapping | Behavior |
|---|---|---|---|
<query> | required | Body query | The search query. |
--country <code> | omitted | Body country | Country code for localized results, such as us. Omitted to use the service default. |
--num-results <n> | 10 | Body numResults | Number of results, an integer from 10 to 100. |
--timeout <seconds> | 600 | CLI request | Sets the HTTP request deadline. Not sent in the API body. |
--token <key> | configured credential | Request headers | Overrides authentication for this command. |
account
account checks the remote account's identity, subscription, token quota,
and rate limits. It calls:
GET https://api.app.mrscraper.com/api/v1/subscription-accountsmrscraper account
mrscraper account --json
mrscraper account --pretty --no-colorInteractive terminals show a dashboard by default; redirected output is JSON. API keys and billing identifiers are excluded, and remaining tokens are clamped to zero for over-quota accounts.
{
"status_code": 200,
"data": {
"account": {
"subscription_status": "active",
"enterprise": false,
"token_usage": 250,
"token_limit": 1000,
"token_remaining": 750,
"usage_percent": 25,
"rate_limit": 10,
"rate_ttl": 60,
"auto_renew": true,
"ends_at": null,
"user": {
"name": "Ada",
"email": "ada@example.com",
"verified": true
}
}
},
"headers": {}
}account parameters
| CLI parameter | Default | API mapping | Behavior |
|---|---|---|---|
--json | automatic when piped | CLI output | Prints the summary as JSON. |
--pretty | automatic in TTY | CLI output | Prints the terminal dashboard. Cannot be combined with --json. |
--no-color | off | CLI output | Disables ANSI color in the dashboard. |
--timeout <seconds> | 30 | CLI request | HTTP request timeout. |
--token <key> | configured credential | Request headers | Overrides authentication for this command. |
Migrating from earlier versions
From 0.5.x
Version 0.6.0 returns to three public operations: scraperAPI, webSearch,
and account. The 0.5.x format-specific commands and package exports
(scraperHtml, scraperMarkdown, getScreenshot, scraperJson,
scraperMultiplePage, scraperSitemap, scrapeBrand, getBrand, and their
snake-case aliases) are no longer public.
| 0.5.x | 0.6.0 |
|---|---|
mrscraper scraperHtml <url> | mrscraper scraperAPI <url> |
mrscraper scraperMarkdown <url> | mrscraper scraperAPI <url> --no-html --markdown |
mrscraper getScreenshot <url> | mrscraper scraperAPI <url> --no-html --screenshot |
mrscraper webSearch <query> --region us | mrscraper webSearch <query> --country us |
scraperMarkdown({ token, url }) | scraperAPI({ token, url, html: false, markdown: true }) |
webSearch({ token, query, region: "us" }) | webSearch({ token, query, country: "us" }) |
From 0.4.x
scraperAPInow sends aGETrequest with every option in the query string, and adds--wait-untiland--save. Requesting only HTML returns a string indata, and screenshots are returned as base64 in a JSON object.webSearchnow callshttps://api.mrscraper.comwithaction: "websearch"and accepts--countryand--num-results(10–100). The--region,--language,--page,--format,--raw,--render-js, and--client-timeoutflags and search URL input are removed, as are theraw,format,region,language,page, andrenderJsprogrammatic options and theurlinput alias.- The
MRSCRAPER_SYNC_BASE_URLsetting and theSYNC_SCRAPER_BASE_URLexport are removed. accountis unchanged.
Removed commands
Version 0.4.0 removed the commands below. The CLI exposes only scraperAPI,
webSearch, and account as data commands; login, logout, auth, init,
and setup remain.
| Previous command | Replacement |
|---|---|
fetch | scraperAPI; --super-mode is now --super, and browser rendering is automatic unless set. |
serp | webSearch. |
status | account; domain analytics are no longer included. |
scrape, rerun, results, result | Manage AI scrapers, reruns, and stored results in the MrScraper dashboard. |
Token Plan
Learn how plan tokens and API tokens work in MrScraper, why token usage varies between runs, and how to create your own API token for authentication.
MCP Server
Official MrScraper MCP server for retrieving web pages, web search, and account usage. Connect AI clients or run the open-source server locally.