
LionScraper MCP + CLI + HTTP API (Python)
io.github.dowant由 GitHub 账号 dowant 发布v1.0.6更新于 Oct 24, 2026
LionScraper Python: MCP stdio + CLI + HTTP API bridging AI to LionScraper browser extension.
概览
一个本地桥接服务,让 AI 助手通过 LionScraper 浏览器扩展从网页抓取列表、文章、链接、邮箱、电话和图片。
- 可以做什么
- 检查 LionScraper 浏览器扩展是否已在桥接端口上连接并注册(ping)。自动识别列表、表格等页面结构,并支持分页(scrape)。提取文章正文与元数据、邮箱地址、电话号码、超链接 URL 以及图片 URL 和基本信息。在 MCP 进程内提供静态指南资源和流程提示词,另有 CLI 和本机回环 HTTP API 调用同一批工具。
- 适用场景
- 当你想让助手从 Chrome 或 Edge 中已打开的页面提取结构化内容(如文章正文、联系方式、链接列表或图片库),并且希望由浏览器扩展而非无头爬虫完成抓取时使用。
- 运行要求
- 本机需 Python 3.10 或更高版本并安装 lionscraper 包,Chrome 或 Edge 中启用 LionScraper 扩展,以及支持 MCP 的 AI 应用。PORT 设置(默认 13808)必须与扩展的桥接端口一致;另有可选的 TIMEOUT、LANG、TOKEN 和 DAEMON 设置。
安装
在 SourceWeft 中
- 打开 控制台中的 LionScraper MCP + CLI + HTTP API (Python),将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
LionScraper MCP + CLI + API service (Python)
- Website: lionscraper.com
- PyPI: project
lionscraper
What is this?
LionScraper is a browser extension that can collect lists, articles, links, images, and more from web pages. This PyPI package provides the companion bridge to that extension in three ways:
- MCP (
lionscraper-mcp): connect your AI app (e.g. Cursor) so the model can call scraping tools in chat. - CLI (
lionscraper): run daemon, scrape, and ping from a terminal over the same local HTTP/WebSocket port as the extension. - HTTP API: call the same tools over loopback JSON HTTP (
/v1/...) when the daemon is running—useful for scripts, services, or any HTTP client without MCP or the CLI front-end.
The real scraping logic runs in the extension; this package connects and forwards.
Before you start
- Browser: Chrome or Edge (follow what the extension actually supports).
- LionScraper extension: Install and enable it from your browser’s store (the listing title may vary by storefront).
- Chrome: Chrome Web Store — LionScraper
- Microsoft Edge: Edge Add-ons — LionScraper
- Python: 3.10 or newer on your machine. If you do not have it yet, download an installer from the Python website and follow the prompts (check the option to add Python to
PATHon Windows if the installer offers it). - For MCP: an AI app that supports MCP (e.g. Cursor, Trae).
- For the HTTP API: same browser, extension, and daemon as the CLI; use
curl,fetch, or any HTTP client againsthttp://127.0.0.1:$PORT(see HTTP API (local REST) below).
This package uses aiohttp for outbound HTTP and WebSocket probes to the daemon. When Chrome/Edge are not detected and the extension is not connected, ping / scrape* can use a server-side HTTP fallback (no in-page JS).
Install (pip)
This package is published on PyPI as lionscraper.
You may use a virtual environment (recommended) or pip install -U --user lionscraper if you prefer not to install into the system interpreter.
You get two commands; together they support three integration styles (MCP, CLI, HTTP API):
If lionscraper-mcp is not on your PATH after install, use the full path to the script (e.g. under your venv’s Scripts/ or bin/), or the python -m lionscraper form below in MCP (still requires a normal pip install -U lionscraper).
MCP (AI applications)
Add MCP in your AI app
Examples assume lionscraper-mcp is on your PATH (UIs differ). In MCP JSON, every env value is a string.
Minimal config (omit env for built-in defaults; PORT defaults to 13808 and must match the extension bridge port):
Full env example (drop keys you do not need; empty strings behave like “unset” for most of these):
PORT: HTTP + WebSocket listen port; default 13808; must match the extension bridge port.TIMEOUT: Milliseconds to wait for a previous instance to release the port before forcing takeover; default 120000;0means force quickly.LANG: Tool descriptions and stderr log language (en-US,zh-CN, or POSIX forms likeen_US.UTF-8).TOKEN: Bearer token shared with the daemon; empty means noAuthorizationheader.DAEMON: Only0disables auto-spawninglionscraper daemonfrom thin MCP; empty or other values match omitting the key (auto-start allowed).
Restart MCP or the app so the config applies.
If lionscraper-mcp is not on PATH
After pip install -U lionscraper, you can run the same routing with python -m lionscraper: no arguments after the module name selects thin MCP over stdio; any extra argument (including --debug) uses the CLI instead. Example:
Use the same python executable you used to install the package (or python3 on some systems).
Match the port in the browser extension
- Open LionScraper settings / options.
- Set bridge port to the same value as
PORT(e.g.13808). - If needed, use Reconnect in the extension, or reload the extension / restart the browser.
Day-to-day use (MCP)
- Keep the extension enabled and target pages open as required.
- Ask in natural language, e.g. “Check if LionScraper is connected” or “Scrape lists / article / emails / phones / links / images from this page.”
- If you see not connected or timeout, retry a connection check and confirm PORT matches.
MCP tools (summary)
The server registers tools that mirror extension capabilities. Names and shapes are what your MCP client shows to the model.
Parameters: A full JSON schema for every field belongs in the tool definitions your client displays and in release-accurate docs; duplicating it here goes stale quickly. Use the tool list / descriptions in the AI app when calling MCP.
MCP Resources / Prompts
The thin MCP process (lionscraper-mcp) exposes Resources and Prompts in addition to Tools:
- Resources: static Markdown at stable URIs, e.g.
lionscraper://guide/connection(PORT alignment,pingtroubleshooting),lionscraper://guide/when-to-use-tools(prefer LionScraper over WebFetch/curl/wget by scenario),lionscraper://guide/cli(terminal CLI),lionscraper://reference/tools,lionscraper://reference/common-params. Clients list/read them into context; they are served inside the stdio process and do not require the daemon HTTP path (works even if the extension is offline). For the loopback HTTP control plane (/v1/...), see HTTP API (local REST) below (not an MCP resource URI). - Prompts: workflow templates (e.g. ping-then-scrape, multi-URL,
scrape_article,prefer_lionscraper_scraping, extension troubleshooting). Clients list/get prompts; UI varies by host (Cursor, Trae, …).
Copy follows LANG (e.g. zh-CN), same as tool metadata.
CLI (terminal)
The lionscraper command is the terminal front-end to the same stack as MCP: lionscraper daemon listens on PORT (default 13808) for HTTP (used by the CLI and by the thin lionscraper-mcp process) and WebSocket (used by the extension). Set PORT (and optional TOKEN) to match the extension bridge port and any MCP config. Use the CLI for scripts, CI, or quick one-off runs without opening an AI chat.
The CLI talks to the daemon HTTP API on http://127.0.0.1:$PORT (default port 13808, same as the extension). If you do not pass --api-url, a local daemon is auto-started when possible when you run scrape or ping.
Common commands:
--method selects which tool the daemon runs (default scrape): scrape, article, emails, phones, urls, images. Repeat -u / --url to pass several URLs in one run.
Set PORT (and optional TOKEN) in the environment so the CLI matches the extension and MCP. Use --api-url http://127.0.0.1:PORT if the daemon is not on the default base URL. Run lionscraper --help for every flag the binary accepts.
Scrape: parameters and richer examples
Below flags are forwarded to the extension (except --bridge-timeout-ms, which only caps how long the CLI waits on the bridge). Actual behavior still depends on the extension version.
Output and connection
Timing and load
Lazy-loaded / infinite scroll (maps to waitForScroll in the tool payload)
Locale
Extra payload
Method-specific filters (examples; see --help for the full set)
- Emails (
--method emails):--email-domain,--email-keyword,--email-limit - Phones (
--method phones):--phone-type,--phone-area-code,--phone-keyword,--phone-limit - URLs (
--method urls):--url-domain,--url-keyword,--url-pattern,--url-limit - Images (
--method images):--img-min-width,--img-min-height,--img-format,--img-keyword,--img-limit
Optional browser automation hints (when the extension supports them): --auto-launch-browser, --no-auto-launch-browser, --post-launch-wait-ms.
Example A — List / table scrape with pagination, delays, and scroll assist
--max-pages: stop after at most five “pages” of list accumulation for this job.--delay: give the page extra time after load before extraction.--timeout-ms/--bridge-timeout-ms: extension vs. CLI-side waits; raise both for slow sites or heavy pages.--wait-scroll-*: gentle scrolling so lazy-loaded rows can appear before scraping.-o/--format pretty: save a human-readable JSON file for inspection.
Example B — Article body with optional HTML snapshot
--method article: maps to thescrape_articletool (Markdown-style body + metadata when the extension provides it).--include-html true: requests additional HTML in the result meta where supported (larger payload).
Example C — Emails and URLs with filters, multiple pages
- Email flags: narrow to addresses in a domain, matching a keyword, and cap the count.
- Two
-uvalues: two URLs processed in one invocation;--scrape-intervalspaces out task starts.
Example D — Images with size / format filters
- Filters out small thumbnails and non-WebP assets when the extension honors these fields;
--img-limitcaps how many entries are returned.
HTTP API (local REST)
Base URL: http://127.0.0.1:$PORT (default 13808). Binds 127.0.0.1 only. The extension must be connected on that port and a daemon must be listening (same process model as the rest of this package).
Anything else → 404 { "ok": false, "error": { "code": "NOT_FOUND", "message": "Not found" } }.
Auth: If env TOKEN is set on the daemon, every request needs Authorization: Bearer <TOKEN>; otherwise omit the header.
POST /v1/tools/call
- Headers:
Content-Type: application/json. For streaming, alsoAccept: application/x-ndjson. - Body:
arguments (JSON keys)
ping only: optional lang ("en-US" | "zh-CN"), autoLaunchBrowser (boolean), postLaunchWaitMs (number, 3000–60000).
All scrape-family tools (scrape, scrape_article, scrape_emails, scrape_phones, scrape_urls, scrape_images) share:
Only scrape: optional maxPages (number, ≥ 1).
Optional filter object (only on the matching tool):
Unknown name, bad JSON, or schema violations → 400 { "code": "BAD_REQUEST", ... }. Bad bearer → 401 UNAUTHORIZED. Tool crash → 500 INTERNAL.
200 body: { "content": [ { "type": "text", "text": "..." } ], "isError"?: boolean }.
Examples (PORT=13808)
FAQ (plain language)
Q: Extension not connected or scraping fails?
- Extension enabled?
- PORT in MCP (or env for CLI) exactly matches the extension bridge port?
- Avoid multiple conflicting MCP/CLI setups on one machine.
Q: Many “tools” visible in the AI app—does that mean the extension is connected?
Not necessarily. Tools only confirm AI → MCP server; the extension must still connect on the same port and register.
Q: CLI says it cannot reach the daemon?
Start lionscraper daemon in another terminal, or fix PORT / --api-url.
Q: I want to drive scraping from my own HTTP client?
Keep the daemon and extension on the same PORT, then POST /v1/tools/call with name and arguments as in HTTP API (local REST). GET /v1/health checks that the listener is LionScraper.
License
MIT (same as the lionscraper package on PyPI).
来源:packages/python/README.md,提交 9889add
工具
0版本历史
1- v1.0.6最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分