mcpField
X
XActions

XActions

本地服务
github.com/nirholas社交媒体6311 天前更新

关于 XActions

XActions 是面向 X/Twitter 的自动化工具集,包含抓取器、MCP 服务、命令行、浏览器脚本和浏览器扩展,无需 API 密钥。其 MCP 服务面向 AI Agent,写操作默认可经人工审核后再发布。

主要功能

  1. 01无需 API 密钥的资料与推文抓取
  2. 02MCP 服务,支持按工具组过滤
  3. 03命令行提供 56 个命令
  4. 04写操作可转为草稿等待审核
  5. 05每账号每日操作上限,记录保存在磁盘

适用场景

  1. 01抓取公开账号的资料与推文并导出为 CSV
  2. 02让 AI Agent 通过 MCP 搜索或发布内容
  3. 03批量管理自己账号的回复与互动

MCP 相关

该项目是一个 MCP 服务,向 MCP 客户端暴露 X/Twitter 的读取、写入、分析等工具,并支持 stdio 与 Streamable HTTP 传输。

配置

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

mcp.json · 通用配置
{
"mcpServers": {
"nirholas-xactions": {
"command": "npx",
"args": [
"-y",
"xactions"
],
"env": {
"X_COOKIES": "<X_COOKIES>",
"X_USERNAME": "<X_USERNAME>",
"X_PASSWORD": "<X_PASSWORD>"
}
}
}
}
启动命令npx -y xactions
需要配置的环境变量
X_COOKIES密钥X/Twitter authentication cookies (JSON string or path to cookies file)
X_USERNAMEX/Twitter username for login
X_PASSWORD密钥X/Twitter password for login

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

安装包
npmxactions3.5.0

工具

145

收录的工具列表 · 更新于 2 周前

参数类型必填说明
cookiestring是来自 X.com 的 auth_token Cookie 值

详细介绍

 
██╗  ██╗ █████╗  ██████╗████████╗██╗ ██████╗ ███╗   ██╗███████╗
╚██╗██╔╝██╔══██╗██╔════╝╚══██╔══╝██║██╔═══██╗████╗  ██║██╔════╝
 ╚███╔╝ ███████║██║        ██║   ██║██║   ██║██╔██╗ ██║███████╗
 ██╔██╗ ██╔══██║██║        ██║   ██║██║   ██║██║╚██╗██║╚════██║
██╔╝ ██╗██║  ██║╚██████╗   ██║   ██║╚██████╔╝██║ ╚████║███████║
╚═╝  ╚═╝╚═╝  ╚═╝ ╚═════╝   ╚═╝   ╚═╝ ╚═════╝ ╚═╝  ╚═══╝╚══════╝

XActions,完整的 X/Twitter 自动化工具包

完整的 X/Twitter 自动化工具包

抓取工具  ·  面向 AI Agent 的 MCP 服务  ·  命令行工具  ·  浏览器脚本  ·  浏览器扩展
无需 API 密钥。无需月费。100% 开源。

npm 版本  npm 下载量  Apache 2.0 许可证  星标数

154 个 MCP 工具  Smithery  MCP 注册表  Docker  TypeScript

关注 @nichxbt  由 Grok 构建

https://xactions.app


网站  ·  npm  ·  文档  ·  MCP 服务  ·  Docker  ·  API 参考


⚡ 30 秒上手体验
npx xactions profile nasa
⚡ @NASA

  Name:      NASA
  Bio:       Making the seemingly impossible, possible. ✨
  Location:  Pale Blue Dot
  Website:   http://www.nasa.gov/
  Joined:    2007-12-19
  Following: 117  Followers: 92.4M
  Tweets:    74.2K  Listed:    0
  ✓ Verified

无需 API 密钥。无需账户。无需浏览器。约一秒即可获取真实数据。

npx xactions tweets nasa --limit 100 --output nasa.csv   # timeline to a spreadsheet
npx xactions login                                        # unlock search, followers, DMs
npx xactions search "your brand" --limit 50               # what people are saying
⚡ 查看实际效果
XActions 命令行演示:查询个人资料、搜索推文、检测未回关用户


🏆 XActions 对比优势

为什么选择 XActions,而不是其他替代方案?

功能XActionstwikittwscrapex-usexmcp (official)birdtwitter-cliAgent-Reach
无需 API 密钥✅✅ Cookies✅ 账号池✅ 浏览器❌ X API keys✅ Cookies❌ X API keys✅
MCP 服务(AI Agent)✅ 154 个工具❌❌✅(33 个工具的服务)✅(140 个工具,按量计费)❌❌❌ 技能,而非 MCP
浏览器控制台脚本✅ 95❌❌❌❌❌❌❌
Spaces 中的 AI 语音 Agent✅ 加入、收听、发言❌❌❌❌❌❌❌
命令行✅ 56 条命令❌✅❌❌✅✅✅
写入操作需经人工审批✅ 每项写入操作都会暂存为草稿❌❌✅❌❌❌❌
重启后仍有效的每日操作上限✅ 按账号设置,保存在磁盘上❌❌✅❌❌❌❌
支持轮换的账号池✅ SQLite,按操作设置时间窗口❌✅❌❌❌❌❌
可续传的长时间抓取✅ 游标检查点❌❌❌❌❌❌❌
从已安装的浏览器获取 Cookies✅ --from-browser, --cookies-file❌❌❌❌✅✅❌
导入官方 X 存档✅ xactions archive❌❌❌❌❌❌❌
语言JavaScriptPythonPythonTypeScriptTypeScriptTypeScriptPythonPython

XActions 是唯一一个无需 API 密钥,即可在浏览器、终端和 AI Agent 中使用的工具包。

竞争对手列的内容来自竞争分析,其中列出了各个项目及其优于我们的方面。竞争对手领先的功能,我们也已实现:审批关卡和每日上限参考了 x-use,账号池参考了 twscrape,游标续传参考了 Scweet,浏览器 Cookie 导入则参考了 bird 和 twitter-cli。


🆕 最新动态

区域变更内容
删除你发给某个账号的所有回复scripts/searchSweep.js 可将任意 X 搜索转为批量操作。打开 x.com/search?q=from:you @someone&f=live,粘贴脚本,即可对每条结果执行删除、点赞、转发或回复,并使用浮动面板、试运行、保护热门帖子的筛选器,以及多轮处理(因为 X 搜索每次只返回一部分结果)。删除操作只会触及你自己的帖子。文档。
批量处理整个个人主页scripts/engageProfile.js 可在控制台中为某个账号的每条帖子点赞、转发和回复,并提供浮动面板、试运行、续跑、撤销,以及使用你的模板或根据一行简报由大模型生成的回复(Grok 可直接在控制台中使用;其他提供方可通过扩展使用)。在终端运行 xactions engage USERNAME --like --repost --comment --prompt "...",即可使用任意提供方执行相同操作。文档。
清晰易用的 CLI现在所有 56 个命令都按任务分组,而非按字母顺序排列。xactions quickstart 会根据你已有的配置,提供适配的引导式首次运行流程。
Tab 补全xactions completion bash|zsh|fish 会根据实时命令树生成并打印补全脚本,因此每个命令、子命令和标志都支持补全。
无需打开 DevTools 即可登录xactions login --from-browser 可直接从已安装的 Chrome、Chromium、Brave、Edge、Arc 或 Firefox 配置文件中读取 x.com Cookie。--cookies-file 可导入 Netscape cookies.txt、Cookie-Editor 或 EditThisCookie JSON 导出文件,或 Playwright / Puppeteer storageState。完整 Cookie jar 优于单独的 auth_token,因为它包含每次写入都需要的 ct0。
可自行更新的查询 IDX 会轮换其 GraphQL 查询 ID,而所有固定使用旧 ID 的客户端都会同时返回 404。我们会从 x.com 自己的资源包中发现并缓存查询 ID,因此轮换不会造成影响。xactions doctor 会报告缓存时长。
请求签名与真实客户端一致每次 GraphQL 调用都会携带 x-client-transaction-id 标头,计算方式与 x.com 自己的 Web 客户端相同,因此读取结果与浏览器获得的结果一致。
账号池与可续跑的抓取会话存储在 SQLite 数据库中,每个会话都有自己的代理,并从 X 自己的标头中读取每种操作的速率限制窗口。池化客户端会在收到 429 时轮换账号,在收到 401 时锁定账号。每一页处理后都会写入检查点,因此即使抓取 50,000 个关注者时在第 400 页中断,重启后也会从游标处继续,而非从第一页开始。
每日操作上限每次 MCP 写入都会计入存储在磁盘上的滚动 24 小时账号预算。即使重启、崩溃或重新运行 npx xactions-mcp,上限也会保留。超过上限的调用会在到达 X 之前被拒绝。默认值遵循 X 公布的限制。
由人类放行的写入操作XACTIONS_MCP_REQUIRE_APPROVAL=1 会将每个写入工具转为草稿。使用 xactions drafts list 审核,通过 xactions drafts approve <id> 放行,或使用 x_list_drafts / x_approve_draft / x_discard_draft 工具。
MCP 工具组工具列表可筛选:--tools read,analytics 或 XACTIONS_MCP_TOOLS=read 只会公布会话所需的工具,已筛选掉的工具既不会公布,也无法调用。分组包括:read、write、dm、lists、spaces、analytics、ai、grok、automation、monitoring、workflows、persona、graph、data、x402、drafts、auth。
通过 HTTP 使用 MCPxactions-mcp --http 会在 /mcp 上提供 Streamable HTTP 传输,供远程和托管客户端使用,并可通过 XACTIONS_MCP_TOKEN 启用可选的 bearer 身份验证。stdio 仍为默认方式。
一拖即可安装到 Claude Desktop.mcpb 软件包包含服务及其依赖项,并会在安装时提示输入会话 Cookie 和工具组,因此无需将任何内容手动输入配置文件。每个版本都会附带该软件包。
可安装的 Skillsxactions skills install --all 会将打包的 50 个 skills 复制到 Claude Code、Cursor、Codex、Windsurf 或当前项目中。xactions skills show <name> 可查看其中一个 skill,无需安装。
导入你的 X 归档数据xactions archive summary|export|migrate 可读取官方 X 数据导出 zip:统计数量、日期范围、最活跃年份和热门话题标签;将数据改写为 JSON、CSV、Markdown,并生成可浏览的 HTML 查看器;或迁移至 Bluesky 或 Mastodon。文档。
实时事件流src/streaming/livePipeline.js 会读取 x.com 自己的事件管道:互动计数、私信更新和正在输入指示器都会主动推送,而非轮询,并支持在会话期间更改订阅。它采用分块的换行分隔 JSON 响应,而非 WebSocket,因为 x.com 对该端点的响应从来不是 101。
已签名的 Webhook外发投递包含 HMAC-SHA256 签名、时间戳、事件类型和稳定的投递 ID,会通过退避策略重试三次,并写入可重放的投递日志。接收方可使用导出的 verifyWebhookSignature 进行验证。
--compact 和 --fields所有读取命令都支持全局使用这两个标志。--compact 会逐行打印记录,以制表符分隔的 key=value 键值对呈现,不带颜色或加载动画;--fields id,text,likes 可将结果缩小到指定列。专为 Agent 和管道而设计。
所有命令都支持 --json每个读取命令都接受 --json,并且只向 stdout 输出数据。它的优先级高于 --output,因此管道输出不会被静默地改为写入文件。
可靠性公开数据读取不再需要浏览器。个人主页和时间线通过内部 GraphQL API 在约一秒内获取,无需下载 Chromium。
如实报告失败现在不会再把空结果报告为成功。无法完成的读取会说明原因,并告知如何处理。
归档所有照片和视频xactions download @nichxbt:all --archive 会使用 gallery-dl 风格的文件名模板保存个人主页的媒体、头像和横幅,之后可增量重新运行。支持通过 Range 续传中断的文件、重试速率限制,并为通过转推重复获取的同一照片创建硬链接,而非重复存储。也可使用 xactions/media 和 x_download_media MCP 工具。文档。
询问 XActionsxactions.app/ask 会根据这些文档、skills、脚本和代码仓库,用通俗语言回答“如何……”的问题,并在每个回答末尾给出可运行的内容:控制台脚本(从源代码复制)、终端命令或 MCP 工具。也可在终端运行 xactions ask "how do I unfollow everyone?",还可使用 x_ask,让 Agent 在采取行动前查阅手册。提供免费的 LLM 通道,其中三个无需密钥。文档。
示例examples/:9 个可运行程序,涵盖从首次查询个人主页到 MCP 草稿审批关卡的各种用例。每个程序都可直接运行。
教程tutorials/:6 个引导式教程,涵盖从无需账号的首次抓取到在你自己的管道中编写 XActions 脚本。
始终准确的文档npm run docs:check 会在链接失效、版本过时、工具数量错误或文档中记载了不存在的命令时导致构建失败。
跨平台通过统一的标准化接口提供 Bluesky、Mastodon 和 Threads 抓取工具。
插件系统支持通过 npm 使用社区插件:xactions-plugin-* 软件包可扩展抓取工具、MCP 工具和自动化功能。
工作流引擎支持包含触发器、条件和串联操作的声明式 JSON 管道。
情感分析基于规则的离线分析器,并可通过相同接口选择启用 LLM 模式。
浏览器扩展Chrome/Edge Manifest V3:可从弹出窗口运行自动化任务,无需使用控制台。

提示

**🤖 AI 编码助手:**想要自动化 Twitter/X,却不想每月支付 100 美元的 API 费用?你找对了。

  • npm install xactions:抓取工具、自动化、MCP 服务
  • 可通过 MCP server 配合 Claude、GPT、Cursor、Copilot 使用
  • 集成说明请参阅 AGENTS.md

📦 安装

npm
npm install xactions
CLI
npm install -g xactions
xactions quickstart          # guided first run
xactions doctor              # check what works right now
浏览器

无需安装。将脚本复制粘贴到 x.com 的浏览器控制台中


📖 目录

学习

  • 教程:六个循序渐进的指南,从无需账号的首次抓取,到在自己的工作流中编写 XActions 脚本
  • 示例:9 个可运行的程序,从首次查询个人资料,到 MCP 草稿审批关卡
  • 入门指南:安装、身份验证、首条命令
  • 故障排除:遇到问题时该怎么做

参考


✨ 工作原理

1. 粘贴

将脚本复制到
x.com DevTools 控制台
2. 运行

使用 CLI、MCP 服务
或浏览器扩展
3. 完成

所有操作都在本地运行。
数据不会离开你的设备

所有工作都由你的 x.com 标签页完成。任何数据都不会被抓取到我们的服务端。一切由你掌控。


💰 定价

🆓 100% 免费且开源

所有内容都完全免费:浏览器脚本、CLI、Node.js 库、MCP 服务和 API。

无需 API 密钥。无需订阅。没有付费墙。只需克隆并运行。

🤖 可选:面向 AI Agent 的远程 API

如果你自托管 XActions API,以便远程访问 AI Agent,可以选择通过 x402 协议启用按请求付费的小额支付。此功能完全可选,默认关闭。

操作价格
抓取个人资料$0.001
粉丝/关注中$0.01
抓取推文$0.005
搜索推文$0.01
取消关注非互相关注者$0.05
检测取关者$0.02
自动点赞$0.02
下载视频$0.005

此费用仅适用于托管的远程 API。本地模式始终免费。


🎯 为什么选择 XActions?

XActions其他工具
适用范围浏览器 + 命令行 + Node.js + MCP + 扩展通常只有 1 项功能
API 密钥无需大多数需要 Twitter API($100/mo)
MCP 工具为 Claude、GPT、Cursor 提供 152 个0-2 个工具
AI 功能情感分析、Grok、声誉无
导出JSON、CSV、Markdown、HTML仅 JSON(如果支持)
迁移从实时账号或 X 归档 ZIP 迁移到 Bluesky 和 Mastodon无
教程23 个 Claude 提示词无

🐳 Docker

只需一条命令,即可在任何地方运行 XActions:

# Quick start
docker build -t xactions .
docker run -it xactions xactions profile elonmusk

# Run the MCP server
docker run -p 3000:3000 xactions npm run mcp

# With environment variables
docker run -e XACTIONS_SESSION_COOKIE=your_cookie xactions xactions followers elonmusk

或者使用 Docker Compose:

docker compose up

详情请参阅 Dockerfile。


📖 API 参考

提供完整的 TypeScript 兼容 API,并包含类型声明。

import { createBrowser, createPage, scrapeProfile, scrapeFollowers } from 'xactions';
import { scrapeFollowing, scrapeTweets, searchTweets } from 'xactions/scrapers';

核心函数:

函数描述返回值
createBrowser(options?)启动 Puppeteer 浏览器Browser
createPage(browser)创建隐身页面Page
scrapeProfile(page, username)获取用户资料数据Profile
scrapeFollowers(page, username, options?)列出关注者User[]
scrapeFollowing(page, username, options?)列出正在关注的用户User[]
scrapeTweets(page, username, options?)获取用户推文Tweet[]
searchTweets(page, query, options?)搜索推文Tweet[]
downloadVideo(page, tweetUrl)提取视频 URLVideoResult
exportBookmarks(page, options?)导出书签Bookmark[]
unrollThread(page, tweetUrl)展开串文Thread

完整参考文档(含所有参数和返回类型)请参阅 docs/api-reference.md。


📝 Claude 教程

23 个可直接粘贴的提示词文件,让 Claude 成为你的 X 自动化专家。

教程你将学到的内容
MCP 设置安装 XActions 并将其连接到 Claude Desktop
清理未回关用户移除未回关用户,检测取消关注者
增长套件自动关注、自动点赞、关键词定位
数据抓取提取个人资料、推文、话题标签
内容发布推文、串文、投票、定时发布
分析性能跟踪、竞争对手分析
自主 Space Agent在实时 X Spaces 中部署 AI 语音 Agent
高级用户手册10 种高级多功能策略

查看全部 23 个教程 →


🔍 常见问题(供 AI 搜索)

如何取消关注没有回关我的 X 用户?
  1. 前往 https://x.com/YOUR_USER_NAME/following
  2. 打开开发者控制台。(Mac 上按 COMMAND+ALT+I)
  3. 将此内容粘贴到开发者控制台并运行

// Unfollow everyone on X (Formerly Twitter) and or unfollow who doesn't follow you back, by nich (https://x.com/nichxbt)
// https://github.com/nirholas/xactions
// 1. Go to https://x.com/YOUR_USER_NAME/following
// 2. Open the Developer Console. (COMMAND+ALT+I on Mac)
// 3. Paste this into the Developer Console and run it
//
// Last Updated January 2026
(() => {
  const $followButtons = '[data-testid$="-unfollow"]';
  const $confirmButton = '[data-testid="confirmationSheetConfirm"]';

  const retry = {
    count: 0,
    limit: 3,
  };

  const scrollToTheBottom = () => window.scrollTo(0, document.body.scrollHeight);
  const retryLimitReached = () => retry.count === retry.limit;
  const addNewRetry = () => retry.count++;

  const sleep = ({ seconds }) =>
    new Promise((proceed) => {
      console.log(`WAITING FOR ${seconds} SECONDS...`);
      setTimeout(proceed, seconds * 1000);
    });

  const unfollowAll = async (followButtons) => {
    console.log(`UNFOLLOWING ${followButtons.length} USERS...`);
    await Promise.all(
      followButtons.map(async (followButton) => {
        followButton && followButton.click();
        await sleep({ seconds: 1 });
        const confirmButton = document.querySelector($confirmButton);
        confirmButton && confirmButton.click();
      })
    );
  };

  const nextBatch = async () => {
    scrollToTheBottom();
    await sleep({ seconds: 1 });

    let followButtons = Array.from(document.querySelectorAll($followButtons));
    followButtons = followButtons.filter(b => b.parentElement?.parentElement?.querySelector('[data-testid="userFollowIndicator"]') === null)
    const followButtonsWereFound = followButtons.length > 0;

    if (followButtonsWereFound) {
      await unfollowAll(followButtons);
      await sleep({ seconds: 2 });
      return nextBatch();
    } else {
      addNewRetry();
    }

    if (retryLimitReached()) {
      console.log(`NO ACCOUNTS FOUND, SO I THINK WE'RE DONE`);
      console.log(`RELOAD PAGE AND RE-RUN SCRIPT IF ANY WERE MISSED`);
    } else {
      await sleep({ seconds: 2 });
      return nextBatch();
    }
  };

  nextBatch();
})();

或者使用 CLI 或 MCP server 获取更多选项。

如何给某个个人资料中的每条帖子点赞、转发并回复?
  1. 前往 https://x.com/USERNAME
  2. 打开开发者控制台。(Mac 上按 COMMAND+ALT+I)
  3. 粘贴 scripts/engageProfile.js 并运行。此时会出现一个面板:选择点赞/转发/回复,保持试运行开启,按下 Start,查看日志,然后关闭试运行。

回复可以使用你自己的模板,也可以由大模型根据简短指示生成,例如“友好、具体,并提出一个真诚的问题”。在终端中运行:npx xactions engage USERNAME --like --repost --comment --prompt "..."。完整指南:docs/engage.md。

如何在 Twitter/X 上批量取消关注?
  1. 前往 https://x.com/YOUR_USER_NAME/following
  2. 打开开发者控制台。(Mac 上按 COMMAND+ALT+I)
  3. 将脚本粘贴到开发者控制台并运行
// Unfollow everyone on X (Formerly Twitter) and or unfollow who doesn't follow you back, by nich (https://x.com/nichxbt)
// https://github.com/nirholas/xactions
//
// 1. Go to https://x.com/YOUR_USER_NAME/following
// 2. Open the Developer Console. (COMMAND+ALT+I on Mac)
// 3. Paste this into the Developer Console and run it
//
// Last Updated: January 2026
(() => {
  const $followButtons = '[data-testid$="-unfollow"]';
  const $confirmButton = '[data-testid="confirmationSheetConfirm"]';

  const retry = {
    count: 0,
    limit: 3,
  };

  const scrollToTheBottom = () => window.scrollTo(0, document.body.scrollHeight);
  const retryLimitReached = () => retry.count === retry.limit;
  const addNewRetry = () => retry.count++;

  const sleep = ({ seconds }) =>
    new Promise((proceed) => {
      console.log(`WAITING FOR ${seconds} SECONDS...`);
      setTimeout(proceed, seconds * 1000);
    });

  const unfollowAll = async (followButtons) => {
    console.log(`UNFOLLOWING ${followButtons.length} USERS...`);
    await Promise.all(
      followButtons.map(async (followButton) => {
        followButton && followButton.click();
        await sleep({ seconds: 1 });
        const confirmButton = document.querySelector($confirmButton);
        confirmButton && confirmButton.click();
      })
    );
  };

  const nextBatch = async () => {
    scrollToTheBottom();
    await sleep({ seconds: 1 });

    const followButtons = Array.from(document.querySelectorAll($followButtons));
    const followButtonsWereFound = followButtons.length > 0;

    if (followButtonsWereFound) {
      await unfollowAll(followButtons);
      await sleep({ seconds: 2 });
      return nextBatch();
    } else {
      addNewRetry();
    }

    if (retryLimitReached()) {
      console.log(`NO ACCOUNTS FOUND, SO I THINK WE'RE DONE`);
      console.log(`RELOAD PAGE AND RE-RUN SCRIPT IF ANY WERE MISSED`);
    } else {
      await sleep({ seconds: 2 });
      return nextBatch();
    }
  };

  nextBatch();
})();

此脚本:

  • 完全免费。
  • 不会试图让你登录,也不会获取你的个人数据。
  • 自动操作你的网页浏览器,点击取消关注按钮、向下滚动以显示更多内容,然后重复操作。
  • 没有任何花招,所有代码都在这里,你可以准确查看它的作用。
如何查找哪些人取消了对我的关注?

使用 src/detectUnfollowers.js——它会保存一份关注者快照,并在下次运行时进行对比。

如何下载 Twitter/X 视频?

使用 src/scrapers/videoDownloader.js——从任意推文中提取 MP4 URL。

有没有免费的 Twitter API 替代方案?

XActions 使用浏览器自动化,而非 API。无需 API 密钥,没有速率限制,也无需支付每月 100 美元的费用。

Hypefury / Tweethunter 的替代方案?

XActions 是开源项目,对人类用户完全免费。AI Agent 按请求支付小额费用。


⚠️ 免责声明

警告

仅供学习

本项目仅用于学习和研究。这些脚本和工具尚未在个人账号上经过广泛测试。

  • 使用风险自负
  • 对于任何账号限制或封禁,我们概不负责
  • 请始终遵守 X/Twitter 的服务条款
  • 请从小批量操作开始,并谨慎测试

致 X/Twitter: 如果你对本项目有任何顾虑,或希望我们修改或移除任何功能,请直接联系 @nichxbt。我们很乐意与你合作。

致谢: 本项目的灵感源自 X 和 xAI 正在开展的创新。我们钦佩 Elon Musk 将 X 打造为万能应用的愿景,也赞赏 Grok 的 AI 理念。XActions 旨在帮助开发者和研究人员探索平台功能,同时尊重其生态系统。


🚀 快速入门示例

60 秒,无需账号

安装后,大多数读取操作即可使用。你不需要 X 账号、API 密钥或浏览器。

npm install -g xactions

xactions doctor                      # what works right now, and why
xactions profile NASA                # any public account
xactions analyze NASA                # engagement rate, cadence, content mix, best hour
xactions tweets NASA --limit 50 --json | jq -r '.[].text'

然后在真实浏览器中登录一次,即可使用搜索、关注者、正在关注、点赞、书签和私信功能:

xactions connect
xactions search "your topic" --limit 50

不带参数运行 xactions 会按任务分组打印全部 56 条命令。运行 xactions completion bash(或 zsh、fish)即可启用 Tab 补全。

示例 1:取消关注未关注你的人(30 秒)

浏览器控制台:无需安装!

// Go to: x.com/YOUR_USERNAME/following
// Press F12 → Console → Paste this:

(() => {
  const sleep = (s) => new Promise(r => setTimeout(r, s * 1000));
  const run = async () => {
    const buttons = [...document.querySelectorAll('[data-testid$="-unfollow"]')]
      .filter(b => !b.closest('[data-testid="UserCell"]')
        ?.querySelector('[data-testid="userFollowIndicator"]'));
    
    for (const btn of buttons) {
      btn.click();
      await sleep(1);
      document.querySelector('[data-testid="confirmationSheetConfirm"]')?.click();
      await sleep(2);
    }
    window.scrollTo(0, document.body.scrollHeight);
    await sleep(2);
    if (document.querySelectorAll('[data-testid$="-unfollow"]').length) run();
    else console.log('✅ Done! Reload page to continue.');
  };
  run();
})();

命令行:

xactions login
xactions non-followers YOUR_USERNAME --output non-followers.json

Node.js:

import { createBrowser, createPage, scrapeFollowing } from 'xactions';

const browser = await createBrowser();
const page = await createPage(browser);
const following = await scrapeFollowing(page, 'your_username', { limit: 500 });
const nonFollowers = following.filter(u => !u.followsBack);
console.log(`Found ${nonFollowers.length} non-followers`);
await browser.close();

💡 不想编写代码? 使用 xactions.app:登录后点击即可!


示例 2:抓取任意个人资料

浏览器控制台:

// Go to any profile on x.com, then run:

(() => {
  const profile = {
    name: document.querySelector('[data-testid="UserName"]')?.textContent?.split('@')[0]?.trim(),
    username: location.pathname.slice(1),
    bio: document.querySelector('[data-testid="UserDescription"]')?.textContent,
    followers: document.querySelector('a[href$="/followers"] span')?.textContent,
    following: document.querySelector('a[href$="/following"] span')?.textContent,
  };
  console.log(profile);
  copy(JSON.stringify(profile, null, 2)); // Copies to clipboard!
})();

命令行:

xactions profile elonmusk --json

Node.js:

import { createBrowser, createPage, scrapeProfile } from 'xactions';

const browser = await createBrowser();
const page = await createPage(browser);
const profile = await scrapeProfile(page, 'elonmusk');
console.log(profile);
// { name: 'Elon Musk', followers: '200M', bio: '...', ... }
await browser.close();

示例 3:搜索并抓取推文

浏览器控制台:

// Go to: x.com/search?q=YOUR_KEYWORD&f=live

(() => {
  const tweets = [...document.querySelectorAll('article[data-testid="tweet"]')]
    .map(article => ({
      text: article.querySelector('[data-testid="tweetText"]')?.textContent,
      author: article.querySelector('[data-testid="User-Name"] a')?.href?.split('/')[3],
      time: article.querySelector('time')?.getAttribute('datetime'),
    }));
  console.table(tweets);
  copy(JSON.stringify(tweets, null, 2));
})();

命令行:

xactions search "AI startup" --limit 100 --output ai-tweets.json

Node.js:

import { createBrowser, createPage, searchTweets } from 'xactions';

const browser = await createBrowser();
const page = await createPage(browser);
const tweets = await searchTweets(page, 'AI startup', { limit: 100 });
console.log(`Found ${tweets.length} tweets`);
await browser.close();

示例 4:检测谁取消了对你的关注

浏览器控制台:

// Go to: x.com/YOUR_USERNAME/followers

(() => {
  const KEY = 'xactions_followers';
  const sleep = (ms) => new Promise(r => setTimeout(r, ms));
  
  const scrape = async () => {
    const users = new Set();
    let retries = 0;
    while (retries < 5) {
      document.querySelectorAll('[data-testid="UserCell"] a')
        .forEach(a => users.add(a.href.split('/')[3]?.toLowerCase()));
      window.scrollTo(0, document.body.scrollHeight);
      await sleep(1500);
      retries++;
    }
    return [...users].filter(Boolean);
  };

  scrape().then(current => {
    const saved = localStorage.getItem(KEY);
    if (saved) {
      const old = JSON.parse(saved);
      const gone = old.filter(u => !current.includes(u));
      console.log('🚨 Unfollowed you:', gone);
    }
    localStorage.setItem(KEY, JSON.stringify(current));
    console.log(`💾 Saved ${current.length} followers`);
  });
})();

命令行:

# First run saves snapshot
xactions followers YOUR_USERNAME --output snapshot1.json

# Later, compare
xactions followers YOUR_USERNAME --output snapshot2.json
# Use diff tools to compare

示例 5:按关键词自动点赞帖子

浏览器控制台:

// Go to: x.com/search?q=YOUR_KEYWORD&f=live

(async () => {
  const sleep = (s) => new Promise(r => setTimeout(r, s * 1000));
  const liked = new Set();
  
  while (liked.size < 20) { // Like 20 posts
    const buttons = [...document.querySelectorAll('[data-testid="like"]')]
      .filter(b => !liked.has(b));
    
    for (const btn of buttons.slice(0, 3)) {
      btn.click();
      liked.add(btn);
      console.log(`❤️ Liked ${liked.size} posts`);
      await sleep(3 + Math.random() * 2); // Random delay
    }
    window.scrollTo(0, document.body.scrollHeight);
    await sleep(2);
  }
  console.log('✅ Done!');
})();

⚠️ 请放慢速度! Twitter 可能会限制你的请求频率。网站版本会自动处理这一点。


示例 6:退出所有社群

浏览器控制台:

// Go to: x.com/YOUR_USERNAME/communities

(() => {
  const $communityLinks = 'a[href^="/i/communities/"]';
  const $joinedButton = 'button[aria-label^="Joined"]';
  const $confirmButton = '[data-testid="confirmationSheetConfirm"]';
  const $communitiesNav = 'a[aria-label="Communities"]';

  const getLeftCommunities = () => {
    try { return JSON.parse(sessionStorage.getItem('xactions_left_ids') || '[]'); }
    catch { return []; }
  };
  const markAsLeft = (id) => {
    const left = getLeftCommunities();
    if (!left.includes(id)) {
      left.push(id);
      sessionStorage.setItem('xactions_left_ids', JSON.stringify(left));
    }
  };

  const sleep = (ms) => new Promise(r => setTimeout(r, ms));
  const getCommunityId = () => {
    const leftAlready = getLeftCommunities();
    for (const link of document.querySelectorAll($communityLinks)) {
      const match = link.href.match(/\/i\/communities\/(\d+)/);
      if (match && !leftAlready.includes(match[1])) return { id: match[1], element: link };
    }
    return null;
  };

  const run = async () => {
    console.log(`🚀 Left so far: ${getLeftCommunities().length}`);
    await sleep(1500);
    const joinedBtn = document.querySelector($joinedButton);
    if (joinedBtn) {
      const urlMatch = window.location.href.match(/\/i\/communities\/(\d+)/);
      const currentId = urlMatch ? urlMatch[1] : null;
      joinedBtn.click();
      await sleep(1000);
      const confirmBtn = document.querySelector($confirmButton);
      if (confirmBtn) { confirmBtn.click(); if (currentId) markAsLeft(currentId); await sleep(1500); }
      const communitiesLink = document.querySelector($communitiesNav);
      if (communitiesLink) { communitiesLink.click(); await sleep(2500); return run(); }
    }
    const community = getCommunityId();
    if (community) { community.element.click(); await sleep(2500); return run(); }
    else { console.log(`🎉 DONE! Left ${getLeftCommunities().length} communities`); sessionStorage.removeItem('xactions_left_ids'); }
  };
  run();
})();

📖 完整文档:docs/examples/leave-all-communities.md


📋 完整功能列表

功能可用性矩阵
功能控制台脚本CLINode.js网站
抓取
抓取个人资料✅✅✅✅
抓取关注者✅✅✅✅
抓取正在关注的人✅✅✅✅
抓取推文✅✅✅✅
搜索推文✅✅✅✅
抓取推文串✅✅✅✅
抓取话题标签✅✅✅✅
抓取媒体✅✅✅✅
抓取列表成员✅✅✅✅
抓取点赞✅✅✅✅
取消关注
取消关注未关注你的人✅✅✅✅
取消关注所有人✅✅✅✅
智能取消关注(经过 X 天后)⚠️✅✅✅
记录取消关注操作✅✅✅✅
关注
关注用户✅✅✅✅
按关键词关注⚠️✅✅✅
关注互动用户⚠️✅✅✅
关注目标用户的关注者⚠️✅✅✅
互动
给推文点赞✅✅✅✅
转发✅✅✅✅
自动点赞⚠️✅✅✅
自动评论⚠️✅✅✅
发布推文✅✅✅✅
监控
检测取消关注者✅✅✅✅
新关注者提醒✅✅✅✅
监控任意账号✅✅✅✅
持续监控⚠️✅✅✅
社群
退出所有社群✅⚠️⚠️⚠️
Space
发现正在直播的 Space✅✅✅✅
抓取 Space 元数据✅✅✅✅
AI Agent 加入 Space❌✅✅❌
Agent 收听并发言❌✅✅❌
高级功能
多账号❌✅✅✅ 专业版
链接抓取工具✅✅✅✅
增长套件❌✅✅✅ 专业版
客户服务机器人❌✅✅✅ 专业版
MCP 服务(AI Agent)❌✅✅❌
导出为 CSV/JSON✅✅✅✅

图例: ✅ 完整支持 | ⚠️ 基础/手动 | ❌ 不可用


🤖 MCP 服务(AI Agent)

XActions 提供功能最全面的免费 X/Twitter MCP 服务。适用于 Claude、Cursor、Windsurf、VS Code 以及任何 MCP 客户端。

快速设置(30 秒)

添加到你的 Claude Desktop 配置(claude_desktop_config.json):

{
  "mcpServers": {
    "xactions": {
      "command": "npx",
      "args": ["-y", "xactions-mcp"],
      "env": {
        "XACTIONS_SESSION_COOKIE": "your_auth_token_here"
      }
    }
  }
}

获取你的 auth_token:x.com → 开发者工具(F12)→ Application → Cookies → 复制 auth_token 值

或者自动生成配置:

npx xactions mcp-config --client claude
npx xactions mcp-config --client cursor
npx xactions mcp-config --client windsurf
可用的 MCP 工具(152)
类别工具
抓取x_get_profile, x_get_followers, x_get_following, x_get_tweets, x_search_tweets, x_get_thread, x_download_video, x_get_replies, x_get_hashtag, x_get_likers, x_get_retweeters, x_get_media, x_get_mentions, x_get_quote_tweets, x_get_likes, x_get_recommendations
分析x_detect_unfollowers, x_analyze_sentiment, x_best_time_to_post, x_competitor_analysis, x_brand_monitor, x_audience_insights, x_engagement_report, x_crypto_analyze
操作x_follow, x_unfollow, x_like, x_post_tweet, x_post_thread, x_reply, x_retweet, x_quote_tweet, x_bookmark, x_send_dm, x_create_poll, x_delete_tweet
自动化x_auto_follow, x_follow_engagers, x_unfollow_all, x_smart_unfollow, x_auto_comment, x_auto_retweet, x_auto_like, x_engage, x_unfollow_non_followers
AIx_analyze_voice, x_generate_tweet, x_summarize_thread, x_rewrite_tweet, x_detect_bots, x_find_influencers, x_smart_target, x_grok_analyze_image
监控x_monitor_account, x_monitor_keyword, x_follower_alerts, x_track_engagement, x_monitor_reputation, x_stream_start
工作流x_workflow_create, x_workflow_run, x_workflow_list, x_workflow_actions
角色设定x_persona_create, x_persona_run, x_persona_edit, x_persona_list, x_persona_presets
可移植性x_export_account, x_migrate_account, x_diff_exports, x_import_data, x_convert_format
Spacesx_get_spaces, x_scrape_space, x_space_join, x_space_leave, x_space_status, x_space_transcript
图谱x_graph_build, x_graph_analyze, x_graph_recommendations, x_graph_list
草稿x_list_drafts, x_approve_draft, x_discard_draft, x_draft_status

每个工具都只属于一个组,并且列表可筛选,因此客户端只会加载会话所需的工具:

npx xactions-mcp --tools read,analytics     # advertise these groups only
npx xactions-mcp --exclude write,dm         # or subtract from the full list
XACTIONS_MCP_TOOLS=read npx xactions-mcp    # same thing through the environment

经过筛选的工具既不会公开,也无法调用。各组按数量从多到少排列: read、analytics、write、monitoring、data、workflows、automation、 ai、persona、spaces、graph、drafts、dm、grok、lists、auth, 此外,服务以远程模式运行时还会有 x402。

所有写入操作均须由人工审核
XACTIONS_MCP_REQUIRE_APPROVAL=1 npx xactions-mcp

此后,所有发帖、删除、关注、静音或发送的工具都会保存为草稿,而不会直接执行。可使用 x_list_drafts、 x_approve_draft 和 x_discard_draft 发布或丢弃草稿;也可在 shell 中使用 xactions drafts list、xactions drafts approve <id> 和 xactions drafts discard <id> 操作。

无论是否启用此限制,每个写入操作都会计入按账号计算的滚动 24 小时上限。上限信息保存在 ~/.xactions 下的文件中,因此重启后仍会保留;任何会超出上限的调用都不会发送到 X。

通过 HTTP 运行服务
npx xactions-mcp --http --port 3000    # Streamable HTTP on /mcp

stdio 是默认模式,也是本地客户端所需的模式。--http(或 MCP_TRANSPORT=http)适用于远程和托管客户端;设置 XACTIONS_MCP_TOKEN 后,将要求提供 Authorization: Bearer <token>。

无需配置文件即可安装到 Claude Desktop

.mcpb 安装包包含服务及其依赖项,并会在安装时提示输入会话 Cookie 和工具组。从 最新版本下载,然后将其拖到 Claude Desktop > Settings > Extensions。

示例提示词

“分析 @paulg 的写作风格,并用他的口吻生成 3 条关于初创公司的推文创意” → 抓取推文 → 分析口吻 → 使用 AI 生成内容

“找出我关注的所有没有回关我的人,并按粉丝数排序” → 使用 x_get_following + x_get_followers → 计算差集 → 格式化结果

“比较 @openai、@anthropic 和 @google 的互动指标” → 抓取个人资料和近期推文 → 计算平均互动量 → 展示对比结果

📖 完整设置指南:docs/mcp-setup.md


🎙️ 自主 Space Agent

AI Agent 可以加入实时 X Spaces、聆听对话,并使用语音 AI 自主发言。由 xspace-agent SDK 提供支持。

功能介绍
  1. 启动无头浏览器并加入 X Space
  2. 实时转录其他发言者的内容(Whisper STT)
  3. 使用你选择的大模型(OpenAI、Claude 或 Groq)生成智能回复
  4. 通过文本转语音功能(ElevenLabs、OpenAI 或浏览器)在 Space 中朗读回复
  5. 处理轮流发言、上下文跟踪和正常关闭
设置
npm install xactions xspace-agent

设置你的凭据:

export X_AUTH_TOKEN="your_auth_token"     # From x.com cookies
export X_CT0="your_ct0_token"            # From x.com cookies
export OPENAI_API_KEY="sk-..."           # Or ANTHROPIC_API_KEY / GROQ_API_KEY
用法

MCP(Claude Desktop / Cursor):

“以 AI Agent 身份加入这个 Space:https://x.com/i/spaces/1abc123”

Claude 会调用 x_space_join,你的 Agent 随即进入 Space。

Node.js:

import { joinSpace, leaveSpace } from 'xactions/spaces/agent';

await joinSpace({
  url: 'https://x.com/i/spaces/1abc123',
  provider: 'openai',
  systemPrompt: 'You are a helpful AI participant. Keep responses concise.',
});

// Later...
const summary = await leaveSpace();
// { duration: '300s', transcriptions: 42, responses: 8 }

MCP 工具:

工具说明
x_space_join使用自主 AI 语音 Agent 加入 Space
x_space_leave离开当前 Space 并获取会话摘要
x_space_status获取 Agent 状态(持续时间、转录/回复次数)
x_space_transcript获取当前 Space 的近期转录内容

📖 完整指南:docs/spaces-agent.md:配置、环境变量、事件、多 Agent 设置和示例。


💻 CLI 参考

包含 56 个按任务分组的命令,以及 85 个子命令。运行 xactions (不带参数)可查看分组界面;运行 xactions help <command> 可查看某个 命令的帮助;运行 xactions completion bash|zsh|fish 可根据实时命令树生成 制表符补全。

从这里开始 quickstart doctor connect login logout mcp-config skills drafts info

xactions quickstart         # guided first run, adapts to what you already have
xactions doctor             # what works right now, and what each failure needs
xactions connect            # log in through a real browser, no DevTools
xactions login --from-browser chrome    # or read cookies from an installed browser
xactions login --cookies-file cookies.txt   # or import a cookie export
xactions skills install --all           # 50 agent skills into Claude Code, Cursor, Codex, Windsurf
xactions drafts list                    # MCP writes waiting for your approval

读取账户信息(无需登录)profile tweets thread media analyze report history snapshot

xactions profile NASA
xactions tweets NASA --limit 50 --output nasa.csv
xactions thread https://x.com/NASA/status/1234567890
xactions media NASA --limit 30
xactions analyze NASA SpaceX          # engagement rate, cadence, content mix, best hour

关注者和受众 followers following non-followers audience crm graph

xactions followers YOUR_USERNAME --limit 1000 --output followers.json
xactions non-followers YOUR_USERNAME  # who does not follow back
xactions audience nasa spacex         # follower overlap between two accounts
xactions graph build nasa             # build and analyse a social graph

搜索和监控 search hashtag scrape platforms monitor sentiment rss stream

xactions search "your brand" --filter latest --limit 50
xactions hashtag ai --limit 50
xactions monitor yourbrand            # sentiment over time
xactions stream start tweet nasa      # tweet, follower or mention streams

创作和增长 engage ai optimize hashtags predict variations evergreen persona schedule bulk

xactions engage USERNAME --like --repost --comment --prompt "supportive, one honest question"
xactions ai generate "shipping fast" --voice nichxbt
xactions evergreen YOUR_USERNAME      # find and recycle top performers
xactions persona run my-persona

自动化 workflow agent notify plugin team dataset

xactions workflow run daily-digest
xactions notify test slack

迁移数据 export export-data archive import convert migrate diff

xactions export YOUR_USERNAME             # profile, tweets, followers, following, bookmarks
xactions archive summary ~/Downloads/twitter-archive.zip
xactions archive migrate ~/Downloads/twitter-archive.zip --to bluesky --execute
xactions diff exports/january exports/february

底层操作 client

xactions client profile nasa          # the raw HTTP client, no browser at all
Agent 和管道的输出标志

所有读取命令均可使用以下全局标志:

xactions profile NASA --compact                              # one record per line, key=value
xactions tweets NASA --limit 200 --fields id,likes,text --compact
xactions tweets NASA --limit 200 --json | jq 'sort_by(-.likes) | .[:5]'

--compact 会以制表符分隔的 key=value 键值对形式输出,不显示颜色或加载动画。 --fields 会按你指定的顺序,仅输出指定的列。 --json 会输出完整的结构化对象,且优先级高于 --output,因此管道输出 不会被静默写入文件。如果同时传入 --compact 和 --json,则以 --compact 为准。

无需账户即可读取公开信息:profile、tweets、thread、media、 analyze、hashtag。搜索、followers、following、non-followers、点赞、 书签和私信均需要会话。完整参考文档: docs/cli-reference.md。


📚 Node.js API

快速入门
import { 
  createBrowser, 
  createPage, 
  loginWithCookie,
  scrapeProfile,
  scrapeFollowers,
  scrapeFollowing,
  scrapeTweets,
  searchTweets,
  exportToJSON,
  exportToCSV 
} from 'xactions';

// Initialize
const browser = await createBrowser({ headless: true });
const page = await createPage(browser);

// Optional: Login for private data
await loginWithCookie(page, 'your_auth_token_cookie');

// Scrape profile
const profile = await scrapeProfile(page, 'elonmusk');

// Scrape followers with progress
const followers = await scrapeFollowers(page, 'elonmusk', {
  limit: 1000,
  onProgress: ({ scraped, limit }) => console.log(`${scraped}/${limit}`)
});

// Export data
await exportToJSON(followers, 'followers.json');
await exportToCSV(followers, 'followers.csv');

await browser.close();
所有抓取器函数
// Profile
scrapeProfile(page, username)

// Followers & Following
scrapeFollowers(page, username, { limit, onProgress })
scrapeFollowing(page, username, { limit, onProgress })

// Tweets
scrapeTweets(page, username, { limit, includeReplies, onProgress })
searchTweets(page, query, { limit, filter: 'latest'|'top' })
scrapeThread(page, tweetUrl)
scrapeHashtag(page, hashtag, { limit, filter })

// Media
scrapeMedia(page, username, { limit })
scrapeLikes(page, tweetUrl, { limit })

// Lists
scrapeListMembers(page, listUrl, { limit })

// Export
exportToJSON(data, filename)
exportToCSV(data, filename)

🌐 不想编写代码?

访问 xactions.app,获取无需编写代码的解决方案

使用浏览器脚本  ·  复制并粘贴控制台脚本  ·  查看教程

完全免费。 无需 API 密钥,无需付费,没有限制。


🔒 安全与最佳实践

速率限制:内置 1-3s 延迟、模拟真人滚动,达到速率限制时自动暂停

身份验证令牌:x.com → DevTools (F12) → Application → Cookies → 复制 auth_token

注意

建议: 使用 2–5s 延迟 · 将自动操作与手动操作结合 · 先用小批量进行测试

避免: 每天大量关注数千人 · 全天候运行 · 垃圾评论


🛠️ 技术栈

Node.js Puppeteer Express Prisma Socket.IO Redis Docker MCP SDK


📁 项目结构

列出所有顶层目录,让这里的内容一目了然。

src/            The library. cli/ mcp/ scrapers/ client/ automation/ agents/
                analytics/ streaming/ workflows/ plugins/ portability/ graph/
                a2a/ spaces/ ai/ auth/ scheduler/ notifications/, plus the
                browser console scripts that sit at the top level
api/            Express REST API: routes/ services/ middleware/ realtime/
bin/            Legacy command name (unfollowx), forwards to the CLI
packages/       xactions-mcp, the thin MCP wrapper published to npm
skills/         50 Agent Skills, one directory each
extension/      Chrome and Edge extension (Manifest V3)
integrations/   Third-party glue (n8n and friends)
worker/         Cloudflare Worker entry point
functions/      Cloudflare Pages Functions for the /api/* edge surface

site/           The marketing landing page served at /
dashboard/      The signed-in app shell at /dashboard, plus the generated
                docs, guides, skills and script pages the site serves
public/         Static assets: OG images, robots.txt, sitemap
playground/     Standalone in-browser playground

docs/           Documentation source (Markdown)
tutorials/      Guided walkthroughs
examples/       Runnable programs, from a profile lookup to the MCP draft gate
prompts/        Prompt library for coding agents

tests/          Vitest suite
scripts/        The 95 browser console scripts, plus build, docs and
                maintenance tooling. twitter/ holds standalone console variants
config/         Agent, niche and persona configuration
prisma/         Database schema and migrations
deploy/         Cloudflare and GCP deployment assets
types/          TypeScript declarations
data/           Runtime output (gitignored, keeps a .gitkeep)
archive/        Retired code, kept for reference. Do not modify

python/         xeepy, the Python twin of the library
xspace-agents/  The Spaces agent monorepo

python/ 和 xspace-agents/ 都是自包含项目,位于此仓库中,但各自独立构建。请从它们的 README 开始,而不是从本文档开始。


🤝 参与贡献

欢迎贡献。请参阅 CONTRIBUTING.md,并查看 AGENTS.md,了解仓库结构图和三种运行时上下文。

git clone https://github.com/nirholas/xactions.git
cd xactions && npm install
npm run cli -- profile elonmusk   # run the CLI from the source tree
npm run mcp                       # run the MCP server

需要 Node.js 22.12 或更高版本(engines.node 为 >=22.12);CI 会在 22 和 24 版本上运行测试套件。提交 PR 前请运行以下三个命令,它们也都会在 CI 中运行:

npm test              # the whole suite, offline, under a minute
npm run lint          # ESLint over the repo
npm run docs:check    # dead links, stale counts, invented CLI commands
贡献者

感谢所有通过代码、错误报告和调查让 XActions 变得更好的人,包括 @RandyLu87、 @ni3a、 @nelsongallardo、 @azeezalhajj570-ai、 @stone-w4tch3r 和 @avner-assistant。完整名单以及每个人的发现或构建内容,请见 CONTRIBUTORS.md。只要提交了准确的错误报告,就能和合并的 PR 一样获得列名机会。


⭐ Star 历史

如果 XActions 帮你省下了每月为 Twitter API 支付的 100 美元,请给仓库点个 Star:这正是开源发展的动力。

Star 历史图表

📚 完整教程库

XActions 完全免费且开源。 访问 xactions.app 查看交互式教程。

🚀 一键脚本运行器

全新功能! 无需任何编程知识即可运行脚本:

  1. 访问 xactions.app/run.html
  2. 将任意蓝色按钮拖到书签栏
  3. 前往 x.com 并点击书签脚本

无需控制台,无需代码,无需设置!

按类别快速链接
类别脚本教程
取消关注取消关注所有人、取消关注未回关者、智能取消关注教程
自动化自动点赞、自动评论、关注互动者教程
抓取视频下载、关注者、推文、话题标签教程
监控检测取关者、跟踪账号、提醒教程
社群退出所有社群教程
AI/MCPClaude Desktop、GPT 集成教程
全部文档
示例文档(完整代码)
功能文档
取消关注所有人unfollow-everyone.md
取消关注未回关者unfollow-non-followers.md
检测取关者detect-unfollowers.md
自动点赞auto-liker.md
自动评论auto-commenter.md
关注互动者follow-engagers.md
视频下载器video-downloader.md
抓取关注者followers-scraping.md
抓取推文tweet-scraping.md
退出社群leave-all-communities.md
MCP 服务mcp-server.md
监控账号monitor-account.md
新关注者提醒new-follower-alerts.md

⚡ XActions,完整的 X/Twitter 自动化工具包
100% 免费且开源 · Apache 2.0 许可证

xactions.app · GitHub · @nichxbt

为此仓库点星  报告 Bug  请求功能


🌐 通过 HTTP 运行 MCP 服务

stdio 是默认传输方式,也是本地客户端所需的方式。对于远程或托管客户端,同一服务可在 /mcp 上使用 MCP Streamable HTTP, 并提供相同的 154 个工具和相同的工具组筛选功能:

npx xactions-mcp --http --port 3000
# or: MCP_TRANSPORT=http PORT=3000 npx xactions-mcp

设置 XACTIONS_MCP_TOKEN 即可要求客户端提供令牌;客户端随后发送 Authorization: Bearer <token>。

从任意 MCP 客户端连接
{
  "mcpServers": {
    "xactions": {
      "type": "http",
      "url": "http://localhost:3000/mcp"
    }
  }
}
在 Shell 中检查
curl -X POST http://localhost:3000/mcp \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'

要将其部署到公开环境?请在 TLS 后运行,并设置 XACTIONS_MCP_TOKEN, 同时优先选择范围较窄的工具集(--tools read,analytics),而不是完整列表。 Dockerfile 和 docs/deployment.md 介绍了 Railway、Fly.io、Docker 和 Cloudflare 的部署方式。


🏆 完整对比矩阵

扩展的逐项功能对比,涵盖所有替代方案。

功能XActionstwikittwscrapex-usexmcp(官方)birdtwitter-cliAgent-Reach
Node.js 库✅❌ Python❌ Python✅✅✅❌ Python❌ Python
工作流引擎✅❌❌❌❌❌❌❌
情感分析✅ 内置❌❌❌❌❌❌❌
实时流✅ 轮询流 + x.com 的实时事件管道✅ live_pipeline❌❌✅ 仅 API❌❌❌
账号导出/迁移✅ JSON/CSV/HTML,以及官方 X archive zip❌❌❌❌❌❌❌
仪表板(无代码)✅❌❌❌❌❌❌❌
Grok AI 集成✅✅ 独立包❌❌❌❌❌❌
Docker 支持✅❌❌❌❌❌❌❌
TypeScript 类型✅❌❌✅✅✅❌❌
MCP 工具允许列表✅ 17 组不适用不适用❌✅不适用不适用不适用
通过 Streamable HTTP 使用 MCP✅ /mcp 上的 --http不适用不适用❌✅不适用不适用不适用
签名的出站 Webhook✅ HMAC-SHA256、重试、重放❌❌❌❌❌❌❌
Claude 教程✅ 23 个提示词❌❌❌❌❌❌❌
多平台(X + 其他平台)✅ Bluesky、Mastodon、Threads❌❌❌❌❌❌✅
费用免费免费免费免费免费 + X API 计划免费免费 + X API 计划免费

本对比反映了撰写时(2026 年 8 月)各项目公开 README 中的信息;如果某一列已过时,请提交 issue。

文档

完整文档网站:https://nirholas.github.io/XActions/

  • 开始使用介绍安装和首次运行。
  • 示例包含可直接复制粘贴的代码片段。

支持这个项目

如果 XActions 为你节省了时间,请在 GitHub 上点星。星标能帮助其他开发者和 AI Agent 找到值得信赖的仓库,而且只需点击一下。

认识可能会用到它的人吗?发布到 X · 分享到 Bluesky · 分享到 LinkedIn · 提交到 Hacker News · 分享到 Reddit

同样为 AI Agent 打造

编码 Agent 和大模型工具可以直接读取此仓库:AGENTS.md、llms.txt、llms-full.txt。将 https://github.com/nirholas/XActions 提供给 Agent,它就能获取所需的上下文。

同一作者的更多项目

Contributors

Contributors

评论

支持 Markdown

第一次接触 MCP?

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

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