spa-reader-mcp

spa-reader-mcp

An MCP server that renders JavaScript-heavy Single Page Applications using Playwright to extract clean, LLM-ready Markdown and capture screenshots. It features a singleton browser architecture for high performance and includes built-in SSRF protection for secure web content retrieval.

Category
访问服务器

README

spa-reader-mcp

npm version npm downloads License: MIT TypeScript Node.js

MCP server that renders JavaScript SPA pages and extracts LLM-ready Markdown.

Traditional web scrapers fail on Single Page Applications because content is rendered by JavaScript after page load. spa-reader-mcp solves this by launching a headless Chromium browser via Playwright, waiting for the page to fully render, then extracting clean Markdown using Mozilla's Readability and Turndown — ready for LLM consumption.

Features

  • spa_read — Render any SPA page and extract article content as clean Markdown with optional YAML frontmatter
  • spa_screenshot — Capture full or viewport-sized PNG screenshots of rendered pages
  • Singleton browser — Reuses a single Chromium instance across requests for fast, low-overhead rendering
  • SSRF protection — Blocks private/loopback IP ranges and restricts URL schemes to http/https
  • Selector injection prevention — Rejects Playwright-specific selector syntax (>>, nth=, text=, has-text, :has)
  • Content truncation — Caps output at 100KB with clean line-boundary truncation

Requirements

  • Node.js >= 20
  • Chromium browser for Playwright:
    npx playwright install chromium
    

Installation

npx (recommended, zero install)

No global install needed — configure directly in your MCP client (see MCP Configuration).

Global install

npm install -g spa-reader-mcp
npx playwright install chromium

From source

git clone https://github.com/XXO47OXX/spa-reader-mcp.git
cd spa-reader-mcp
pnpm install
pnpm build
npx playwright install chromium

MCP Configuration

Claude Desktop

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "spa-reader": {
      "command": "npx",
      "args": ["-y", "spa-reader-mcp"]
    }
  }
}

Claude Code

claude mcp add spa-reader -- npx -y spa-reader-mcp

Tools

spa_read

Render a JavaScript SPA page and extract its content as LLM-ready Markdown.

Parameter Type Required Default Description
url string Yes The URL of the SPA page to read
waitForSelector string No CSS selector to wait for before extraction
waitTimeout number No 30000 Navigation timeout in ms (1000–120000)
includeMetadata boolean No true Include title/author/excerpt as YAML frontmatter

Example output:

---
title: "Understanding React Server Components"
author: "Dan Abramov"
excerpt: "A deep dive into how RSC works under the hood"
source: "https://example.com/blog/rsc"
---

## Introduction

React Server Components allow you to...

spa_screenshot

Take a PNG screenshot of a JavaScript SPA page after rendering.

Parameter Type Required Default Description
url string Yes The URL to screenshot
waitForSelector string No CSS selector to wait for before capturing
waitTimeout number No 30000 Navigation timeout in ms (1000–120000)
width number No 1280 Viewport width in pixels (320–3840)
height number No 720 Viewport height in pixels (240–2160)
fullPage boolean No false Capture full scrollable page

Returns the screenshot as a base64-encoded PNG image.

Architecture

URL
 → Playwright Chromium (headless, singleton)
   → Per-request BrowserContext (isolated cookies/storage)
     → Page navigation + networkidle + optional selector wait
       → Raw HTML
         → Mozilla Readability (article extraction)
           → Turndown (HTML → Markdown)
             → YAML frontmatter + truncation
               → LLM-ready Markdown

Key design decisions:

  • Singleton browser: A single Chromium instance is launched on first request and reused. This avoids the ~2s cold-start penalty on subsequent calls.
  • Per-request BrowserContext: Each request gets an isolated BrowserContext with its own cookies and storage, preventing cross-request data leakage.
  • Readability fallback: If Mozilla Readability determines the page isn't article-like, the extractor falls back to converting the full <body> HTML.

Security

Protection Details
SSRF prevention Blocks localhost, 127.x.x.x, 10.x.x.x, 172.16-31.x.x, 192.168.x.x, ::1, fe80:, 169.254.x.x, 0.0.0.0
Scheme whitelist Only http: and https: URLs are allowed
Selector injection Rejects Playwright engine syntax: >>, nth=, text=, has-text, :has()
Content truncation Output capped at 100KB with clean line-boundary cut
Test bypass Set SPA_READER_ALLOW_PRIVATE=1 to allow private IPs (for local development/testing only)

Development

# Install dependencies
pnpm install

# Build
pnpm build

# Run tests
pnpm test

# Type check
pnpm lint

License

MIT — Copyright (c) 2026 XXO47OXX

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选