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.
| Command | Description |
|---|---|
status | Return the raw account status API response without summarizing, redacting body fields, or adding calculated fields. |
scrape-html | Retrieve the raw HTML of a page. Browser rendering is optional. |
scrape-markdown | Retrieve a page as clean Markdown. Browser rendering is optional. |
get-screenshot | Capture a base64 PNG screenshot of the full page, the first viewport, or a custom viewport. Browser rendering is always enabled. |
scrape-brand | Extract a website's colors, typography, logos, and social links as 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. |
web-search | Search 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 --versionInstall the CLI and the MrScraper agent skill pack 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.
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.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. See MCP Server for hosted MCP setup.
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.
mrscraper setup skills
mrscraper setup skills --agent hermes
mrscraper init --all --yes --skip-auth --dry-runNative 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 statusA 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 loginThe 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:
- Command
--token MRSCRAPER_API_KEYMRSCRAPER_API_TOKEN~/.mrscraper/auth.json
--token is sent in request headers, never in the request URL.
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 sign-in URL without launching it. The CLI still waits for approval. |
--timeout <seconds> | 180 | Local | Maximum 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_codecontains the HTTP response code.datacontains 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.headerscontains response headers. Credential-bearing headers are filtered, and known credential metadata in scraping and search JSON is redacted.statuspreserves its body fields.- Failed API calls print a JSON envelope with
errorand exit non-zero. HTTP failures keep the status instatus_code; network failures usenull. - 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
| 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 status and login. |
MRSCRAPER_FETCH_BASE_URL | https://api.mrscraper.com | Development 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.
| Parameter | API field | Type | Default | Description |
|---|---|---|---|---|
<url> | url | string | Required | Absolute HTTP or HTTPS URL of the page to process. |
--timeout | timeout | integer | 300 | Maximum seconds to wait for the scrape, from 1 to 330. The HTTP request allows 30 additional seconds. |
--wait-for-selector | waitForSelector | string | Omitted | CSS selector or text to wait for on the page before returning the result, up to 500 characters. |
--geo-code | geoCode | string | Omitted | Two-letter country code to load the page from, sent in lowercase. |
--max-age | maxAge | integer | 0 | Return 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-retries | maxRetries | integer | Omitted | Maximum 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.
| Parameter | API field | Type | Default | Description |
|---|---|---|---|---|
--browser-rendering / --no-browser-rendering | browserRendering | boolean | Omitted | Whether 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-start | warmStart | boolean | false | Whether to open the site's home page first to warm the session before loading the target URL. |
--block-resources | blockResources | boolean | false | Whether 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.
| Command | Fixed fields |
|---|---|
scrape-html | html=true and markdown=false, plus browserRendering=true when a screenshot is set |
scrape-markdown | markdown=true, html=false, and screenshot=false |
get-screenshot | browserRendering=true, html=false, and markdown=false |
scrape-brand | action=brand-scraping and bundle=none |
scrape-json | agent=general |
web-search | action=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:
| Parameter | API field | Type | Default | Description |
|---|---|---|---|---|
--screenshot | screenshot | string | false | Screenshot 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 0The 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 86400000The 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:
| Parameter | API field | Type | Default | Description |
|---|---|---|---|---|
--screenshot | screenshot | string | "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.pngThe 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.comThe 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:
| Parameter | API field | Type | Default | Description |
|---|---|---|---|---|
--prompt | prompt | string | "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-html | html | boolean | true | Whether to include the page HTML in the response. |
--screenshot | screenshot | boolean | false | Whether 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"
}
}web-search
Search the web and return ranked results with titles, URLs, descriptions, and sources. The HTTP deadline is fixed at 120 seconds.
| Parameter | API field | Type | Default | Description |
|---|---|---|---|---|
<query> | query | string | Required | Search query text, trimmed before sending, containing 1 to 1000 characters. |
--country | country | string | Omitted | Two-letter country code to search from, sent in lowercase. Omit it to search from the United States. |
--num-results | numResults | integer | 10 | Number 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 20The 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 loginor setMRSCRAPER_API_KEY. - For slow pages, increase
--timeoutup to 330 seconds.scrape-brandandweb-searchhave fixed 120-second deadlines. - Use
--helpon 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.x | 0.9.0 |
|---|---|
--super, --proxy-country, --proxy, --wait-until, --return-cookie | Removed |
--save-result | Removed; page results are always saved to your dashboard |
mrscraper scrape-markdown <url> --html | mrscraper scrape-markdown <url> for Markdown, or mrscraper scrape-html <url> for HTML |
mrscraper get-screenshot <url> --no-html --markdown | mrscraper get-screenshot <url>; the API still returns the page HTML |
--screenshot full or top | Also accepts a WIDTHxHEIGHT[-ZOOM] viewport, such as 1280x800 |
superMode in programmatic calls | Removed |
--max-ageis new on every page command.scrape-htmlaccepts--screenshot, andscrape-jsonaccepts--warm-start,--block-resources, and--wait-for-selector.--browser-renderingis omitted unless set, so the API switches to a browser only when a request is blocked. Pass--no-browser-renderingto sendbrowserRendering=false.get-screenshotno longer accepts browser rendering, resource blocking,--no-html, or--markdown.--geo-codeand theweb-search--countryoption are omitted unless set, so the API uses the United States. Thescrape-json--htmloption now defaults to on; pass--no-htmlto 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. Runmrscraper setup skillsto refresh installed skills.
Earlier versions
- 0.6.x to 0.7.0:
scraperAPIwas replaced byscrape-html,scrape-markdown, andget-screenshot,accountbystatus, andwebSearchbyweb-search.statusprints the raw API body, andstatusandweb-searchno 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 intoscraperAPI. Upgrade directly to the 0.9.x commands above. - From 0.4.x:
webSearchmoved toaction: "websearch"with--countryand--num-results, and theMRSCRAPER_SYNC_BASE_URLsetting was removed. - Before 0.4.0:
fetchbecamescraperAPI,serpbecamewebSearch, and the originalstatuscommand (with domain analytics) becameaccount. 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, web search, and account usage. Connect AI clients or run the open-source server locally.