CLI

Install, authenticate, and use the MrScraper CLI to retrieve pages as HTML, Markdown, or screenshots, extract brand details and structured JSON, search the web, and check account status.

The MrScraper CLI provides terminal access to the seven MrScraper services, with browser sign-in and optional agent skill setup. Its commands share their descriptions, parameter meanings, and defaults with the MCP server, the SDKs, and the other integrations. This guide covers installation, authentication, output, environment variables, programmatic usage, and complete command details.

CommandDescription
statusReturn the raw account status API response without summarizing, redacting body fields, or adding calculated fields.
scrape-htmlRetrieve the raw HTML of a page. Browser rendering is optional.
scrape-markdownRetrieve a page as clean Markdown. Browser rendering is optional.
get-screenshotCapture a base64 PNG screenshot of the full page, the first viewport, or a custom viewport. Browser rendering is always enabled.
scrape-brandExtract a website's colors, typography, logos, and social links as JSON.
scrape-jsonExtract structured JSON from a page using a natural-language prompt. Append Json Schema: and a JSON schema to shape the output.
web-searchSearch the web and return ranked results with titles, URLs, descriptions, and sources.

init, login, auth status, logout, and setup skills are configuration commands.

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.9.0. Since 0.7.1, the page commands no longer accept --super, --proxy-country, --proxy, --wait-until, --return-cookie, or --save-result, accept --max-age and custom screenshot viewports, and always save page results to your dashboard. The skill pack has one skill per command. See Migrating from 0.7.x. 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 the MrScraper agent skill pack 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.

The skill pack contains seven skills: mrscraper for setup and account usage, plus mrscraper-scrape-html, mrscraper-scrape-markdown, mrscraper-get-screenshot, mrscraper-scrape-brand, mrscraper-scrape-json, and mrscraper-web-search, one for each scraping and search command.

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. See MCP Server for hosted MCP setup.

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.

mrscraper setup skills
mrscraper setup skills --agent hermes
mrscraper init --all --yes --skip-auth --dry-run

Native plugins (optional)

Native agent plugins are maintained separately from the CLI for ChatGPT and Codex and Claude. See Claude Code setup for installing the Claude plugin.

Choose one skill installation method

If npx ... init already installed the MrScraper skills for an agent, skip plugin installation for that agent. Enabling both methods can load duplicate copies of the same skills.

Verifying installation

After completing installation, verify that the CLI binary and commands are accessible in your environment:

mrscraper --version
mrscraper auth status --json
mrscraper status

A successful status 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 browser approval, and saves a dedicated API key in ~/.mrscraper/auth.json. Keep mrscraper login running until approval completes. Set MRSCRAPER_HOME to change the containing directory.

API-key login

mrscraper login --api-key "$MRSCRAPER_API_KEY"

For automation, set an environment variable instead of saving a key:

export MRSCRAPER_API_KEY="YOUR_TOKEN"

Authentication precedence for service commands is:

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

--token is sent in request headers, never in the request URL.

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 sign-in URL without launching it. The CLI still waits for approval.
--timeout <seconds>180LocalMaximum time to wait for browser approval.

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, plus source for an environment variable or path for a saved key:

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

Every service command prints a JSON envelope to stdout:

{
  "status_code": 200,
  "data": "<html><body>Example page content...</body></html>",
  "headers": {
    "content-type": "text/html; charset=utf-8"
  }
}
  • status_code contains the HTTP response code.
  • data contains the API response body. JSON bodies are parsed; other bodies, such as HTML or Markdown text, remain strings. Field names are returned as the API sends them.
  • headers contains response headers. Credential-bearing headers are filtered, and known credential metadata in scraping and search JSON is redacted. status preserves its body fields.
  • Failed API calls print a JSON envelope with error and exit non-zero. HTTP failures keep the status in status_code; network failures use null.
  • Progress messages use stderr so stdout stays machine-readable. Invalid arguments fail before any request.

Save large output with shell redirection:

mrscraper scrape-html https://example.com > result.json
mrscraper scrape-markdown https://example.com | jq -r '.data'

Response examples on this page show selected keys with placeholder values. Actual responses may contain additional fields.

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 status and login.
MRSCRAPER_FETCH_BASE_URLhttps://api.mrscraper.comDevelopment override for scraping and search commands.

The CLI also loads a .env file from the current working directory.

Shared parameters

Service options use kebab-case. Run mrscraper <command> --help to see the options a command accepts. Every service command also accepts --token <key>.

Page controls

scrape-html, scrape-markdown, get-screenshot, and scrape-json accept these options. Defaults are a 300-second timeout and a maxAge of 0, which always scrapes fresh. --geo-code and --max-retries are omitted unless set, so the API loads the page from the United States with no retry limit.

ParameterAPI fieldTypeDefaultDescription
<url>urlstringRequiredAbsolute HTTP or HTTPS URL of the page to process.
--timeouttimeoutinteger300Maximum seconds to wait for the scrape, from 1 to 330. The HTTP request allows 30 additional seconds.
--wait-for-selectorwaitForSelectorstringOmittedCSS selector or text to wait for on the page before returning the result, up to 500 characters.
--geo-codegeoCodestringOmittedTwo-letter country code to load the page from, sent in lowercase.
--max-agemaxAgeinteger0Return a cached result of the same request when it is newer than the selected age, in milliseconds, up to 604800000 (7 days). A cached result costs the same tokens as the original scrape.
--max-retriesmaxRetriesintegerOmittedMaximum number of retries, as a nonnegative integer. Omit this parameter for no limit.

Loading controls

scrape-html, scrape-markdown, and scrape-json also accept these options. get-screenshot does not.

ParameterAPI fieldTypeDefaultDescription
--browser-rendering / --no-browser-renderingbrowserRenderingbooleanOmittedWhether to load the page in a browser: true always does and false never does. Omit it to load the page without a browser first and switch to a browser automatically if the request is blocked.
--warm-startwarmStartbooleanfalseWhether to open the site's home page first to warm the session before loading the target URL.
--block-resourcesblockResourcesbooleanfalseWhether to block images, fonts, and stylesheets while loading the page.

Values always sent

Each command adds its fixed request fields automatically; they are not options. scrape-html, scrape-markdown, get-screenshot, and scrape-json also always send saveResult=true, so page results are saved to your dashboard. tokenCap is never sent.

CommandFixed fields
scrape-htmlhtml=true and markdown=false, plus browserRendering=true when a screenshot is set
scrape-markdownmarkdown=true, html=false, and screenshot=false
get-screenshotbrowserRendering=true, html=false, and markdown=false
scrape-brandaction=brand-scraping and bundle=none
scrape-jsonagent=general
web-searchaction=websearch

CLI command list

status

Return the raw account status API response without summarizing, redacting body fields, or adding calculated fields. It takes no service parameters, and its HTTP deadline is fixed at 600 seconds. --json is accepted for compatibility; JSON is already the default.

mrscraper status
mrscraper status | jq '.data.data.tokenUsage'

The API body contains message and data. Account details remain nested in data, including subscriptionItem and scraperAllowance, so the envelope exposes them at data.data.

{
  "status_code": 200,
  "data": {
    "message": "Example response",
    "data": {
      "id": "ACCOUNT_ID",
      "tokenLimit": 100000,
      "tokenUsage": 2500,
      "stripeStatus": "active",
      "user": {
        "name": "Example user",
        "email": "user@example.com",
        "isVerified": true
      },
      "subscriptionItem": {
        "name": "Example plan",
        "tokenLimit": 100000
      },
      "scraperAllowance": {
        "remaining": 97500,
        "plans": [{ "remaining": 97500 }]
      }
    }
  },
  "headers": {
    "content-type": "application/json; charset=utf-8"
  }
}

scrape-html

Retrieve the raw HTML of a page. Browser rendering is optional.

Accepts page controls, loading controls, and:

ParameterAPI fieldTypeDefaultDescription
--screenshotscreenshotstringfalseScreenshot to capture with the HTML: false for none, full for the entire page, top for the first viewport, or a WIDTHxHEIGHT viewport from 100 to 3840 pixels with an optional -ZOOM percent from 25 to 300, such as 1280x800 or 1920x1080-75. Setting a screenshot also sends browserRendering=true.
mrscraper scrape-html https://example.com --browser-rendering --warm-start \
  --wait-for-selector 'body' --timeout 120 --max-retries 0

The response body is HTML text. With --screenshot, data is an object containing html and a base64 screenshot:

{
  "status_code": 200,
  "data": {
    "html": "<html>...</html>",
    "screenshot": "BASE64_IMAGE_DATA"
  },
  "headers": {
    "content-type": "application/json; charset=utf-8"
  }
}

Scrape HTML usage is based on runtime and bandwidth. Resource blocking can reduce bandwidth for text-focused pages, and --max-retries limits retry usage. See the Token Plan for the complete calculation.

scrape-markdown

Retrieve a page as clean Markdown. Browser rendering is optional.

Accepts page controls and loading controls.

mrscraper scrape-markdown https://example.com --warm-start --max-age 86400000

The response body is Markdown text.

get-screenshot

Capture a base64 PNG screenshot of the full page, the first viewport, or a custom viewport. Browser rendering is always enabled.

Accepts page controls and:

ParameterAPI fieldTypeDefaultDescription
--screenshotscreenshotstring"full"Screenshot area to capture: full for the entire scroll height, top for the first viewport, or a WIDTHxHEIGHT viewport from 100 to 3840 pixels with an optional -ZOOM percent from 25 to 300, such as 1280x800 or 1920x1080-75.
mrscraper get-screenshot https://example.com --screenshot 1280x800 --timeout 120
mrscraper get-screenshot https://example.com | jq -r '.data.screenshot' | base64 -d > page.png

The response body is JSON containing a base64 PNG screenshot and the page HTML, which the API includes even though html=false is sent.

{
  "status_code": 200,
  "data": {
    "html": "<html>...</html>",
    "screenshot": "BASE64_PNG_DATA"
  },
  "headers": {
    "content-type": "application/json; charset=utf-8"
  }
}

scrape-brand

Extract a website's colors, typography, logos, and social links as JSON. It takes only the URL; page controls are not accepted. The HTTP deadline is fixed at 120 seconds.

mrscraper scrape-brand https://example.com

The API body contains message and a data object with job_id, status, url, final_url, brand, and error. Brand details are at data.data.brand.

{
  "status_code": 200,
  "data": {
    "data": {
      "job_id": "JOB_ID",
      "status": "succeeded",
      "url": "https://example.com",
      "final_url": "https://example.com",
      "brand": {
        "name": "Example brand",
        "colors": { "background": "#ffffff", "text": "#222222" },
        "typography": { "body": { "font_family": "Example font" } }
      },
      "error": null,
      "bundle_url": null
    },
    "message": "Example response"
  },
  "headers": {
    "content-type": "application/json"
  }
}

scrape-json

Extract structured JSON from a page using a natural-language prompt. Append Json Schema: and a JSON schema to shape the output.

Accepts page controls, loading controls, and:

ParameterAPI fieldTypeDefaultDescription
--promptpromptstring"Extract all data as complete as possible."Instructions describing the data to extract. Append Json Schema: and a JSON schema to shape the output.
--html / --no-htmlhtmlbooleantrueWhether to include the page HTML in the response.
--screenshotscreenshotbooleanfalseWhether to include a base64 screenshot in the response.

The request uses GET. If the encoded URL exceeds 8,000 characters, it switches to POST with url, prompt, and agent in the body; page controls remain in the query.

mrscraper scrape-json https://example.com --browser-rendering \
  --prompt 'Extract the first 2 items with title and price. Json Schema: {"type":"array","items":{"type":"object","properties":{"title":{"type":"string"},"price":{"type":"string"}},"required":["title","price"]}}'

Extraction results are in the API body's data field and follow the requested schema. Response metadata includes thread_id, token_usage, status, error, runtime, and cookies. html contains the page HTML unless disabled; markdown and screenshot can be empty strings.

{
  "status_code": 200,
  "data": {
    "success": true,
    "data": [{ "title": "Example item", "price": "10.00" }],
    "thread_id": "THREAD_ID",
    "token_usage": 1,
    "html": "<html>...</html>",
    "markdown": "",
    "screenshot": "",
    "status": "Results ready",
    "error": "",
    "runtime": 1.23,
    "cookies": []
  },
  "headers": {
    "content-type": "application/json"
  }
}

Search the web and return ranked results with titles, URLs, descriptions, and sources. The HTTP deadline is fixed at 120 seconds.

ParameterAPI fieldTypeDefaultDescription
<query>querystringRequiredSearch query text, trimmed before sending, containing 1 to 1000 characters.
--countrycountrystringOmittedTwo-letter country code to search from, sent in lowercase. Omit it to search from the United States.
--num-resultsnumResultsinteger10Number of search results to request, as an integer from 10 to 100. Fewer results may be returned.
mrscraper web-search "site:example.com documentation" --country id --num-results 20

The API body contains success, message, a data array, and tokenUsage. Each result includes rank, title, url, description, and source.

{
  "status_code": 200,
  "data": {
    "success": true,
    "message": "Example response",
    "data": [
      {
        "rank": 1,
        "title": "Example result",
        "url": "https://example.com",
        "description": "Example result description.",
        "source": "example.com"
      }
    ],
    "tokenUsage": 1
  },
  "headers": {
    "content-type": "application/json; charset=utf-8"
  }
}

Programmatic use

The package exports the low-level functions used by the commands: scrapeHtml, scrapeMarkdown, getScreenshot, scrapeBrand, scrapeJson, webSearch, and getSubscriptionAccountApi.

import { scrapeMarkdown, webSearch, getSubscriptionAccountApi } from "@mrscraper/cli";

const token = process.env.MRSCRAPER_API_KEY;

const page = await scrapeMarkdown({ token, url: "https://example.com" });
console.log(page.data);

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 getSubscriptionAccountApi(token);
console.log(status.data.data.tokenUsage);

The functions take a single options object and return the same envelope the commands print. Options use the camelCase API field names shown in each command table. getSubscriptionAccountApi takes the token as its only argument. Programmatic calls require an explicit token and do not load saved CLI credentials or .env files. For an application client, prefer the Node.js SDK.

Troubleshooting

  • For missing credentials, run mrscraper login or set MRSCRAPER_API_KEY.
  • For slow pages, increase --timeout up to 330 seconds. scrape-brand and web-search have fixed 120-second deadlines.
  • Use --help on a command to inspect its accepted options.

Migrating from earlier versions

From 0.7.x

Versions 0.8.1 and 0.9.0 keep the seven commands and change their options.

0.7.x0.9.0
--super, --proxy-country, --proxy, --wait-until, --return-cookieRemoved
--save-resultRemoved; page results are always saved to your dashboard
mrscraper scrape-markdown <url> --htmlmrscraper scrape-markdown <url> for Markdown, or mrscraper scrape-html <url> for HTML
mrscraper get-screenshot <url> --no-html --markdownmrscraper get-screenshot <url>; the API still returns the page HTML
--screenshot full or topAlso accepts a WIDTHxHEIGHT[-ZOOM] viewport, such as 1280x800
superMode in programmatic callsRemoved
  • --max-age is new on every page command. scrape-html accepts --screenshot, and scrape-json accepts --warm-start, --block-resources, and --wait-for-selector.
  • --browser-rendering is omitted unless set, so the API switches to a browser only when a request is blocked. Pass --no-browser-rendering to send browserRendering=false. get-screenshot no longer accepts browser rendering, resource blocking, --no-html, or --markdown.
  • --geo-code and the web-search --country option are omitted unless set, so the API uses the United States. The scrape-json --html option now defaults to on; pass --no-html to turn it off.
  • Page timeouts accept up to 330 seconds.
  • The skill pack changed from three skills (mrscraper, mrscraper-fetch, mrscraper-serp) to seven, one per command. Run mrscraper setup skills to refresh installed skills.

Earlier versions

  • 0.6.x to 0.7.0: scraperAPI was replaced by scrape-html, scrape-markdown, and get-screenshot, account by status, and webSearch by web-search. status prints the raw API body, and status and web-search no longer accept --timeout.
  • 0.5.x to 0.6.0: the format-specific 0.5.x commands (scraperHtml, scraperMarkdown, getScreenshot, scraperJson, scraperMultiplePage, scraperSitemap, scrapeBrand, getBrand) were merged into scraperAPI. Upgrade directly to the 0.9.x commands above.
  • From 0.4.x: webSearch moved to action: "websearch" with --country and --num-results, and the MRSCRAPER_SYNC_BASE_URL setting was removed.
  • Before 0.4.0: fetch became scraperAPI, serp became webSearch, and the original status command (with domain analytics) became account. Manage AI scrapers, reruns, and stored results in the MrScraper dashboard.

On this page