CLI
Install, authenticate, and use the MrScraper CLI for web fetching, extraction, search, and saved scraper workflows.
The MrScraper CLI provides terminal access to HTML fetching, AI extraction, Google SERP, saved scraper reruns, stored results, 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
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 scrape "https://example.com" \
--prompt "Extract the page title"A successful scrape 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
API commands return a consistent JSON envelope:
{
"status_code": 200,
"data": "the parsed JSON response or response text",
"headers": {
"content-type": "text/html"
}
}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, sensitive response headers, and credentials in generated curl commands are redacted.
- Fetched HTML and scraper extraction results are returned in
data. - HTTP failures remain JSON on stdout, set
error, and exit non-zero. - Progress messages use stderr so stdout remains machine-readable.
status presents account and analytics data as a normalized summary.
Environment variables
| Variable | Default | Purpose |
|---|---|---|
MRSCRAPER_API_KEY | — | Preferred API-key environment override. |
MRSCRAPER_API_TOKEN | — | Legacy API-key environment override. |
MRSCRAPER_HOME | ~/.mrscraper | Credential directory override. |
MRSCRAPER_API_BASE_URL | https://api.app.mrscraper.com/api/v1 | Development override for platform API commands. |
MRSCRAPER_FETCH_BASE_URL | https://api.mrscraper.com | Development override for fetch. |
MRSCRAPER_SYNC_BASE_URL | https://sync.scraper.mrscraper.com | Development override for SERP. |
The CLI also loads a .env file from the current working directory.
Programmatic use
The package exports the same direct API helpers used by the commands:
import {
fetchContentApi,
createAiScraperApi,
googleSerpSyncApi,
getAllResultsApi,
} from "@mrscraper/cli";
const result = await fetchContentApi({
token: process.env.MRSCRAPER_API_KEY,
url: "https://example.com",
browserRendering: true,
maxRetries: 3,
});The helpers return the same response envelope used by the CLI commands.
CLI command list
fetch
fetch uses MrScraper's
Web Unblocker to retrieve HTML from public,
protected, JavaScript-rendered, or geo-sensitive pages through:
GET https://api.mrscraper.com/The returned HTML is available in the envelope's .data field.
mrscraper fetch "https://example.com"
mrscraper fetch "https://example.com" | jq -r '.data'For JavaScript-rendered content, enable browser rendering:
mrscraper fetch "https://example.com/products" \
--browser-rendering \
--wait-for-selector ".product-card"fetch parameters
| CLI parameter | Default | API mapping | Behavior |
|---|---|---|---|
<url> | required | Query url | Target page URL. |
--browser-rendering | false | Query browserRendering=true | Loads the page in a browser and executes JavaScript. |
--geo-code <code> | omitted | Query geoCode | Requests proxy routing through the ISO 3166-1 alpha-2 country. |
--wait-for-selector <selector> | omitted | Query waitForSelector | Waits for a CSS selector. The CLI rejects it unless --browser-rendering is explicit. |
--home-page | false | Query homePage=true | Visits the site root before loading the target page. |
--block-resources | false | Query blockResources=true | Blocks non-essential browser resources when supported by the selected proxy. |
--max-retries <n> | 3 | Query maxRetries | Sets the maximum retry attempts after a failed request. Zero is accepted. |
--token-cap <n> | omitted | Query tokenCap | Limits the running plan-token total used to decide whether another retry may run. The initial request always runs. |
--timeout <seconds> | 30 | Query timeout | Sets the page-load timeout. The command allows an additional 30 seconds to receive the response. |
--token <key> | configured credential | Request headers | Overrides authentication for this command. |
Start with the default request and add page-loading controls when the target
needs them. Unblocker usage is based on runtime and bandwidth: one plan token
per 30 seconds and one plan token per 0.2 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.
scrape
scrape calls:
POST https://api.app.mrscraper.com/api/v1/scrapers-aiThe default agent is general. General and listing require an extraction
prompt:
mrscraper scrape "https://example.com/product" \
--prompt "Extract name, price, availability, and image URLs"The request body contains url, message, and agent, plus optional fields
for the selected agent.
Listing agent
mrscraper scrape "https://example.com/products" \
--agent listing \
--prompt "Extract every product's name, price, and URL" \
--max-pages 5Listing is synchronous and may take several minutes. Progress is printed to
stderr. If --max-pages is omitted, the service default applies.
Map agent
mrscraper scrape "https://example.com" \
--agent map \
--max-depth 2 \
--max-pages 50 \
--limit 1000 \
--include-patterns '/products/'Map accepts crawl limits and URL patterns. Prompts, schema guidance, and proxy country selection are available with the general and listing agents.
Local output file
mrscraper scrape "https://example.com/product" \
--prompt "Extract the product" \
--output ./.mrscraper/product.json--output creates parent directories and writes the extracted
data.data.data value as pretty JSON. The complete response remains on stdout.
The file is created after a completed extraction returns data.
Best-effort schema prompt
mrscraper scrape "https://example.com/product" \
--prompt "Extract the product" \
--schema-prompt ./product.schema.json--schema-prompt reads a local JSON Schema object and adds it to the extraction
instructions as best-effort shape guidance. Use a separate validator when
strict schema compliance is required.
Reproduce a scrape with rerun
Every successful scrape creates a saved AI scraper configuration by default.
The complete stdout response contains its UUID at data.data.scraperId. Save
that response when the extraction may need to run again:
mrscraper scrape "https://example.com/product" \
--prompt "Extract the product name, price, and availability" \
--output ./.mrscraper/product.json \
> ./.mrscraper/product-run.json
SCRAPER_UUID=$(jq -r '.data.data.scraperId' ./.mrscraper/product-run.json)
mrscraper rerun "https://example.com/product-2" \
--type ai \
--scraper-id "$SCRAPER_UUID"The output file contains only data.data.data; the stdout envelope retains the
scraper UUID. rerun reproduces the saved prompt and agent configuration, but
page changes and model behavior can still change the extracted values.
rerun also supports dashboard-built manual workflows and asynchronous bulk
jobs across multiple target URLs. See the full rerun section below
for the available modes and result-tracking workflow.
scrape parameters
| CLI parameter | Default | API mapping | Accepted agents and behavior |
|---|---|---|---|
<url> | required | Body url | Target URL for all agents. |
-p, --prompt <text> | required | Body message | Extraction instructions for general/listing. |
-a, --agent <agent> | general | Body agent | general, listing, or map. |
--proxy-country <code> | omitted | Body proxyCountry | General/listing only; rejected for map. |
--max-pages <n> | omitted | Body maxPages | Listing/map only. The service default applies when omitted. |
--max-depth <n> | omitted | Body maxDepth | Map only. |
--limit <n> | omitted | Body limit | Map only. |
--include-patterns <regex> | omitted | Body includePatterns | Map only. |
--exclude-patterns <regex> | omitted | Body excludePatterns | Map only. |
--schema-prompt <path> | omitted | Appended to body message | Best-effort shape guidance for general/listing. |
-o, --output <path> | omitted | Output file | Writes data.data.data as pretty JSON. |
--token <key> | configured credential | Request headers | Overrides authentication for this command. |
serp
serp calls:
POST https://sync.scraper.mrscraper.com/api/google/serp/v2/syncUse --format to choose parsed JSON or the result-page HTML:
mrscraper serp "iphone 17" --region id --language id --page 2
mrscraper serp "iphone 17" --format html --render-jsA complete Google search URL can also be passed directly:
mrscraper serp "https://www.google.com/search?q=iphone+17&gl=us&hl=en&start=20"The CLI extracts q, gl, hl, and start, converts start to a page
number, then sends the normal API body.
serp 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> | omitted | Body region | Result country. Explicit CLI input overrides gl from a URL. |
--language <code> | omitted | Body language | Result language. Explicit CLI input overrides hl from a URL. |
--page <n> | 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 | false | Body renderJs=true | Waits for JavaScript-rendered SERP features. |
--raw | false | Sends body format=html | Deprecated CLI alias for --format html. |
--client-timeout <seconds> | 120 | CLI request | Sets the HTTP request deadline. |
--token <key> | configured credential | Request headers | Overrides authentication for this command. |
status
status combines account information into a concise summary. It calls:
GET https://api.app.mrscraper.com/api/v1/subscription-accountsThe CLI removes credential and billing identifiers, renames selected fields,
and calculates token_remaining and usage_percent. Interactive terminals get
a dashboard; redirected output is JSON. Force either mode with --pretty or
--json.
mrscraper status
mrscraper status --jsonThe JSON summary includes its source endpoints:
{
"kind": "mrscraper-cli-status-summary",
"source_endpoints": ["/subscription-accounts"],
"status_code": 200,
"data": {
"account": {}
}
}With --domain, the CLI makes a second request to /analytic/statuses, converts
a URL to its hostname, converts relative dates to the API timestamp format, and
merges the result:
mrscraper status --domain "https://example.com/products" --from 7d --to nowstatus parameters
| CLI parameter | Default | API mapping | Behavior |
|---|---|---|---|
--domain <domain-or-url> | omitted | Analytics query domain | Enables the second analytics request; URLs are locally reduced to hostname. |
--from <date-or-duration> | 24h | Analytics query startDate | Accepts ISO time or local durations such as 30m, 24h, and 7d, then formats UTC for the API. Used only with --domain. |
--to <date> | now | Analytics query endDate | Accepts ISO time or now, then formats UTC. Used only with --domain. |
--action <action> | empty string | Analytics query action | Optional analytics filter. Used only with --domain. |
--api-token-name <name> | empty string | Analytics query apiTokenName | Optional analytics filter. Used only with --domain. |
--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. |
--token <key> | configured credential | Request headers | Overrides authentication for both requests. |
rerun
Choose the saved scraper and the number of target URLs independently:
--type airuns an AI scraper created bymrscraper scrape.--type manualruns a step-based workflow created in the MrScraper dashboard. The CLI reruns existing manual workflows; it does not create them.- Without
--bulk, the scraper runs on one URL. With--bulk, the same saved configuration is submitted once with a comma- or newline-separated URL list.
Manual reruns can be single or bulk. Bulk reruns can use either an AI or a manual scraper; bulk describes the number of targets, not the scraper type.
Bulk mode submits one asynchronous backend job; it does not loop over the
single-URL endpoint locally. Save data.data.bulkResultId from the submission
response and retrieve the stored result until it finishes:
mrscraper result --id BULK_RESULT_UUIDrerun selects an endpoint based on --type and --bulk:
| Mode | Endpoint |
|---|---|
| Single AI | POST /api/v1/scrapers-ai-rerun |
| Bulk AI | POST /api/v1/scrapers-ai-rerun/bulk |
| Single manual | POST /api/v1/scrapers-manual-rerun |
| Bulk manual | POST /api/v1/scrapers-manual-rerun/bulk |
mrscraper rerun "https://example.com/product" \
--type ai --scraper-id SCRAPER_UUID
mrscraper rerun "https://a.example,https://b.example" \
--bulk --type manual --id SCRAPER_UUIDrerun parameters
| CLI parameter | Default | API mapping | Behavior |
|---|---|---|---|
<target> | required | Body url or urls | One URL for single mode. Bulk mode locally splits comma- or newline-separated URLs into urls. |
--type <ai|manual> | required | CLI routing | Selects the AI or manual endpoint. |
--bulk | false | CLI routing | Selects the bulk endpoint. |
--scraper-id <uuid> | required for single | Body scraperId | Single endpoint only. Rejected with --bulk. |
--id <uuid> | required for bulk | Body scraperId | Bulk endpoint only. Rejected for single mode. |
--max-depth <n> | 2 | Body maxDepth | Single AI rerun only. |
--max-pages <n> | 50 | Body maxPages | Single AI rerun only. |
--limit <n> | 1000 | Body limit | Single AI rerun only. |
--include-patterns <regex> | "" | Body includePatterns | Single AI rerun only. |
--exclude-patterns <regex> | "" | Body excludePatterns | Single AI rerun only. |
--token <key> | configured credential | Request headers | Overrides authentication for this command. |
The crawl controls apply to single AI reruns.
results
results calls GET /api/v1/results and maps its filtering options directly to
query parameters:
mrscraper results --page-size 20 --page 2
mrscraper results --search example.com
mrscraper results \
--date-range-column updatedAt \
--start-at "2026-08-01T00:00:00Z" \
--end-at "2026-08-18T00:00:00Z"results parameters
| CLI parameter | Default | API query field | Behavior |
|---|---|---|---|
--sort-field <field> | updatedAt | sortField | Field used to sort results. |
--sort-order <asc|desc> | desc | sortOrder | CLI accepts case-insensitively and sends uppercase ASC or DESC. |
--page-size <n> | 10 | pageSize | Positive result page size. |
--page <n> | 1 | page | Positive 1-based page number. |
--search <query> | omitted | search | Search filter. |
--date-range-column <column> | omitted | dateRangeColumn | Column used with startAt and endAt. |
--start-at <iso> | omitted | startAt | Inclusive range start. |
--end-at <iso> | omitted | endAt | Inclusive range end. |
--token <key> | configured credential | Request headers | Overrides authentication. |
result
result calls GET /api/v1/results/{id}:
mrscraper result RESULT_UUID
mrscraper result --id RESULT_UUIDThe positional ID and --id are local input alternatives. --token overrides
authentication for this command.