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 --version

Install the CLI and all four MrScraper agent skills for every detected harness:

npx -y @mrscraper/cli@latest init --all

Install for one harness:

npx -y @mrscraper/cli@latest init --agent codex

Supported 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.md

For 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 login

CLI and skills only

mrscraper init installs the CLI and skill pack. It does not install or configure MCP.

init parameters

ParameterDefaultScopeBehavior
--api-key <key>LocalSaves the supplied key during bootstrap instead of browser login.
--allenabledLocalInstalls skills for every supported harness detected on this machine.
--agent <id>LocalInstalls skills for one supported harness, even when its detection directory is absent.
-y, --yesoffLocalKeeps bootstrap non-interactive. Missing authentication is left for a later login.
--skip-installoffLocalDoes not install the current CLI version globally.
--skip-authoffLocalPerforms no authentication step.
--skip-skillsoffLocalDoes not install the skill pack.
--dry-runoffLocalPrints 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 install mrscraper-cli@mrscraper.
  • Cursor: use /add-plugin mrscraper-cli after 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 login

The 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:

  1. Command --token
  2. MRSCRAPER_API_KEY
  3. MRSCRAPER_API_TOKEN
  4. ~/.mrscraper/auth.json

login parameters

ParameterDefaultScopeBehavior
--api-key <key>LocalSaves this API key and does not open browser login.
--token <key>LocalDeprecated alias for login's --api-key.
--no-browseroffLocalPrompts a human for an API key; requires an interactive terminal.
--no-openoffLocalPrints the browser URL without launching it. The callback server still waits.
--timeout <seconds>180LocalMaximum 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_code contains the HTTP response code.
  • headers contains non-sensitive response headers.
  • data contains 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

VariableDefaultPurpose
MRSCRAPER_API_KEYPreferred API-key environment override.
MRSCRAPER_API_TOKENLegacy API-key environment override.
MRSCRAPER_HOME~/.mrscraperCredential directory override.
MRSCRAPER_API_BASE_URLhttps://api.app.mrscraper.com/api/v1Development override for platform API commands.
MRSCRAPER_FETCH_BASE_URLhttps://api.mrscraper.comDevelopment override for fetch.
MRSCRAPER_SYNC_BASE_URLhttps://sync.scraper.mrscraper.comDevelopment 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 parameterDefaultAPI mappingBehavior
<url>requiredQuery urlTarget page URL.
--browser-renderingfalseQuery browserRendering=trueLoads the page in a browser and executes JavaScript.
--geo-code <code>omittedQuery geoCodeRequests proxy routing through the ISO 3166-1 alpha-2 country.
--wait-for-selector <selector>omittedQuery waitForSelectorWaits for a CSS selector. The CLI rejects it unless --browser-rendering is explicit.
--home-pagefalseQuery homePage=trueVisits the site root before loading the target page.
--block-resourcesfalseQuery blockResources=trueBlocks non-essential browser resources when supported by the selected proxy.
--max-retries <n>3Query maxRetriesSets the maximum retry attempts after a failed request. Zero is accepted.
--token-cap <n>omittedQuery tokenCapLimits the running plan-token total used to decide whether another retry may run. The initial request always runs.
--timeout <seconds>30Query timeoutSets the page-load timeout. The command allows an additional 30 seconds to receive the response.
--token <key>configured credentialRequest headersOverrides 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-ai

The 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 5

Listing 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 parameterDefaultAPI mappingAccepted agents and behavior
<url>requiredBody urlTarget URL for all agents.
-p, --prompt <text>requiredBody messageExtraction instructions for general/listing.
-a, --agent <agent>generalBody agentgeneral, listing, or map.
--proxy-country <code>omittedBody proxyCountryGeneral/listing only; rejected for map.
--max-pages <n>omittedBody maxPagesListing/map only. The service default applies when omitted.
--max-depth <n>omittedBody maxDepthMap only.
--limit <n>omittedBody limitMap only.
--include-patterns <regex>omittedBody includePatternsMap only.
--exclude-patterns <regex>omittedBody excludePatternsMap only.
--schema-prompt <path>omittedAppended to body messageBest-effort shape guidance for general/listing.
-o, --output <path>omittedOutput fileWrites data.data.data as pretty JSON.
--token <key>configured credentialRequest headersOverrides authentication for this command.

serp

serp calls:

POST https://sync.scraper.mrscraper.com/api/google/serp/v2/sync

Use --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-js

A 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 parameterDefaultAPI mappingBehavior
<query-or-url>requiredBody querySends a plain query, or locally derives request fields from a Google URL.
--region <code>omittedBody regionResult country. Explicit CLI input overrides gl from a URL.
--language <code>omittedBody languageResult language. Explicit CLI input overrides hl from a URL.
--page <n>omittedBody page1-based result page. Explicit CLI input overrides URL start.
--format <json|html>jsonBody formatReturns parsed JSON or result-page HTML.
--render-jsfalseBody renderJs=trueWaits for JavaScript-rendered SERP features.
--rawfalseSends body format=htmlDeprecated CLI alias for --format html.
--client-timeout <seconds>120CLI requestSets the HTTP request deadline.
--token <key>configured credentialRequest headersOverrides authentication for this command.

status

status combines account information into a concise summary. It calls:

GET https://api.app.mrscraper.com/api/v1/subscription-accounts

The 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 --json

The 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 now

status parameters

CLI parameterDefaultAPI mappingBehavior
--domain <domain-or-url>omittedAnalytics query domainEnables the second analytics request; URLs are locally reduced to hostname.
--from <date-or-duration>24hAnalytics query startDateAccepts ISO time or local durations such as 30m, 24h, and 7d, then formats UTC for the API. Used only with --domain.
--to <date>nowAnalytics query endDateAccepts ISO time or now, then formats UTC. Used only with --domain.
--action <action>empty stringAnalytics query actionOptional analytics filter. Used only with --domain.
--api-token-name <name>empty stringAnalytics query apiTokenNameOptional analytics filter. Used only with --domain.
--jsonautomatic when pipedCLI outputPrints the summary as JSON.
--prettyautomatic in TTYCLI outputPrints the terminal dashboard. Cannot be combined with --json.
--no-coloroffCLI outputDisables ANSI color in the dashboard.
--token <key>configured credentialRequest headersOverrides authentication for both requests.

rerun

Choose the saved scraper and the number of target URLs independently:

  • --type ai runs an AI scraper created by mrscraper scrape.
  • --type manual runs 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_UUID

rerun selects an endpoint based on --type and --bulk:

ModeEndpoint
Single AIPOST /api/v1/scrapers-ai-rerun
Bulk AIPOST /api/v1/scrapers-ai-rerun/bulk
Single manualPOST /api/v1/scrapers-manual-rerun
Bulk manualPOST /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_UUID

rerun parameters

CLI parameterDefaultAPI mappingBehavior
<target>requiredBody url or urlsOne URL for single mode. Bulk mode locally splits comma- or newline-separated URLs into urls.
--type <ai|manual>requiredCLI routingSelects the AI or manual endpoint.
--bulkfalseCLI routingSelects the bulk endpoint.
--scraper-id <uuid>required for singleBody scraperIdSingle endpoint only. Rejected with --bulk.
--id <uuid>required for bulkBody scraperIdBulk endpoint only. Rejected for single mode.
--max-depth <n>2Body maxDepthSingle AI rerun only.
--max-pages <n>50Body maxPagesSingle AI rerun only.
--limit <n>1000Body limitSingle AI rerun only.
--include-patterns <regex>""Body includePatternsSingle AI rerun only.
--exclude-patterns <regex>""Body excludePatternsSingle AI rerun only.
--token <key>configured credentialRequest headersOverrides 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 parameterDefaultAPI query fieldBehavior
--sort-field <field>updatedAtsortFieldField used to sort results.
--sort-order <asc|desc>descsortOrderCLI accepts case-insensitively and sends uppercase ASC or DESC.
--page-size <n>10pageSizePositive result page size.
--page <n>1pagePositive 1-based page number.
--search <query>omittedsearchSearch filter.
--date-range-column <column>omitteddateRangeColumnColumn used with startAt and endAt.
--start-at <iso>omittedstartAtInclusive range start.
--end-at <iso>omittedendAtInclusive range end.
--token <key>configured credentialRequest headersOverrides authentication.

result

result calls GET /api/v1/results/{id}:

mrscraper result RESULT_UUID
mrscraper result --id RESULT_UUID

The positional ID and --id are local input alternatives. --token overrides authentication for this command.

On this page