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

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

scraperAPI and webSearch return a consistent JSON envelope:

{
  "status_code": 200,
  "data": {},
  "headers": {
    "content-type": "application/json"
  }
}

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

VariableDefaultPurpose
MRSCRAPER_API_KEY—Preferred API-key environment override.
MRSCRAPER_API_TOKEN—Alternative API-key environment override.
MRSCRAPER_HOME~/.mrscraperCredential directory override.
MRSCRAPER_API_BASE_URLhttps://api.app.mrscraper.com/api/v1Development override for account and login.
MRSCRAPER_FETCH_BASE_URLhttps://api.mrscraper.comDevelopment override for scraperAPI.
MRSCRAPER_SYNC_BASE_URLhttps://sync.scraper.mrscraper.comDevelopment 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-page

scraperAPI parameters

CLI parameterDefaultAPI mappingBehavior
<url>requiredBody urlTarget page URL.
--html / --no-htmlHTML requestedQuery htmlRequests or skips HTML content.
--markdownoffQuery markdown=trueRequests Markdown content.
--screenshotoffQuery screenshot=trueCaptures a screenshot and forces browser rendering.
--browser-rendering / --no-browser-renderingautomaticQuery browserRenderingForces or disables browser rendering.
--superoffQuery super=trueSelects real-device routing.
--geo-code <code>USQuery geoCodeProxy country code.
--proxy-country <code>omittedQuery proxyCountryCompatibility country option.
--no-use-proxyproxy allowedQuery useProxy=falseDoes not use the service's configured proxy.
--proxy <proxy>omittedQuery proxyCustom proxy as username:password@host:port.
--wait-for-selector <selector>omittedQuery waitForSelectorWaits for a CSS selector.
--home-pageoffQuery warmStart=trueVisits the site root before loading the target page.
--block-resourcesoffQuery blockResources=trueBlocks images, CSS, and fonts.
--bypass-proxyoffQuery bypassProxy=trueEnables the proxy-bypass behavior.
--cookie-jar <config>omittedQuery cookieJarCookie configuration string.
--headers <json>omittedQuery headersTarget page request headers as a JSON object.
--max-retries <n>3Body maxRetriesMaximum retries; zero disables retries.
--token-cap <n>omittedBody tokenCapRunning token total that stops further retries. The initial request always runs.
--timeout <seconds>120Query timeoutPage timeout from 1 to 300 seconds. The command allows an additional 30 seconds to receive the response.
--stream / --no-streamAPI defaultQuery streamSets the streaming preference; the CLI still prints one JSON response.
--discard-token-secret <secret>omittedHeader x-discard-token-secretOptional upstream header.
--token <key>configured credentialRequest headersOverrides 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/sync

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

A 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 parameterDefaultAPI mappingBehavior
<query-or-url>requiredBody querySends a plain query, or locally derives request fields from a Google URL.
--region <code>from URL or omittedBody regionResult country. Explicit CLI input overrides gl from a URL.
--language <code>from URL or omittedBody languageResult language. Explicit CLI input overrides hl from a URL.
--page <n>from URL or omittedBody page1-based result page. Explicit CLI input overrides URL start.
--format <json|html>jsonBody formatReturns parsed JSON or result-page HTML.
--render-jsoffBody renderJs=trueRenders JavaScript-dependent search features.
--rawoffBody format=htmlDeprecated alias for --format html.
--timeout <seconds>600CLI requestSets the HTTP request deadline. Not sent in the API body.
--client-timeout <seconds>—CLI requestCompatibility alias for --timeout.
--token <key>configured credentialRequest headersOverrides 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-accounts
mrscraper account
mrscraper account --json
mrscraper account --pretty --no-color

Interactive 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 parameterDefaultAPI mappingBehavior
--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.
--timeout <seconds>30CLI requestHTTP request timeout.
--token <key>configured credentialRequest headersOverrides 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 commandReplacement
fetchscraperAPI; --super-mode is now --super, and browser rendering is automatic unless set.
serpwebSearch; --client-timeout is now --timeout, and --raw is --format html.
statusaccount; domain analytics are no longer included.
scrape, rerun, results, resultManage AI scrapers, reruns, and stored results in the MrScraper dashboard.

On this page