foxfetch 0.1.7__tar.gz → 0.1.8__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  # Install
2
2
 
3
- > The same content lives in [README.md](README.md) (English) and [README.zh.md](README.zh.md)
4
- > (简体中文), which is what most people want. This file is the longer reference: it keeps the
3
+ > The same content lives in [README.md](README.md) (简体中文, the default) and
4
+ > [README.en.md](README.en.md) (English), which is what most people want. This file is the longer reference: it keeps the
5
5
  > doctor output, the interpreter-path note and the troubleshooting table in one place.
6
6
 
7
7
  Two pieces, always two:
@@ -0,0 +1,380 @@
1
+ Metadata-Version: 2.5
2
+ Name: foxfetch
3
+ Version: 0.1.8
4
+ Summary: Fetch pages through a real Firefox engine (ruyijs) for AI agents: pass bot checks, run the page's own JavaScript, then hand the identity to Chromium when a screenshot is needed.
5
+ Project-URL: Homepage, https://github.com/zhuchongba-01/foxfetch
6
+ Project-URL: Repository, https://github.com/zhuchongba-01/foxfetch
7
+ Project-URL: Issues, https://github.com/zhuchongba-01/foxfetch/issues
8
+ Project-URL: Changelog, https://github.com/zhuchongba-01/foxfetch/commits/master
9
+ License: MIT License
10
+
11
+ Copyright (c) 2026 foxfetch contributors
12
+
13
+ Permission is hereby granted, free of charge, to any person obtaining a copy
14
+ of this software and associated documentation files (the "Software"), to deal
15
+ in the Software without restriction, including without limitation the rights
16
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
+ copies of the Software, and to permit persons to whom the Software is
18
+ furnished to do so, subject to the following conditions:
19
+
20
+ The above copyright notice and this permission notice shall be included in all
21
+ copies or substantial portions of the Software.
22
+
23
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
+ SOFTWARE.
30
+
31
+ Note: `ruyijs`, the Firefox engine this package drives, is a separate project
32
+ under AGPL-3.0. foxfetch only imports and calls it; no ruyijs code is bundled.
33
+ License-File: LICENSE
34
+ Keywords: agent,anti-bot,firefox,mcp,playwright,ruyijs,scraping
35
+ Classifier: Environment :: Console
36
+ Classifier: Intended Audience :: Developers
37
+ Classifier: License :: OSI Approved :: MIT License
38
+ Classifier: Operating System :: Microsoft :: Windows
39
+ Classifier: Operating System :: POSIX :: Linux
40
+ Classifier: Programming Language :: Python :: 3
41
+ Classifier: Topic :: Internet :: WWW/HTTP :: Browsers
42
+ Requires-Python: >=3.10
43
+ Requires-Dist: mcp<2,>=1.30
44
+ Requires-Dist: ruyijs>=0.4.5
45
+ Provides-Extra: dev
46
+ Requires-Dist: mypy>=1.10; extra == 'dev'
47
+ Requires-Dist: pytest>=8; extra == 'dev'
48
+ Description-Content-Type: text/markdown
49
+
50
+ # foxfetch
51
+
52
+ **普通 HTTP 抓不到的页面,用真 Firefox 引擎跑一遍再读。**
53
+
54
+ [简体中文](README.md) · [English](README.en.md)
55
+
56
+ [![PyPI](https://img.shields.io/pypi/v/foxfetch?logo=pypi&label=PyPI)](https://pypi.org/project/foxfetch/)
57
+ [![Python](https://img.shields.io/pypi/pyversions/foxfetch?logo=python&logoColor=white)](https://pypi.org/project/foxfetch/)
58
+ [![npm plugin](https://img.shields.io/npm/v/dsh-foxfetch?logo=npm&label=dsh-foxfetch)](https://www.npmjs.com/package/dsh-foxfetch)
59
+ [![License](https://img.shields.io/pypi/l/foxfetch)](LICENSE)
60
+
61
+ 在真 Firefox 引擎里跑页面,用来过风控;需要截图时把身份交给 Chromium。
62
+
63
+ ## 安装
64
+
65
+ ```bash
66
+ pip install foxfetch
67
+ ```
68
+
69
+ **DSH(DeepSeek Harness)安装指令:**
70
+
71
+ ```powershell
72
+ cd "$env:USERPROFILE\.dsh\profiles\desktop"
73
+ pnpm add dsh-foxfetch
74
+ ```
75
+
76
+ 再把 `"dsh-foxfetch"` 加进该目录 `package.json` 的 `dsh.profile.bundles`,重启 DSH。
77
+
78
+ **其余软件安装指令:**
79
+
80
+ ```bash
81
+ pi mcp add foxfetch -- python -m foxfetch serve # Pi
82
+ claude mcp add foxfetch -- python -m foxfetch serve # Claude Code
83
+ ```
84
+
85
+ Codex 和其它 MCP 客户端只写配置、不装包,见[下文](#详细安装)。
86
+
87
+ ## 验证
88
+
89
+ ```bash
90
+ python -m foxfetch doctor # 应输出 "ok": true
91
+ ```
92
+
93
+ 然后让你的 agent 调用:
94
+
95
+ ```
96
+ foxfetch_run(js="navigator.userAgent", url="https://example.com")
97
+ ```
98
+
99
+ 答案里必须出现 `Firefox/160.0`。如果出现 `Python-urllib` 或 `HeadlessChrome`,说明 agent 没连上
100
+ 引擎 —— 这个问题不解决,后面全是假的。
101
+
102
+ > **一个宿主只装一个入口。** 同一个 agent 里不要既加 MCP 条目又装 DSH 插件,否则会出现两套
103
+ > 同样的 7 个工具(`foxfetch_run` 和 `mcp__foxfetch__run`)。
104
+
105
+ ## 为什么需要它
106
+
107
+ `curl` 拿回来 403,无头 Chrome 被指纹识别拦掉。foxfetch 在**真 Firefox 引擎**(SpiderMonkey +
108
+ Necko,无窗口、不渲染)里执行站点自己的 JavaScript,所以 TLS 握手和 JS 环境都是真浏览器的,
109
+ 而且这个环境在调用之间保持存活。需要截图或点击时,`handoff` 把挣到的身份导出来,交给 Chromium
110
+ 完成剩下的活。
111
+
112
+ ## 详细安装
113
+
114
+ ### 前置要求
115
+
116
+ 这里涉及**两个平台**,注意区分:
117
+
118
+ - **服务** —— 一个 Python 包,`pip install foxfetch`,所有宿主共用。
119
+ - **宿主入口** —— 各家机制不同:Pi / Claude Code / Codex 是 MCP 配置条目,DSH 是 npm 插件。
120
+
121
+ - **Python 3.10+** —— 就这一条。Chromium 是可选的(只有截图才需要)。
122
+ - 引擎 `ruyijs`(44 MB 的 wheel)会作为依赖自动装上。
123
+
124
+ `doctor` 报错时,直接跑它给出的命令。实际会遇到的三种:
125
+
126
+ | `doctor` 说 | 修复 |
127
+ |---|---|
128
+ | `ruyijs` 缺失或 `< 0.4.5` | `pip install -U "ruyijs>=0.4.5"` |
129
+ | `mcp` 是 2.x | `pip install "mcp>=1.30,<2"` —— 2.x 把 `FastMCP` 改名了,本服务 import 不到 |
130
+ | `chromium: found: false` | 可选:`npx playwright install chromium` |
131
+
132
+ **用哪个 Python?** agent 必须启动**和 `pip install` 同一个**解释器:
133
+
134
+ ```powershell
135
+ (Get-Command python).Source # Windows
136
+ which python3 # macOS / Linux
137
+ ```
138
+
139
+ ```bash
140
+ # 如果不是纯 `python`,配置里写绝对路径:
141
+ # "command": "C:/Users/you/AppData/Local/Programs/Python/Python314/python.exe"
142
+ ```
143
+
144
+ ### Pi
145
+
146
+ 命令行一条搞定:
147
+
148
+ ```bash
149
+ pi mcp add foxfetch -- python -m foxfetch serve
150
+ ```
151
+
152
+ 或者自己写 `~/.pi/agent/mcp.json`:
153
+
154
+ ```json
155
+ {
156
+ "mcpServers": {
157
+ "foxfetch": {
158
+ "command": "python",
159
+ "args": ["-m", "foxfetch", "serve"],
160
+ "timeout": 180
161
+ }
162
+ }
163
+ }
164
+ ```
165
+
166
+ 验证:`pi mcp list` → 应该显示 `foxfetch: connected, 7 tools`。
167
+ 已经在跑的 Pi 会话里,输入 `/reload` 即可加载。
168
+
169
+ ### Claude Code
170
+
171
+ ```bash
172
+ claude mcp add foxfetch -- python -m foxfetch serve
173
+ claude mcp list
174
+ ```
175
+
176
+ ### Codex
177
+
178
+ 把这段追加到 `~/.codex/config.toml`,然后重启 Codex:
179
+
180
+ ```toml
181
+ [mcp_servers.foxfetch]
182
+ command = "python"
183
+ args = ["-m", "foxfetch", "serve"]
184
+ ```
185
+
186
+ ### DeepSeek Harness
187
+
188
+ DSH 有原生插件机制,所以给它装插件而不是 MCP 条目。插件里**没有任何逻辑** —— 它启动同一个
189
+ Python 服务,只负责把结果整理成 DSH 的卡片样式。
190
+
191
+ > **DSH 要装两样,不是一样**:服务(`pip`,第 1 步)**加上**插件(npm)。
192
+ > 插件只是转发壳,没有服务会立刻报 `cannot start the Python service`。
193
+
194
+ ```powershell
195
+ # 1. 服务(和别的宿主一样 —— 这步不能跳)
196
+ pip install foxfetch
197
+
198
+ # 2. 插件,装进 DSH 的 profile
199
+ cd "$env:USERPROFILE\.dsh\profiles\desktop"
200
+ pnpm add dsh-foxfetch
201
+
202
+ # 3. 登记(保留文件里已有的条目)
203
+ $pkg = Get-Content package.json -Raw | ConvertFrom-Json
204
+ if ($pkg.dsh.profile.bundles -notcontains "dsh-foxfetch") {
205
+ $pkg.dsh.profile.bundles += "dsh-foxfetch"
206
+ }
207
+ $pkg | ConvertTo-Json -Depth 20 | Set-Content package.json
208
+
209
+ # 4. 重启 DSH
210
+ ```
211
+
212
+ 改完 `package.json` 应该长这样:
213
+
214
+ ```json
215
+ {
216
+ "name": "dsh-profile-desktop",
217
+ "private": true,
218
+ "dependencies": {
219
+ "dsh-foxfetch": "^0.1.1"
220
+ },
221
+ "dsh": {
222
+ "profile": {
223
+ "bundles": [
224
+ "@deepseek-ai/dsh-base",
225
+ "@deepseek-ai/dsh-web-app",
226
+ "dsh-foxfetch"
227
+ ]
228
+ }
229
+ }
230
+ }
231
+ ```
232
+
233
+ **`pnpm` 不在 PATH 里?** DSH 自带一份:
234
+
235
+ ```powershell
236
+ $dsh = "$env:USERPROFILE\.dsh\dsh-runtimes\dsh-primary-runtime\dependencies"
237
+ $node = Join-Path $dsh "node\bin\node.exe"
238
+ $pnpm = Join-Path $dsh "pnpm\bin\pnpm.cjs"
239
+ & $node $pnpm add dsh-foxfetch
240
+ ```
241
+
242
+ 重启 DSH 后工具列表里应该有 `foxfetch_probe`、`foxfetch_run`、`foxfetch_net`、
243
+ `foxfetch_handoff`、`foxfetch_close`、`foxfetch_cleanup`、`foxfetch_status` —— 并且**没有**
244
+ `mcp__foxfetch__*` 这种重复条目。
245
+
246
+ ### 其它 MCP 客户端
247
+
248
+ 大多数客户端吃同一段 stdio 配置:
249
+
250
+ ```json
251
+ {
252
+ "mcpServers": {
253
+ "foxfetch": {
254
+ "command": "python",
255
+ "args": ["-m", "foxfetch", "serve"]
256
+ }
257
+ }
258
+ }
259
+ ```
260
+
261
+ ---
262
+
263
+ ## 你会得到什么
264
+
265
+ 七个工具:
266
+
267
+ | 工具 | 作用 |
268
+ |---|---|
269
+ | `probe` | 判断一个 URL 该走哪一层:`plain_http` / `needs_engine` / `blocked`,**附判据** |
270
+ | `run` | 在引擎里执行 JS,返回结果 + console + 请求日志 |
271
+ | `net` | 读当前上下文的请求日志和 console,不发新请求 |
272
+ | `handoff` | 导出 cookie(含 HttpOnly)、localStorage、UA,并生成 Playwright 脚本 |
273
+ | `close` | 关掉某个上下文(按 id 或 origin),或全关 |
274
+ | `cleanup` | 删产物、关上下文、扫临时目录 |
275
+ | `status` | 活着的上下文、产物占用、环境自检 |
276
+
277
+ ### 用最便宜的那一层
278
+
279
+ | 情况 | 用什么 |
280
+ |---|---|
281
+ | 静态 HTML、JSON 接口、RSS | 普通 HTTP —— **别调 foxfetch** |
282
+ | 内容要等 JS 跑完才出现 | `run` |
283
+ | 403 / Cloudflare / DataDome / Kasada | 先 `probe`,再 `run` |
284
+ | 有人需要**看到**页面 | `handoff` → 生成的 Playwright 脚本 |
285
+
286
+ ```
287
+ probe("https://shop.example/item")
288
+ → verdict: blocked
289
+ evidence: HTTP 403, DataDome(命中 'datadome'), 512 字节, 可见文本 0
290
+ suggestion: 用 run —— 引擎的 TLS 与 JS 指纹跟真 Firefox 一致
291
+ ```
292
+
293
+ 引擎每次开页面要 ~90 MB 内存、~3 秒。如果 `curl` 就能拿到的页面,用它纯属浪费 —— 这就是
294
+ `probe` 存在的原因。
295
+
296
+ ### 上下文保持
297
+
298
+ 一个 origin 一个引擎世界,调用之间保持存活,所以多步流程是若干小调用,而不是一个巨型脚本:
299
+
300
+ ```python
301
+ run("window.step = 1", url="https://x.test") # 打开页面
302
+ run("window.step + 1") # → 2,同一个文档
303
+ run("fetch('/api/me').then(r => r.text())",
304
+ advance_ms=800, read="window.__last") # 带上前面挣到的 cookie
305
+ ```
306
+
307
+ 上下文会在这些情况下消失:`close`、静默超过 `FOXFETCH_IDLE_SECONDS`(默认 60 秒)、
308
+ 池子超过 `FOXFETCH_MAX_CONTEXTS`(默认 2 个,淘汰最久未用的)。
309
+
310
+ ---
311
+
312
+ ## 配置项
313
+
314
+ | 环境变量 | 默认值 | 含义 |
315
+ |---|---|---|
316
+ | `FOXFETCH_HOME` | `%LOCALAPPDATA%\foxfetch` | 产物目录(凭据会经过它) |
317
+ | `FOXFETCH_MAX_CONTEXTS` | 2 | 存活上下文上限,超了淘汰最久未用 |
318
+ | `FOXFETCH_IDLE_SECONDS` | 60 | 静默多久杀掉上下文 |
319
+ | `FOXFETCH_TIMEOUT_MS` | 30000 | 默认导航预算 |
320
+ | `FOXFETCH_MAX_BYTES` | 65536 | 输出上限,超了落盘 |
321
+ | `FOXFETCH_ARTIFACT_TTL` | 86400 | 产物自动过期的秒数 |
322
+ | `FOXFETCH_ARTIFACT_MAX` | 67108864 | 产物目录字节预算 |
323
+ | `FOXFETCH_REMIND_AFTER` | 600 | 超过多少秒开始提醒清理(0 = 关闭) |
324
+ | `FOXFETCH_PY` | — | DSH 插件启动用的解释器 |
325
+
326
+ ## 安全
327
+
328
+ `handoff` 写出的是**活的凭据** —— 包括页面 JS 读不到的 HttpOnly cookie。它们落在
329
+ `FOXFETCH_HOME` 下,权限仅本人可读,超过 `FOXFETCH_ARTIFACT_TTL` 自动删除。
330
+
331
+ 每次工具返回都会报告磁盘上还留着什么;某个文件超过 `FOXFETCH_REMIND_AFTER` 后,返回里会多出
332
+ 一个 `reminder`,叫 agent 调 `cleanup`,并用 `keep=[...]` 保住用户还要看的东西。跑完 cleanup
333
+ 这个字段立刻消失 —— 所以**残留的提醒就是明确的 bug**,不会静默发生。
334
+
335
+ ## 它不做什么
336
+
337
+ - 不截图、不点击、不排版 —— 那些交给 Chromium,前提是拿到 `handoff` 导出的身份。
338
+ - 不保存会话:每个上下文都是全新的,`close` 之后什么都不剩。
339
+ - 不做指纹随机化:随便猜一个和谁都不像的配置,比直接冒充真 Firefox 更容易被识别。
340
+
341
+ ## 开发
342
+
343
+ ```bash
344
+ pip install -e '.[dev]'
345
+ pytest -q # 45 个测试,不联网
346
+ mypy src # strict
347
+ ```
348
+
349
+ ```bash
350
+ # github.com:443 被重置但 api.github.com 通的时候,用 API 推送
351
+ python tools/push_via_api.py --repo <owner>/<name> --dry-run
352
+ ```
353
+
354
+ 测试里固化的就是这次重写要防的坑:按字节截断中文出 `�`、URL 尾斜杠比较不匹配、
355
+ `sameSite: "Default"` 被 Playwright 拒绝、`cleanup` 只删过期文件、截图抛异常时留下孤儿浏览器。
356
+
357
+ ## 排错
358
+
359
+ | 症状 | 原因 | 修法 |
360
+ |---|---|---|
361
+ | `cannot start the Python service`(DSH) | 插件找到了另一个解释器 | 把 `FOXFETCH_PY` 设成绝对路径 |
362
+ | `ModuleNotFoundError: mcp.server.fastmcp` | 装了 `mcp` 2.x | `pip install "mcp>=1.30,<2"` |
363
+ | `no live context for that origin` | 上下文空闲超时(60 秒)或被淘汰 | 再传一次 `url`,或保留 `context_id` |
364
+ | `navigation produced an empty document` | 页面慢,或需要真渲染器 | 调大 `timeout_ms`,或走 `handoff` + Chromium |
365
+ | 工具出现两遍 | 同一个宿主装了两个入口 | 删掉一个 |
366
+ | `pip install` 下到一半断 | 到 `files.pythonhosted.org` 的网络不稳 | 重试,或 `pip install --proxy http://127.0.0.1:7897 foxfetch` |
367
+
368
+ ## 卸载
369
+
370
+ ```bash
371
+ pip uninstall foxfetch
372
+ ```
373
+
374
+ 产物目录:Windows 是 `%LOCALAPPDATA%\foxfetch`,其他平台是 `~/.local/share/foxfetch`。
375
+ 然后删掉宿主里的入口 —— `mcpServers` 那段、`[mcp_servers.foxfetch]` 那个表,或者
376
+ `dsh-foxfetch` 依赖加 bundles 里那一行。
377
+
378
+ ## 许可
379
+
380
+ MIT。引擎 `ruyijs` 是另一个项目,AGPL-3.0;foxfetch 只是调用它,不包含任何 ruyijs 代码。
@@ -2,7 +2,7 @@
2
2
 
3
3
  **Read pages that block plain HTTP — by running them in a real Firefox engine.**
4
4
 
5
- [English](README.md) · [简体中文](README.zh.md)
5
+ [简体中文](README.md) · [English](README.en.md)
6
6
 
7
7
  [![PyPI](https://img.shields.io/pypi/v/foxfetch?logo=pypi&label=PyPI)](https://pypi.org/project/foxfetch/)
8
8
  [![Python](https://img.shields.io/pypi/pyversions/foxfetch?logo=python&logoColor=white)](https://pypi.org/project/foxfetch/)
@@ -2,7 +2,7 @@
2
2
 
3
3
  **普通 HTTP 抓不到的页面,用真 Firefox 引擎跑一遍再读。**
4
4
 
5
- [English](README.md) · [简体中文](README.zh.md)
5
+ [简体中文](README.md) · [English](README.en.md)
6
6
 
7
7
  [![PyPI](https://img.shields.io/pypi/v/foxfetch?logo=pypi&label=PyPI)](https://pypi.org/project/foxfetch/)
8
8
  [![Python](https://img.shields.io/pypi/pyversions/foxfetch?logo=python&logoColor=white)](https://pypi.org/project/foxfetch/)
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "foxfetch"
7
- version = "0.1.7"
7
+ version = "0.1.8"
8
8
  description = "Fetch pages through a real Firefox engine (ruyijs) for AI agents: pass bot checks, run the page's own JavaScript, then hand the identity to Chromium when a screenshot is needed."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -42,7 +42,7 @@ foxfetch = "foxfetch.cli:main"
42
42
  include = [
43
43
  "src/foxfetch",
44
44
  "README.md",
45
- "README.zh.md",
45
+ "README.en.md",
46
46
  "INSTALL.md",
47
47
  ]
48
48
 
@@ -1,5 +1,5 @@
1
1
  """foxfetch: read pages through a real Firefox engine when plain HTTP is not enough."""
2
2
 
3
- __version__ = "0.1.7"
3
+ __version__ = "0.1.8"
4
4
 
5
5
  __all__ = ["__version__"]
foxfetch-0.1.7/PKG-INFO DELETED
@@ -1,386 +0,0 @@
1
- Metadata-Version: 2.5
2
- Name: foxfetch
3
- Version: 0.1.7
4
- Summary: Fetch pages through a real Firefox engine (ruyijs) for AI agents: pass bot checks, run the page's own JavaScript, then hand the identity to Chromium when a screenshot is needed.
5
- Project-URL: Homepage, https://github.com/zhuchongba-01/foxfetch
6
- Project-URL: Repository, https://github.com/zhuchongba-01/foxfetch
7
- Project-URL: Issues, https://github.com/zhuchongba-01/foxfetch/issues
8
- Project-URL: Changelog, https://github.com/zhuchongba-01/foxfetch/commits/master
9
- License: MIT License
10
-
11
- Copyright (c) 2026 foxfetch contributors
12
-
13
- Permission is hereby granted, free of charge, to any person obtaining a copy
14
- of this software and associated documentation files (the "Software"), to deal
15
- in the Software without restriction, including without limitation the rights
16
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
- copies of the Software, and to permit persons to whom the Software is
18
- furnished to do so, subject to the following conditions:
19
-
20
- The above copyright notice and this permission notice shall be included in all
21
- copies or substantial portions of the Software.
22
-
23
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
- SOFTWARE.
30
-
31
- Note: `ruyijs`, the Firefox engine this package drives, is a separate project
32
- under AGPL-3.0. foxfetch only imports and calls it; no ruyijs code is bundled.
33
- License-File: LICENSE
34
- Keywords: agent,anti-bot,firefox,mcp,playwright,ruyijs,scraping
35
- Classifier: Environment :: Console
36
- Classifier: Intended Audience :: Developers
37
- Classifier: License :: OSI Approved :: MIT License
38
- Classifier: Operating System :: Microsoft :: Windows
39
- Classifier: Operating System :: POSIX :: Linux
40
- Classifier: Programming Language :: Python :: 3
41
- Classifier: Topic :: Internet :: WWW/HTTP :: Browsers
42
- Requires-Python: >=3.10
43
- Requires-Dist: mcp<2,>=1.30
44
- Requires-Dist: ruyijs>=0.4.5
45
- Provides-Extra: dev
46
- Requires-Dist: mypy>=1.10; extra == 'dev'
47
- Requires-Dist: pytest>=8; extra == 'dev'
48
- Description-Content-Type: text/markdown
49
-
50
- # foxfetch
51
-
52
- **Read pages that block plain HTTP — by running them in a real Firefox engine.**
53
-
54
- [English](README.md) · [简体中文](README.zh.md)
55
-
56
- [![PyPI](https://img.shields.io/pypi/v/foxfetch?logo=pypi&label=PyPI)](https://pypi.org/project/foxfetch/)
57
- [![Python](https://img.shields.io/pypi/pyversions/foxfetch?logo=python&logoColor=white)](https://pypi.org/project/foxfetch/)
58
- [![npm plugin](https://img.shields.io/npm/v/dsh-foxfetch?logo=npm&label=dsh-foxfetch)](https://www.npmjs.com/package/dsh-foxfetch)
59
- [![License](https://img.shields.io/pypi/l/foxfetch)](LICENSE)
60
-
61
- Runs a page in a real Firefox engine to get past bot checks, then hands the identity to Chromium
62
- when a screenshot is needed.
63
-
64
- ## Install
65
-
66
- ```bash
67
- pip install foxfetch
68
- ```
69
-
70
- **DSH (DeepSeek Harness) install command:**
71
-
72
- ```powershell
73
- cd "$env:USERPROFILE\.dsh\profiles\desktop"
74
- pnpm add dsh-foxfetch
75
- ```
76
-
77
- Then add `"dsh-foxfetch"` to `dsh.profile.bundles` in that folder's `package.json` and restart
78
- DSH.
79
-
80
- **Everything else install command:**
81
-
82
- ```bash
83
- pi mcp add foxfetch -- python -m foxfetch serve # Pi
84
- claude mcp add foxfetch -- python -m foxfetch serve # Claude Code
85
- ```
86
-
87
- Codex and other MCP clients need config only, no package — see [below](#detailed-install).
88
-
89
- ## Verify
90
-
91
- ```bash
92
- python -m foxfetch doctor # expect "ok": true
93
- ```
94
-
95
- Then ask your agent:
96
-
97
- ```
98
- foxfetch_run(js="navigator.userAgent", url="https://example.com")
99
- ```
100
-
101
- It must answer with `Firefox/160.0`. If it says `Python-urllib` or `HeadlessChrome`, the agent is
102
- not reaching the engine — nothing else will work until that is fixed.
103
-
104
- > **One entry per host.** Never add both an MCP entry and the DSH plugin to the same agent: you
105
- > would get the same seven tools twice (`foxfetch_run` and `mcp__foxfetch__run`).
106
-
107
- ## Why this exists
108
-
109
- `curl` gets a 403. Headless Chrome gets fingerprinted. foxfetch runs the site's own JavaScript in
110
- a real Firefox engine (SpiderMonkey + Necko, no window, no renderer), so the TLS handshake and
111
- the JS environment are those of a real browser — and it keeps that world alive between calls.
112
- When a screenshot or a click is needed, `handoff` exports the identity it earned so Chromium can
113
- finish the job.
114
-
115
- ## Detailed install
116
-
117
- ### Requirements
118
-
119
- There are two platforms involved, and it matters:
120
-
121
- - **the service** — one Python package, `pip install foxfetch`, shared by every host.
122
- - **the host entry** — a different mechanism per host: an MCP config entry for Pi / Claude
123
- Code / Codex, an npm plugin for DSH.
124
-
125
- - **Python 3.10+** — that is all. Chromium is optional (screenshots only).
126
- - The `ruyijs` engine (44 MB wheel) comes in automatically as a dependency.
127
-
128
- If `doctor` reports a problem, run the command it prints. The three that happen:
129
-
130
- | `doctor` says | Fix |
131
- |---|---|
132
- | `ruyijs` missing or `< 0.4.5` | `pip install -U "ruyijs>=0.4.5"` |
133
- | `mcp` is 2.x | `pip install "mcp>=1.30,<2"` — 2.x renamed `FastMCP`; this server cannot import it |
134
- | `chromium: found: false` | optional: `npx playwright install chromium` |
135
-
136
- **Which Python?** The agent must start the same interpreter that `pip install` used:
137
-
138
- ```powershell
139
- (Get-Command python).Source # Windows
140
- which python3 # macOS / Linux
141
- ```
142
-
143
- ```bash
144
- # If it is not plain `python`, put the absolute path in the config:
145
- # "command": "C:/Users/you/AppData/Local/Programs/Python/Python314/python.exe"
146
- ```
147
-
148
- ### Pi
149
-
150
- `pi mcp add foxfetch -- python -m foxfetch serve`
151
-
152
- Or write `~/.pi/agent/mcp.json` yourself:
153
-
154
- ```json
155
- {
156
- "mcpServers": {
157
- "foxfetch": {
158
- "command": "python",
159
- "args": ["-m", "foxfetch", "serve"],
160
- "timeout": 180
161
- }
162
- }
163
- }
164
- ```
165
-
166
- Verify: `pi mcp list` → `foxfetch: connected, 7 tools`.
167
- Inside a running Pi session, `/reload` picks it up.
168
-
169
- ### Claude Code
170
-
171
- `claude mcp add foxfetch -- python -m foxfetch serve`
172
-
173
- Verify: `claude mcp list`.
174
-
175
- ### Codex
176
-
177
- Append to `~/.codex/config.toml`, then restart Codex:
178
-
179
- ```toml
180
- [mcp_servers.foxfetch]
181
- command = "python"
182
- args = ["-m", "foxfetch", "serve"]
183
- ```
184
-
185
- ### DeepSeek Harness
186
-
187
- DSH has a native plugin API, so it gets a real plugin instead of an MCP entry. The plugin holds
188
- no logic — it starts the same Python service and reshapes results for the DSH UI.
189
-
190
- > **DSH needs two installs, not one:** the service (`pip`, step 1) **and** the plugin (npm).
191
- > The plugin is only a forwarder; without the service it fails immediately with
192
- > `cannot start the Python service`.
193
-
194
- ```powershell
195
- # 1. service (same as everyone else — do not skip this)
196
- pip install foxfetch
197
-
198
- # 2. plugin, into the DSH profile
199
- cd "$env:USERPROFILE\.dsh\profiles\desktop"
200
- pnpm add dsh-foxfetch
201
-
202
- # 3. register it (keep the entries already in the file)
203
- $pkg = Get-Content package.json -Raw | ConvertFrom-Json
204
- if ($pkg.dsh.profile.bundles -notcontains "dsh-foxfetch") {
205
- $pkg.dsh.profile.bundles += "dsh-foxfetch"
206
- }
207
- $pkg | ConvertTo-Json -Depth 20 | Set-Content package.json
208
-
209
- # 4. restart DSH
210
- ```
211
-
212
- The result should look like this:
213
-
214
- ```json
215
- {
216
- "name": "dsh-profile-desktop",
217
- "private": true,
218
- "dependencies": {
219
- "dsh-foxfetch": "^0.1.1"
220
- },
221
- "dsh": {
222
- "profile": {
223
- "bundles": [
224
- "@deepseek-ai/dsh-base",
225
- "@deepseek-ai/dsh-web-app",
226
- "dsh-foxfetch"
227
- ]
228
- }
229
- }
230
- }
231
- ```
232
-
233
- `pnpm` not on PATH? DSH ships its own:
234
-
235
- ```powershell
236
- $dsh = "$env:USERPROFILE\.dsh\dsh-runtimes\dsh-primary-runtime\dependencies"
237
- $node = Join-Path $dsh "node\bin\node.exe"
238
- $pnpm = Join-Path $dsh "pnpm\bin\pnpm.cjs"
239
- & $node $pnpm add dsh-foxfetch
240
- ```
241
-
242
- After restarting DSH the tool list shows `foxfetch_probe`, `foxfetch_run`, `foxfetch_net`,
243
- `foxfetch_handoff`, `foxfetch_close`, `foxfetch_cleanup`, `foxfetch_status` — and no
244
- `mcp__foxfetch__*` entries.
245
-
246
- ### Any other MCP client
247
-
248
- Most clients take the same stdio block:
249
-
250
- ```json
251
- {
252
- "mcpServers": {
253
- "foxfetch": {
254
- "command": "python",
255
- "args": ["-m", "foxfetch", "serve"]
256
- }
257
- }
258
- }
259
- ```
260
-
261
- ---
262
-
263
- ## What you get
264
-
265
- Seven tools:
266
-
267
- | Tool | What it does |
268
- |---|---|
269
- | `probe` | Classify a URL — `plain_http` / `needs_engine` / `blocked` — with the evidence |
270
- | `run` | Evaluate JavaScript in the engine; returns the value, console and request log |
271
- | `net` | Read the request log and console of a live context |
272
- | `handoff` | Export cookies (incl. HttpOnly), localStorage, UA; write a Playwright script |
273
- | `close` | Close one context (by id or origin) or all of them |
274
- | `cleanup` | Delete artifacts, close contexts, sweep temp scratch dirs |
275
- | `status` | Live contexts, artifact usage, environment check |
276
-
277
- ### Use the cheapest layer
278
-
279
- | Situation | Use |
280
- |---|---|
281
- | Static HTML, JSON endpoints, RSS | plain HTTP — **do not call foxfetch** |
282
- | Content appears only after JS runs | `run` |
283
- | 403 / Cloudflare / DataDome / Kasada | `probe`, then `run` |
284
- | Someone needs to *see* the page | `handoff` → the generated Playwright script |
285
-
286
- ```
287
- probe("https://shop.example/item")
288
- → verdict: blocked
289
- evidence: HTTP 403, DataDome (matched 'datadome'), 512 bytes, 0 visible text
290
- suggestion: use run — the engine's TLS and JS profile match a real Firefox
291
- ```
292
-
293
- The engine costs ~90 MB of RAM and ~3 s per open. On a page `curl` could have fetched, that buys
294
- nothing — hence `probe`.
295
-
296
- ### Contexts
297
-
298
- One engine world per origin, kept alive between calls, so a multi-step flow is several small
299
- calls instead of one giant script:
300
-
301
- ```python
302
- run("window.step = 1", url="https://x.test") # opens the page
303
- run("window.step + 1") # → 2, same document
304
- run("fetch('/api/me').then(r => r.text())",
305
- advance_ms=800, read="window.__last") # carries the cookies earned above
306
- ```
307
-
308
- A context dies on `close`, after `FOXFETCH_IDLE_SECONDS` (default 60) of silence, or when the pool
309
- exceeds `FOXFETCH_MAX_CONTEXTS` (default 2) — least recently used first.
310
-
311
- ---
312
-
313
- ## Configuration
314
-
315
- | Variable | Default | Meaning |
316
- |---|---|---|
317
- | `FOXFETCH_HOME` | `%LOCALAPPDATA%\foxfetch` | Artifact root (credentials pass through it) |
318
- | `FOXFETCH_MAX_CONTEXTS` | 2 | Live contexts before LRU eviction |
319
- | `FOXFETCH_IDLE_SECONDS` | 60 | Silence before a context is killed |
320
- | `FOXFETCH_TIMEOUT_MS` | 30000 | Default navigation budget |
321
- | `FOXFETCH_MAX_BYTES` | 65536 | Output cap before spilling to a file |
322
- | `FOXFETCH_ARTIFACT_TTL` | 86400 | Seconds before an artifact is deleted |
323
- | `FOXFETCH_ARTIFACT_MAX` | 67108864 | Artifact directory byte budget |
324
- | `FOXFETCH_REMIND_AFTER` | 600 | Seconds before responses start reminding about pending artifacts (0 disables) |
325
- | `FOXFETCH_PY` | — | Interpreter the DSH plugin starts |
326
-
327
- ## Safety
328
-
329
- `handoff` writes **live credentials** — cookies including the HttpOnly ones page script cannot
330
- read. They land under `FOXFETCH_HOME`, owner-only, and expire after `FOXFETCH_ARTIFACT_TTL`.
331
-
332
- Every tool response reports what is still on disk, and once a file is older than
333
- `FOXFETCH_REMIND_AFTER` the response grows a `reminder` telling the agent to call `cleanup` and to
334
- pass `keep=[...]` for anything the user still needs to look at. The field disappears the moment
335
- cleanup runs, so a stale reminder is a visible bug rather than a silent one.
336
-
337
- ## What it is not
338
-
339
- - Not a screenshot tool, not a clicker, not a layout engine — Chromium does that, once it has the
340
- identity `handoff` exported.
341
- - Not a session store: every context is fresh, nothing survives `close`.
342
- - Not a fingerprint randomiser: guessing a profile that matches nobody is worse than sending a
343
- real Firefox.
344
-
345
- ## Development
346
-
347
- ```bash
348
- pip install -e '.[dev]'
349
- pytest -q # 45 tests, no network
350
- mypy src # strict
351
- ```
352
-
353
- ```bash
354
- # when github.com:443 is reset but api.github.com answers, push through the API
355
- python tools/push_via_api.py --repo <owner>/<name> --dry-run
356
- ```
357
-
358
- The tests encode the bugs this rewrite exists to prevent: a clip that split UTF-8 sequences, a URL
359
- compare that ignored the trailing slash, `sameSite: "Default"` rejected by Playwright, a `cleanup`
360
- that only deleted expired files, and a runaway browser left behind when the screenshot threw.
361
-
362
- ## Troubleshooting
363
-
364
- | Symptom | Cause | Fix |
365
- |---|---|---|
366
- | `cannot start the Python service` (DSH) | the plugin found a different interpreter | set `FOXFETCH_PY` to the absolute path |
367
- | `ModuleNotFoundError: mcp.server.fastmcp` | `mcp` 2.x installed | `pip install "mcp>=1.30,<2"` |
368
- | `no live context for that origin` | context idled out (60 s) or was evicted | pass `url` again, or keep `context_id` |
369
- | `navigation produced an empty document` | slow page, or one that needs a real renderer | raise `timeout_ms`, or use `handoff` + Chromium |
370
- | tools appear twice | two entries in one host | remove one |
371
- | `pip install` stops mid-download | flaky network to `files.pythonhosted.org` | retry, or `pip install --proxy http://127.0.0.1:7897 foxfetch` |
372
-
373
- ## Uninstall
374
-
375
- ```bash
376
- pip uninstall foxfetch
377
- ```
378
-
379
- Artifacts: `%LOCALAPPDATA%\foxfetch` (Windows) or `~/.local/share/foxfetch`. Then delete the host
380
- entry — the `mcpServers` block, the `[mcp_servers.foxfetch]` table, or the `dsh-foxfetch`
381
- dependency plus its bundle line.
382
-
383
- ## Licence
384
-
385
- MIT. The engine (`ruyijs`) is a separate project under AGPL-3.0; foxfetch only calls it — no
386
- ruyijs code is bundled.
File without changes
File without changes
File without changes
File without changes
File without changes