CLI
Install, authenticate, and use the MrScraper CLI to retrieve pages as HTML, Markdown, or screenshots, search Google, and check account usage.
The MrScraper CLI provides terminal access to page retrieval, Google 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.4.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 three 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 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. |
MRSCRAPER_SYNC_BASE_URL | https://sync.scraper.mrscraper.com | Development override for 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,
});
const results = await webSearch({
token,
query: "books",
raw: false,
format: "json",
});
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 account results place the summary directly in data, not in
data.account. Programmatic options use camelCase, such as
browserRendering, homePage, maxRetries, and tokenCap.
scraperAPI and webSearch use the Python SDK's defaults, including
webSearch's raw: true (result-page HTML); pass raw: false for parsed
JSON.
CLI command list
scraperAPI
scraperAPI uses MrScraper's
Web Fetching to retrieve a known page as HTML,
Markdown, a screenshot, or a combination through:
POST https://api.mrscraper.com/HTML is requested by default. The content is in the envelope's data object:
mrscraper scraperAPI "https://www.scrapethissite.com/pages/simple/"
mrscraper scraperAPI "https://www.scrapethissite.com/pages/simple/" | jq -r '.data.html'
mrscraper scraperAPI "https://www.scrapethissite.com/pages/simple/" \
--markdown --no-html | jq -r '.data.markdown'data also reports token_usage, runtime, retry_count, and error. A
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 | Body 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. |
--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 | Enables the proxy-bypass behavior. |
--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 | Body maxRetries | Maximum retries; zero disables retries. |
--token-cap <n> | omitted | Body 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. |
--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 calls:
POST https://sync.scraper.mrscraper.com/api/google/serp/v2/syncParsed JSON is the default; organic results are in data.data.organic. Use
--format html for the result-page HTML:
mrscraper webSearch "iphone 17" --region id --language id --page 2
mrscraper webSearch "iphone 17" --format html --render-jsA complete Google search URL can also be passed directly:
mrscraper webSearch "https://www.google.com/search?q=iphone+17&gl=us&hl=en&start=20"The CLI extracts q, gl, hl, and start, and converts start to a page
number (start=10 selects page 2). Explicit --region, --language, and
--page values override the values from the URL.
webSearch parameters
| CLI parameter | Default | API mapping | Behavior |
|---|---|---|---|
<query-or-url> | required | Body query | Sends a plain query, or locally derives request fields from a Google URL. |
--region <code> | from URL or omitted | Body region | Result country. Explicit CLI input overrides gl from a URL. |
--language <code> | from URL or omitted | Body language | Result language. Explicit CLI input overrides hl from a URL. |
--page <n> | from URL or omitted | Body page | 1-based result page. Explicit CLI input overrides URL start. |
--format <json|html> | json | Body format | Returns parsed JSON or result-page HTML. |
--render-js | off | Body renderJs=true | Renders JavaScript-dependent search features. |
--raw | off | Body format=html | Deprecated alias for --format html. |
--timeout <seconds> | 600 | CLI request | Sets the HTTP request deadline. Not sent in the API body. |
--client-timeout <seconds> | — | CLI request | Compatibility alias for --timeout. |
--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. |
Removed commands
Version 0.4.0 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; --client-timeout is now --timeout, and --raw is --format html. |
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, Google search, and account usage. Connect AI clients or run the open-source server locally.