npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@alaxlee/mcp-rendered-fetch-server

v1.2.1-hotfix.1

Published

An MCP server that returns JS-rendered HTML via Playwright (inspired by zcaceres)

Readme

Fetch MCP Server

fetch mcp logo

一个精简版 MCP 服务器,仅提供经无头浏览器渲染后的页面 HTML 抓取能力。

本工程参考并致敬原项目 zcaceres/fetch(作者 Zach Caceres),并感谢贡献者 Piotr Wilkin;在其基础上进行精简与改造,仅保留渲染后 HTML 抓取工具。

NPM

工具

  • fetch_rendered_html
    • 功能:使用 Playwright 的 Chromium 渲染页面并返回当前 DOM 的完整 HTML(类似浏览器看到的页面)
    • 输入参数:
      • url(string,必填):要抓取的页面 URL
      • headers(object,可选):请求时附加的自定义 headers
      • max_length(number,可选):返回内容最大字符数,默认从环境变量控制(默认 5000,0 表示不限制)
      • start_index(number,可选):从该字符索引开始返回内容,默认 0
      • wait_ms(number,可选):页面加载完成后额外等待的毫秒数,用于等待客户端渲染,默认 2000
      • simplify(boolean,可选):是否启用精简模式,默认 false
      • include_iframes(boolean,可选):是否将每个 <iframe> 的页面 HTML 直接写入最终 HTML 中对应的 <iframe> 标签内部(不改动 src/srcdoc),以便一次性查看完整页面。跨域 iframe 也支持。若子页面指向私网地址,则不抓取真实内容,改为在标签内部写入占位文本。默认 false
    • 返回:{ content: [{ type: "text", text: "<html>...</html>" }], isError: false }

安全

  • 自动阻止访问私有 IP(如 127.0.0.110.x.x.x192.168.x.x 等),防止本地数据被外泄
  • 统一设置桌面浏览器 User-Agent,可通过 headers 叠加自定义头

快速开始

  1. 克隆仓库
  2. 安装依赖:npm install
  3. 构建:npm run build
  4. 运行:npm start

服务器通过 stdio 提供 MCP 能力。

示例调用(工具入参)

客户端调用工具 fetch_rendered_html 时,传参示例:

{
  "name": "fetch_rendered_html",
  "arguments": {
    "url": "https://example.com",
    "simplify": true,
    "include_iframes": true,
    "wait_ms": 2000,
    "max_length": 50000,
    "start_index": 0
  }
}

参数默认值速览

  • headers:不设置(可选)
  • max_length:默认 DEFAULT_LIMIT(环境变量,默认 5000;设为 0 表示不限制)
  • start_index:默认 0
  • wait_ms:默认 2000
  • simplify:默认 false
  • include_iframes:默认 false

环境变量

  • DEFAULT_LIMIT:默认内容长度限制(字符数),设置为 0 表示不限制,默认 5000

在桌面应用中使用

将以下配置加入你的应用(示例):

{
  "mcpServers": {
    "fetch": {
      "command": "npx",
      "args": ["@alaxlee/mcp-rendered-fetch-server"],
      "env": {
        "DEFAULT_LIMIT": "50000"
      }
    }
  }
}

客户端调用工具名为 fetch_rendered_html

功能特性

  • 使用 Playwright 的 Chromium 渲染并返回页面 HTML
  • 支持自定义请求头、长度与起始位置控制、渲染后额外等待(wait_ms
  • 可选精简模式:截断脚本、样式与超长属性值,降低返回体大小
  • 可选 iframe 内容嵌入:将子页面的 HTML 写入对应 <iframe> 标签内部(不改动属性)
  • 阻止私有 IP 访问,提升安全性

精简模式说明(simplify: true

启用后在浏览器端对当前 DOM 进行以下精简,再返回 HTML:

  • <script> 内联内容仅保留前 100 个字符,后面追加 ...后续已忽略
  • <script><style> 的内联内容仅保留前 100 个字符,后面追加 ...后续已忽略
  • 所有元素的属性值长度超过 1000 时,仅保留前 100 个字符,后面追加 ...后续已忽略

精简在渲染完成与额外等待(wait_ms)之后执行,随后再获取页面内容并应用 max_lengthstart_index 截断。

iframe 内容嵌入说明(include_iframes: true

  • 遍历所有子 frame,读取其 HTML 并将内容写入最终 HTML 中对应 <iframe> 标签的内部(innerHTML),不修改 src/srcdoc 等属性
  • 私网地址的 frame 不会嵌入真实内容,改为在标签内部写入占位文本 [Blocked private IP content]
  • 若启用精简模式,子 frame 内也会进行脚本、样式与长属性值的截断

依赖与浏览器安装提示

  • 依赖:@modelcontextprotocol/sdkplaywrightzodprivate-ip
  • 若首次运行遇到浏览器缺失错误,可执行:npx playwright install

开发

  • npm run dev:启动 TypeScript 编译器 watch 模式
  • npm test:运行测试用例

许可证

MIT

致谢

  • 参考项目:zcaceres/fetch
  • 原作者:Zach Caceres(zach.dev)
  • 贡献者:Piotr Wilkin([email protected]