Skip to content

Commit 9677b3a

Browse files
committed
docs(adapters): document CLI --explain and Botasaurus OpenAPI 2.0 options
auto/capture --explain print telemetry on stderr. MCP inspect payload includes admission and XHR recon. request.botasaurus matches the scrape-API contract (no extra keys, window_size object).
1 parent f28c492 commit 9677b3a

3 files changed

Lines changed: 43 additions & 19 deletions

File tree

src/content/docs/ruby-gem/reference/cli-reference.mdx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Automatically discovers items from a page and prints the generated RSS or JSONFe
2626
html2rss auto https://example.com/articles --limit 10 ; \\
2727
BOTASAURUS_SCRAPER_URL="http://localhost:4010" html2rss auto https://example.com/protected --strategy botasaurus ; \\
2828
html2rss auto https://example.com/articles --items_selector ".post-card" ; \\
29+
html2rss auto https://example.com/articles --explain ; \\
2930
html2rss auto --input sample.html ; \\
3031
html2rss auto https://example.com/articles --input sample.html
3132
`}
@@ -38,11 +39,12 @@ Available options:
3839

3940
- `--strategy`: Optional request strategy (`auto`, `faraday`, `botasaurus`, `local_file`). Defaults to `auto`, which tries `faraday` -> `botasaurus`.
4041
- `--format`: Output format for the auto-sourced feed (`rss` or `jsonfeed`). Defaults to `rss`.
41-
- `--limit`: Maximum number of articles to extract during discovery (defaults to `20`).
42+
- `--limit`: Maximum number of articles to extract during discovery (defaults to `25`).
4243
- `--items_selector`: Optional CSS selector hint for item extraction.
4344
- `--max-redirects`: Maximum redirects to follow per request.
4445
- `--max-requests`: Maximum requests to allow for this feed build (defaults to `4` for auto discovery).
4546
- `--input`: Local HTML file path to read input from without making network requests. When provided without a `URL`, `html2rss` attempts to detect the base URL from `<link rel="canonical">` or OpenGraph metadata in the HTML.
47+
- `--explain`: Print `Html2rss::Status` JSON to stderr (`version`, `dedup_dropped`, and when present `scraper_tallies`, `selected_strategy`, `attempt_count`, `strategy_attempts`, `admission_drops`). Stdout stays the RSS or JSON Feed.
4648

4749
#### URL Surface Guidance For `auto`
4850

@@ -131,13 +133,14 @@ The CLI keeps `strategy` as a top-level override and writes runtime request limi
131133

132134
### Capture
133135

134-
Analyzes a URL using auto-source structural analysis and prints a reusable YAML feed configuration with derived CSS selectors to stdout.
136+
Analyzes a URL using auto-source structural analysis and prints a reusable YAML feed configuration (`items` selector + `enhance: true`) to stdout.
135137

136138
<Code
137139
code={`
138140
html2rss capture https://example.com/articles ; \\
139141
html2rss capture https://example.com/articles --strategy botasaurus ; \\
140142
html2rss capture https://example.com/articles --items_selector ".post-card" ; \\
143+
html2rss capture https://example.com/articles --explain ; \\
141144
html2rss capture --input sample.html
142145
`}
143146
lang="bash"
@@ -153,6 +156,9 @@ Available options:
153156
- `--max-redirects`: Maximum redirects to follow per request.
154157
- `--max-requests`: Maximum requests to allow for this feed build.
155158
- `--input`: Local HTML file path to read input from without making network requests.
159+
- `--explain`: Print capture quality JSON to stderr (`articles_count`, `channel_title`, `has_selectors`, `segment_strategy`, `selected_strategy`, `admission_drops`). Stdout stays YAML.
160+
161+
When AutoFallback (or a pinned strategy) selects a concrete transport, the printed YAML includes a top-level `strategy:` so later `html2rss feed` uses the same hop.
156162

157163
### MCP
158164

@@ -174,7 +180,7 @@ Available options:
174180
- `--transport`: MCP transport protocol (`stdio` or `http`). Defaults to `stdio`.
175181
- `--port`: Port for HTTP transport (default: `8080`). Bound strictly to `127.0.0.1` (loopback only).
176182

177-
HTTP transport requires the `rack`, `rackup`, and `webrick` gems. See the [MCP Server Reference](/ruby-gem/reference/mcp-server/) and [AI Agent Workflows Guide](/ruby-gem/guides/ai-agent-workflows/) for full configuration and tool schemas.
183+
HTTP transport requires the `rack`, `rackup`, and `webrick` gems. stdio keeps JSON-RPC on stdout; the daemon logs to stderr and defaults to `LOG_LEVEL=info` unless you set `LOG_LEVEL`. See the [MCP Server Reference](/ruby-gem/reference/mcp-server/) and [AI Agent Workflows Guide](/ruby-gem/guides/ai-agent-workflows/) for full configuration and tool schemas.
178184

179185
### Schema
180186

src/content/docs/ruby-gem/reference/mcp-server.mdx

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ The MCP server supports two transport mechanisms:
3434

3535
- **Loopback binding:** The HTTP transport only binds to `127.0.0.1`. Never expose it to public interfaces without authentication and reverse proxy origin controls.
3636
- **Dependencies:** The HTTP transport requires the `rack`, `rackup`, and `webrick` gems. If they are not present, starting the server raises a descriptive `LoadError`.
37+
- **Logging:** stdio JSON-RPC uses stdout. The daemon logs to stderr and defaults to `LOG_LEVEL=info` unless `LOG_LEVEL` is set (`debug` for more, `warn` to quiet).
3738

3839
## Strategy Resolution in MCP
3940

@@ -47,14 +48,24 @@ Read `html2rss://runtime` for `botasaurus_configured` (boolean only). Set `BOTAS
4748

4849
## Result envelope
4950

50-
Every tool returns the same JSON object in both the text content and `structuredContent` (there is no `_meta` quality channel):
51+
Every tool returns the same JSON object in both the text content and `structuredContent`:
5152

52-
```json
53-
{ "ok": true, "next_step": "validate_config", "guidance": "...", "payload": {} }
54-
```
53+
<Code
54+
code={`
55+
{
56+
"ok": true,
57+
"next_step": "validate_config",
58+
"guidance": "...",
59+
"payload": {}
60+
}
61+
`}
62+
lang="json"
63+
/>
5564

5665
`isError` matches `ok: false`. Hosts that parsed scrape text as a raw JSON array must read `payload.items` instead.
5766

67+
`next_step` is one of: `done`, `inspect_url`, `validate_config`, `apply_config`, `scrape_url`, `capture_config`, `read_runtime`.
68+
5869
## Tools Reference
5970

6071
The server registers 5 primary tools for AI agent orchestration.
@@ -84,6 +95,9 @@ Diagnostic page analysis plus recon from the same fetch. `auto` uses Faraday; pi
8495
- `scheme_downgrade`: `true` when the fetch went https → http.
8596
- `alternate_feeds`: `rel=alternate` RSS/Atom links from the document head (no `/feed` path guessing).
8697
- `content_type` / `html_response` / `scraper_eligibility` / `sst_stats` / `sst.segment_stats`.
98+
- `articles_count` and `admission_drops` when the response is HTML (Cleanup drop-reason counts).
99+
- `blocked_surface` when an interstitial signature is detected.
100+
- `xhr_capture` when the inspect strategy is `botasaurus` (`count`, redacted `sample_endpoints`, `candidate_articles`).
87101
- **next_step:** `done` when native alternate feeds exist, `capture_config` when articles were found, otherwise `scrape_url`.
88102

89103
### `capture_config`
@@ -129,6 +143,8 @@ The MCP server exposes reference data under the `html2rss://` URI scheme:
129143
| **`html2rss://strategies`** | `application/json` | Published MCP request strategies (`auto`, `faraday`, `botasaurus`). Does not list `local_file`. |
130144
| **`html2rss://runtime`** | `application/json` | Boolean `botasaurus_configured` from process env. Never includes the scraper URL. |
131145

146+
`validate_config` / `apply_config` reject `strategy: local_file` and `request.local_file_path`. Use CLI `--input` for fixtures.
147+
132148
## Prompts Reference
133149

134150
The server publishes guided prompt workflows for AI assistants:

src/content/docs/ruby-gem/reference/strategy.mdx

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ Under `auto`, `Html2rss.feed_result(...).status` exposes scrape telemetry: `sele
3030

3131
`faraday` is the standard static HTTP transport. When no custom `User-Agent` header is supplied in `headers`, `html2rss` sends `html2rss/<VERSION>` by default.
3232

33+
HTML is accepted when `Content-Type` includes `text/html`, or when the body sniffs as HTML (`<!DOCTYPE html` / `<html`) and the response is not JSON. Gzip, deflate, and brotli bodies are decoded even when `Content-Encoding` is missing; unlabeled brotli is tried for `octet-stream`.
34+
3335
## `botasaurus`
3436

3537
`botasaurus` delegates page fetching to a Botasaurus scrape API endpoint. It runs as the second tier of `auto`, or when you pin `strategy: botasaurus`.
@@ -43,6 +45,8 @@ html2rss enforces local request policy preflight and timeout budget. When a tota
4345

4446
During the **browser** execution tier, the Botasaurus scrape API always captures JSON XHR/fetch response bodies (`xhr_responses`). html2rss forwards them as `Response#captured_responses` so AutoSource `xhr_articles` can extract articles without extra requests. The HTTP-request tier returns an empty capture list. Caps and filtering live in the scrape API (see its README); article-likeness filtering is a client concern.
4547

48+
The client speaks OpenAPI 2.0 `ScrapeSuccess` / `ScrapeError` envelopes. Success requires an `html` string. Extra `request.botasaurus` keys fail YAML validation.
49+
4650
### Configuration
4751

4852
<Code
@@ -54,29 +58,28 @@ During the **browser** execution tier, the Botasaurus scrape API always captures
5458
request:
5559
botasaurus:
5660
navigation_mode: auto
57-
max_retries: 1
61+
max_retries: 2
5862
headless: false
5963
`}
6064
lang="yml"
6165
/>
6266

63-
Supported `request.botasaurus` options:
67+
Supported `request.botasaurus` options (unknown keys are rejected):
6468

65-
- `execution_mode` (`auto`, `request`, `browser`; default `auto`)
69+
- `execution_mode` (`auto`, `request`, `browser`; scrape-API default `auto` when omitted)
6670
- `navigation_mode` (`auto`, `get`, `google_get`, `google_get_bypass`, `organic_get`; default `auto`)
67-
- `max_retries` (`0..3`; default `1`)
71+
- `max_retries` (`0..3`; omit to use the scrape-API default of `2`)
6872
- `wait_for_selector` (string)
69-
- `wait_timeout_seconds` (integer)
73+
- `wait_timeout_seconds` (integer `1..20`; omit to use the scrape-API default of `15`)
7074
- `scroll` (boolean)
71-
- `scroll_to_bottom` (boolean)
7275
- `block_images` (boolean)
7376
- `block_images_and_css` (boolean)
7477
- `block_trackers` (boolean)
7578
- `wait_for_complete_page_load` (boolean)
7679
- `headless` (boolean, default `false`)
7780
- `proxy` (string)
7881
- `user_agent` (string)
79-
- `window_size` (two-item integer array, for example `[1920, 1080]`)
82+
- `window_size` (`{ width: 1920, height: 1080 }` — both positive integers, required together)
8083
- `lang` (string, for example `en-US`)
8184
- `headers` (hash, forwarded to the Botasaurus scrape API alongside config-level `headers`)
8285
- `cookies` (hash)
@@ -90,7 +93,7 @@ Example scrape-API payload shape:
9093
{
9194
"url": "https://example.com",
9295
"navigation_mode": "auto",
93-
"max_retries": 1,
96+
"max_retries": 2,
9497
"headless": false
9598
}
9699
`}
@@ -103,11 +106,10 @@ Example scrape-API payload shape:
103106
code={`
104107
BOTASAURUS_SCRAPER_URL="http://localhost:4010" \\
105108
html2rss auto https://example.com/updates --strategy botasaurus
106-
107-
BOTASAURUS_SCRAPER_URL="http://localhost:4010" \\
108-
html2rss feed my_config.yml --strategy botasaurus
109+
BOTASAURUS_SCRAPER_URL="http://localhost:4010" \\
110+
html2rss feed my_config.yml --strategy botasaurus
109111
`}
110-
lang="bash"
112+
lang="bash"
111113
/>
112114

113115
## `local_file`

0 commit comments

Comments
 (0)