x-post-to-json MCP server

x-post-to-json MCP server

Converts X (Twitter) posts into JSON, PDF, PNG, Markdown, or Slack/Discord messages using public endpoints, no API key or login required.

Category
访问服务器

README

x-post-to-json

Turn any X (Twitter) post into JSON, a PDF document, a PNG card, Markdown, or a Slack/Discord post — with no API key and no login.

<p align="center"> <img src="docs/example-card.png" width="540" alt="A tweet rendered as a PNG card"> </p>

Zero npm dependencies. Works on Node 18+ (uses built-in fetch). PDF/PNG rendering uses your local headless Google Chrome.

node scripts/fetch-tweet.mjs "https://x.com/jack/status/20"

Why

X degrades its own content outside the platform (login walls, broken previews, deleted tweets vanish). This toolkit extracts a tweet's data through X's public syndication endpoint (the same one Vercel's react-tweet uses) and enriches it via the public GraphQL endpoint with a guest token — recovering full long-form text and complete metrics — then renders it however you need.

Outputs

Tool Command Notes
JSON scripts/fetch-tweet.mjs <url> normalized + raw; batch → array
PDF scripts/tweet-to-pdf.mjs <url> -o out.pdf real document, selectable text, archival footer; batch → multi-page
PNG card scripts/tweet-to-png.mjs <url> -o out.png shareable card, 2× retina, transparent bg
Markdown scripts/tweet-to-md.mjs <url> for Notion/Obsidian/blogs; batch → joined
Slack/Discord scripts/tweet-to-chat.mjs <url> --webhook <url> rich card via incoming webhook; --dry-run to preview
Analyze / fact-check scripts/analyze-tweet.mjs <url> returns a fact-check scaffold (signals, claims, search queries, rubric) for an AI to verify against
Unroll thread scripts/unroll-thread.mjs <url> [--markdown] walks back the reply chain → the author's full ordered thread

All accept a tweet URL (x.com / twitter.com, with ?query//photo/1) or a bare tweet ID, and one or more inputs (batch).

Common flags

  • --full — always enrich via GraphQL (full metrics even for short tweets)
  • --no-enrich — pure no-auth syndication only (fastest)
  • -o <path> — output file (PDF/PNG/MD)

What it extracts

Text (including full long-form), author (name, handle, avatar, verified_type), timestamp, metrics (likes / reposts / replies / quotes / bookmarks / views), media (photos + video/GIF with poster & link), links, hashtags, mentions, and quoted/reply info. Deleted / protected / age-gated / suspended tweets return a clean error.

MCP server

mcp-server.mjs exposes everything as MCP tools so any MCP client (Claude Desktop, Claude Code, Cursor, Cline, …) can call them directly. Zero dependencies (JSON-RPC over stdio). tweet_to_png_card returns the rendered image inline.

Claude Code:

claude mcp add x-post -- node "$(pwd)/mcp-server.mjs"

Claude Desktop / Cursor / Cline (claude_desktop_config.json):

{ "mcpServers": {
  "x-post": { "command": "node", "args": ["/absolute/path/to/x-post-to-json/mcp-server.mjs"] }
} }

Tools: tweet_to_json, analyze_tweet, unroll_thread, tweet_to_markdown, tweet_to_png_card, tweet_to_pdf, post_tweet_to_chat.

analyze_tweet — fact-check / explain

Turns the extractor into an analyst. The tool fetches the tweet and returns a scaffold — heuristic signals (percentages, stats/causal/sensational language, named entities, links), candidate claims, suggested search queries, author credibility, and a rubric. The host AI then runs web searches and produces a verdict card (claim → supported / misleading / false / unverifiable, the mechanism of any error, the actual evidence, and source reliability). No LLM or API key lives in this repo — the reasoning is done by whatever AI calls the tool.

Architecture

lib/tweet.mjs              shared fetch + normalize engine (fetchTweet)
lib/render.mjs             shared render helpers (esc, richText, fmt*, embedAssets)
scripts/fetch-tweet.mjs    JSON
scripts/tweet-to-pdf.mjs   PDF document
scripts/tweet-to-png.mjs   PNG card
scripts/tweet-to-md.mjs    Markdown
scripts/tweet-to-chat.mjs  Slack/Discord
scripts/analyze-tweet.mjs  fact-check scaffold
scripts/unroll-thread.mjs  thread unroll (backward walk)
mcp-server.mjs             MCP wrapper

To add an output format, import the engine + lib/render.mjs and reuse the normalized object — don't re-implement fetching.

Caveats

  • Uses X's undocumented public endpoints. They can change; GraphQL enrichment is best-effort and degrades gracefully (falls back to the syndication preview, flags truncated). If enrichment stops working, the GQL_QUERY_ID in lib/tweet.mjs likely rotated and needs updating.
  • Public tweets only. Respect X's Terms of Service and applicable laws for your use case.
  • PDF/PNG require Google Chrome installed (path is /Applications/Google Chrome.app/... on macOS — adjust in the scripts for other OSes).

License

MIT © itsbigdill

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选