plugin_fetch is a clean-room, zero-dependency pure C99 rewrite of the
tool surface of
`modelcontextprotocol/servers` → `src/fetch`
plus the readability-shaped HTML→Markdown subset of
`openclaw/openclaw` → `extensions/web-readability`,
reshaped as a SCORPIOX BOT connector plugin: one binary, four modes, no
shared-library requirements, and a security model you can actually read.
Give it a URL, get clean Markdown back — with the boilerplate gone and long
documents chunked so an agent can page through a page instead of flooding its
context window.
| Slug | fetch |
| Binary | plugin_fetch (plugin_fetch.exe on Windows) |
--meta | {"name":"fetch","desc":"URL to Markdown","kind":"mcp","mcp":true,"daemon":false,"menus":false,"verified":"live"} |
| Category | network |
| Kind | MCP connector (--mcp, stdio JSON-RPC 2.0) |
| License | MIT (vendored yyjson MIT, mbedTLS 3.6.7 Apache-2.0) |
| Mode | Trigger | Who calls it |
|---|---|---|
| Discovery | --meta / SX_PLUGIN_META=1 | scorpiox-bot-api /plugins, scorpiox-cli-botplugin, sx-connector-mcp |
| MCP tool | --mcp | sx-connector-mcp (the single MCP router) or any MCP client over stdio |
| Control API | ?action=… / ?format=json | the plugin page (behind require_node_auth()) |
| Setup / tester page | GET | the browser, via the hub or the node directly |
./plugin_fetch --meta
printf '%s\n' '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' | ./plugin_fetch --mcp
make && make test && make e2e
One tool, fetch, with the same parameter shape as upstream so prompts and
agent code written against the Python reference work unchanged:
| Argument | Type | Default | Meaning |
|---|---|---|---|
url | string | required | must be http:// or https:// |
max_length | integer | 5000 | characters to return, hard cap 100000 |
start_index | integer | 0 | continue a truncated document here |
raw | boolean | false | return the original HTML instead of converting |
printf '%s\n' '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"fetch","arguments":{"url":"https://example.com","max_length":2000}}}' \
| ./plugin_fetch --mcp
Behaviour that matters when an agent is driving it:
`<error>Content truncated. Call the fetch tool with a start_index of 5000 to
get more content.</error>, and an out-of-range start_index` answers
<error>No more content available.</error> — exactly the upstream strings,
so the agent's second call is never guesswork.
cannot be simplified (JSON, XML, plain text) is prefixed with
Content type … cannot be simplified to markdown, but here is the raw content:.
Redirecting from … to … — and each ofup to five hops is re-validated before it is connected to.
Content-Length over5 MB is refused without pulling a byte, so a hostile server cannot make the
node allocate.
What the converter does, in one pass over the bytes (no DOM, no regex):
| Input | Output |
|---|---|
<h1>…<h6> | #…###### |
<a href> | [text](href) — href absolutised against the page URL |
<ul> / <ol> (one nesting level) | - item / 1. item |
<pre><code> | fenced block; <code> inline → ` code ` |
<strong>/<b>, <em>/<i> | **…**, *…* |
<blockquote> | > … |
<hr> | --- |
<img alt src> |  |
<table> | pipe-separated rows |
& — — ✓ | decoded (named + decimal + hex) |
<script> <style> <noscript> <svg> <head> <nav> <aside> <footer> <form> <template> + comments | dropped, subtrees and all |
The document title (og:title if present, else <title>) is prepended as an
# h1 when the body does not already open with it — the same rule as the
upstream title.py.
It is a forgiving tokenizer over raw bytes, not a validator: UTF-8 passes
through untouched, and a page that forgets to close a tag still converts.
This plugin fetches arbitrary URLs on your node, so the guardrails are the
product, not a footnote.
ftp, file, gopher, data) is refused before a socket exists.
every returned record is tested against the denylist, and the socket
then connects to that validated numeric address. A server whose DNS
alternates between a public and a private record — the classic rebinding
trick — is refused outright, and there is no window between the check and
the connect() for the answer to change under us.
_NON_PUBLIC_NETWORKS and then some: 0/8, 10/8, 100.64/10 (CGNAT), 127/8, 169.254/16 (link-local,
which is where the cloud metadata endpoints live), 172.16/12,
192/24 IANA special (with upstream's two anycast exceptions),
192.0.2/24, 192.88.99/24, 192.168/16, 198.18/15, 198.51.100/24,
203.0.113/24, 224/4 (our own addition, upstream omits multicast),
240/4; and on IPv6 ::/96, ::ffff:0:0/96 (v4-mapped, applied through
the v4 list), 64:ff9b::/96 and 64:ff9b:1::/48 (NAT64), 100::/64,
2001::/23 with the documented TEREDO/AMP/ORCHID exceptions,
2001:db8::/32, 2002::/16 (6to4), 3fff::/20, fc00::/7 (ULA),
fe80::/10, fec0::/10.
Non-canonical address text (0177.0.0.1, 0x7f.0.0.1, 1.2.3) is
refused, never reinterpreted — inet_aton would happily turn those
into loopback.
toggle on the page (which writes config.json in the plugin's connector
directory) or FETCH_ALLOW_PRIVATE=1 in the environment. It is off by
default. The offline test suite is the main reason it exists.
MBEDTLS_SSL_VERIFY_REQUIRED with a minimum of TLS 1.2, verifying the peer
certificate and the hostname against a CA bundle (FETCH_TLS_CA_FILE, or
the first system bundle found). There is deliberately no
INSECURE_SKIP_VERIFY option to add. Windows builds hand the whole HTTP
and TLS leg to WinHTTP with the system root store, TLS 1.2+ pinned and
WinHTTP's own redirect handling switched off so every hop comes back
through our validator.
X-Bot-Password, Authorization: Bearer, or ?pwd=), same as every other plugin.
--meta and the page itself stay unauthenticated so discovery works.
Full write-up, including the exact prefix lists and how to verify any of it
yourself, is in `docs/SECURITY.md`.
Dark and light, following the bot's theme tokens and the sx-theme handoff,
fluid down to 390 px and inside the Chat floating window, with zero
<script src=> and no CDN:
max_length / start_index / raw controlssee is what the agent sees
--mcp tool schema, straight from ?action=infoOpen it through the hub (/plugins?plugin=fetch) or the node directly
(/plugin_fetch); ?embed=1 and &theme=dark|light are honoured.
make # native -> ./plugin_fetch
make musl # static musl x86_64 -> ./plugin_fetch.musl
make arm64 # static aarch64 -> ./plugin_fetch.arm64
make win64 # static MinGW PE -> ./plugin_fetch.exe
make macos # Apple clang
make asan # ASan + UBSan + leak check
make fortify # -D_FORTIFY_SOURCE=2
make zlib # native build with gzip support (-DHAVE_ZLIB -lz)
make ui # regenerate src/ui_html.h from src/ui.html
make test # offline suite
make e2e # Playwright viewport checks (skips cleanly without it)
The published artefacts link nothing but libc. make zlib exists so the suite
can prove the gzip path works when zlib happens to be present — the shipped
binary says Unsupported content encoding gzip rather than lying about it.
For the inner loop, ./dev-build.sh caches the ~110 vendored mbedTLS objects
in /tmp/fetch-objs and only recompiles src/ (about two seconds instead of
a minute).
src/plugin_fetch.c four modes, the tool, the policy file, the CGI API
src/fetch_http.c URL parse, SSRF matrix, HTTP/1.1, chunked, redirects,
the POSIX socket path and the WinHTTP path
src/fetch_tls.c mbedTLS over our own BIOs (POSIX only; empty TU on Win32)
src/fetch_md.c tokenizer + Markdown renderer + title extraction
src/sxbuf.c growable buffer, query decoding, JSON escaping, case fold
src/ui.html the page (compiled into src/ui_html.h by tools/gen_ui.py)
src/bot_theme_plugin.h the shared bot theme tokens + sx-theme handoff
vendor/ yyjson (MIT) + mbedTLS 3.6.7 (Apache-2.0) sources
tests/mockd.py the offline HTTP/HTTPS fixture server
tests/mcp.py the MCP stdio harness used by the suite
tests/e2e.py Playwright viewport + interaction checks
docs/ SECURITY.md + screenshots taken by the e2e run
make test runs everything offline — no outbound network. The listeners live
on 127.0.0.1 and the suite reaches them through the plugin's own test-only
private-address allowance, so nothing outside the machine is touched.
--meta · --mcp (tools/list, tools/call, ping, unknown method/tool,
notifications, noise tolerance, argument coercion)
html→markdown (headings, links, lists, code, entities, stripped boilerplate,
title rule, verbatim markdown, no-Content-Type sniffing)
pagination (truncation footer, continuation, out-of-range, the 100000 cap, raw)
transport (redirect chain, relative Location, loop cap, 404/403/500, oversized
body refused unread, chunked, no-Content-Length, gzip, request shape,
read deadline)
ssrf (the whole v4+v6 matrix through --selftest, redirect-to-private,
the env var, the persisted toggle)
tls (self-signed refused, CA accepted, hostname mismatch refused)
cgi (401 on every action, open node, ?pwd= / header / Bearer, info, policy
round-trip, POST body, format=json as a real parameter)
ui (no CDN, no <script src=, CSP, embed rule, no emoji, no raw IP literal)
builds (ASan+UBSan and fortified runs of the same surface)
audit (full git-history secret / LAN-IP scan)
./plugin_fetch --selftest <addr> … prints <addr> denied=<0|1> per line and
reads stdin when given no arguments — pure policy, no DNS and no sockets, so
the SSRF matrix is asserted identically on a machine with no network.
Installed from Settings → Plugins or BotMarket, the binary lands in
~/.scorpiox/plugins/ (or /workspace/.scorpiox/plugins/ in BotCloud) and
sx-connector-mcp picks it up automatically: it appears as
connector_call → fetch. To wire it in by hand:
install -m 0755 plugin_fetch ~/.scorpiox/plugins/plugin_fetch
./plugin_fetch --meta # must print the one-line JSON
Policy lives in <connector dir>/fetch/config.json
(SX_CONNECTOR_DIR, else /workspace/.scorpiox/connectors/fetch,
~/.scorpiox/connectors/fetch, or %LOCALAPPDATA%\scorpiox\connectors\fetch).
| Variable | Effect |
|---|---|
FETCH_ALLOW_PRIVATE | unset/0 = enforce the denylist; anything else allows private ranges (test escape hatch) |
FETCH_TLS_CA_FILE | PEM bundle to trust instead of the system bundle |
SX_CONNECTOR_DIR | where the policy file lives |
BOT_PASSWORD | the node's password — gates every JSON action |
SX_PLUGIN_META | answered with the discovery line and exit |
modelcontextprotocol/servers src/fetch (Apache-2.0) and the readability subset in openclaw/openclaw extensions/web-readability
— reimplemented clean-room in C99, not translated line by line.
MIT © SCORPIOX INC.