mcpField
D
Diffgrab

Diffgrab

本地服务
github.com/QuartzUnit浏览器自动化028 周前更新

关于 Diffgrab

Diffgrab 是用于跟踪网页内容变化的工具,面向需要监控网页更新的开发者和研究者。它生成按章节分析的结构化差异,并保存 SQLite 快照历史;还集成 markgrab 与可选的 snapgrab 视觉差异。

主要功能

  1. 01检测网页内容变化
  2. 02生成统一差异和章节分析
  3. 03提供易读的变化摘要
  4. 04在 SQLite 中保存快照历史
  5. 05支持可选的截图视觉比较

适用场景

  1. 01监控网页是否发布新内容
  2. 02查看更新涉及的章节与行数
  3. 03回顾网页历史版本
  4. 04通过截图比较页面视觉变化

MCP 相关

Diffgrab 的 MCP 服务提供 5 种工具,用于注册 URL、检查变化、获取结构化差异、查看快照历史和停止跟踪。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

mcp.json · 通用配置
{
"mcpServers": {
"arknill-diffgrab": {
"command": "uvx",
"args": [
"diffgrab"
]
}
}
}
启动命令uvx diffgrab

本地服务需要在你的电脑上安装运行环境(如 Node.js 18+)。各客户端的配置文件位置不同,请参考客户端文档。

安装包
pypidiffgrab0.1.0

工具

还没有获取到工具列表

本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。

详细介绍

diffgrab

PyPI Python License

한국어 문서 · llms.txt

通过结构化差异跟踪网页变化。集成 markgrab + snapgrab,原生支持 MCP。

from diffgrab import DiffTracker

tracker = DiffTracker()
await tracker.track("https://example.com")
changes = await tracker.check()
for c in changes:
    if c.changed:
        print(c.summary)     # "3 lines added, 1 lines removed in sections: Introduction."
        print(c.unified_diff) # Standard unified diff output
await tracker.close()

功能

  • 变化检测 — 跟踪任意 URL,通过内容哈希检测内容变化
  • 结构化差异 — 统一差异 + 章节级分析(哪些标题发生了变化)
  • 易读摘要 — “章节 Intro、Methods 中新增 5 行,删除 2 行”
  • 快照历史 — 使用 SQLite 存储,浏览任意网页的历史版本
  • 由 markgrab 提供支持 — 通过 markgrab 提取 HTML/YouTube/PDF/DOCX 内容
  • 视觉差异 — 可选通过 snapgrab 比较截图
  • MCP 服务 — 为 Claude Code / MCP 客户端提供 5 种工具
  • 附带 CLI — diffgrab track、check、diff、history、untrack

工作原理

flowchart TD
    A["diffgrab track URL"] --> B["Fetch initial snapshot\n(markgrab + snapgrab)"]
    B --> C["Store baseline"]
    C --> D["diffgrab check"]
    D --> E["Fetch current page"]
    E --> F{"Content\nhash match?"}
    F -->|"changed"| G["Compute structured diff\n+ section analysis"]
    F -->|"unchanged"| H["No changes"]
    G --> I["📊 DiffResult\nadded / removed / modified"]

安装

pip install diffgrab

可选扩展:

pip install 'diffgrab[cli]'      # CLI with click + rich
pip install 'diffgrab[visual]'   # Visual diff with snapgrab
pip install 'diffgrab[mcp]'      # MCP server with fastmcp
pip install 'diffgrab[all]'      # Everything

使用方法

Python API
import asyncio
from diffgrab import DiffTracker

async def main():
    tracker = DiffTracker()

    # Track a URL (takes initial snapshot)
    await tracker.track("https://example.com", interval_hours=12)

    # Check for changes
    changes = await tracker.check()
    for change in changes:
        if change.changed:
            print(change.summary)
            print(change.unified_diff)

    # Get diff between specific snapshots
    result = await tracker.diff("https://example.com", before_id=1, after_id=2)

    # Browse snapshot history
    history = await tracker.history("https://example.com", count=20)

    # Stop tracking
    await tracker.untrack("https://example.com")

    await tracker.close()

asyncio.run(main())
便捷函数
from diffgrab import track, check, diff, history, untrack

await track("https://example.com")
changes = await check()
result = await diff("https://example.com")
snaps = await history("https://example.com")
await untrack("https://example.com")
CLI
# Track a URL
diffgrab track https://example.com --interval 12

# Check all tracked URLs for changes
diffgrab check

# Check a specific URL
diffgrab check https://example.com

# Show diff between snapshots
diffgrab diff https://example.com
diffgrab diff https://example.com --before 1 --after 3

# View snapshot history
diffgrab history https://example.com --count 20

# Stop tracking
diffgrab untrack https://example.com
MCP 服务

将以下内容添加到 Claude Code 的 MCP 配置中:

{
  "mcpServers": {
    "diffgrab": {
      "command": "diffgrab-mcp",
      "args": []
    }
  }
}

也可以使用 uvx:

{
  "mcpServers": {
    "diffgrab": {
      "command": "uvx",
      "args": ["--from", "diffgrab[mcp]", "diffgrab-mcp"]
    }
  }
}

MCP 工具:

工具描述
track_url注册要跟踪变化的 URL
check_changes检查已跟踪的 URL 是否发生变化
get_diff获取快照之间的结构化差异
get_history浏览快照历史
untrack_url停止跟踪 URL

DiffResult

每次差异操作都会返回一个 DiffResult:

@dataclass
class DiffResult:
    url: str                           # The tracked URL
    changed: bool                      # Whether content changed
    added_lines: int                   # Lines added
    removed_lines: int                 # Lines removed
    changed_sections: list[str]        # Markdown headings with changes
    unified_diff: str                  # Standard unified diff
    summary: str                       # Human-readable summary
    before_snapshot_id: int | None     # DB ID of older snapshot
    after_snapshot_id: int | None      # DB ID of newer snapshot
    before_timestamp: str              # When older snapshot was taken
    after_timestamp: str               # When newer snapshot was taken

存储

快照存储在 SQLite 数据库 ~/.local/share/diffgrab/diffgrab.db 中(自动创建)。自定义路径:

tracker = DiffTracker(db_path="/path/to/custom.db")

QuartzUnit 生态系统

软件包用途PyPI
markgrab将 HTML/YouTube/PDF/DOCX 转换为 Markdownpip install markgrab
snapgrab将 URL 转换为截图 + 元数据pip install snapgrab
docpickOCR + 大模型文档提取pip install docpick
feedkitRSS 源收集pip install feedkit
diffgrab网页变化跟踪pip install diffgrab
browsegrab面向大模型的浏览器 Agent即将推出

使用项目

  • newswatch — RSS 新闻监控流水线(feedkit → markgrab → embgrep → diffgrab)
  • watchdeck — 带视觉差异和安全防护的网页监控

许可证

MIT


属于 QuartzUnit 生态系统 — 用于数据收集、提取、搜索和 AI Agent 安全防护的可组合 Python 库。

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。