xengager-mcp
Provides programmatic X (Twitter) engagement via MCP, offering 24 tools for search, timelines, notifications, bookmarks, profiles, and tweet actions through a headless browser.
README
xengager-mcp
X (Twitter) engagement via Model Context Protocol — programmatic access through a headless browser.
24 tools across 6 domains: search, timelines, notifications, bookmarks, profiles, and tweet interactions. Designed for Claude Code, Cursor, and any MCP-compatible client.
Features
| Domain | Tools | Description |
|---|---|---|
| Timeline | x_home_timeline, x_following_timeline, x_explore, x_trends |
Home feed, following feed, explore tab, trending topics |
| Search | x_search |
Full-text search with operators (from:, since:, lang:, min_likes:, etc.) |
| Notifications | x_notifications |
All notifications or filtered to mentions, with pagination |
| Bookmarks | x_bookmarks |
Authenticated user's saved tweets |
| Profile | x_user_profile, x_user_posts, x_user_replies, x_user_following, x_user_followers, x_user_likes, x_user_media, x_user_articles |
Full profile access including media, articles, and social graph |
| Tweet Actions | x_get_tweet, x_tweet_replies, x_like, x_unlike, x_repost, x_unrepost, x_bookmark, x_unbookmark, x_quote_tweet, x_reply, x_post_tweet |
Read, engage, compose, and post threads |
All tools are idempotent and return errors inside the JSON payload — never as MCP protocol errors.
Architecture
┌──────────────────────────────────────────┐
│ MCP Client (Claude Code, Cursor, etc.) │
└──────────────────┬───────────────────────┘
│ Streamable HTTP / stdio
┌──────────────────▼───────────────────────┐
│ xengager-mcp Server │
│ ┌──────────┐ ┌──────────────────────┐ │
│ │ GraphQL │ │ DOM Scraping │ │
│ │ (primary) │ │ (Puppeteer fallback) │ │
│ └──────────┘ └──────────────────────┘ │
│ ┌──────────────────────────────────────┐│
│ │ Puppeteer + stealth plugin ││
│ │ (anti-bot detection evasion) ││
│ └──────────────────────────────────────┘│
└──────────────────────────────────────────┘
- GraphQL-first: Most read operations use X's internal GraphQL API for speed and reliability
- DOM fallback: Actions (like, repost, reply) use Puppeteer with randomized delays and human-like mouse movement
- Single browser instance: All tools share one page — calls are serialized naturally via MCP transport
Prerequisites
- Bun ≥ 1.1
- Chrome/Chromium (auto-installed by Puppeteer, or use system Chrome in Docker)
- X (Twitter) account with valid auth cookies
Obtaining X Credentials
- Log into x.com in Chrome
- Open DevTools → Application → Cookies → x.com
- Copy the values for
auth_tokenandct0
Quick Start
# Clone and install
git clone https://github.com/YOUR_USERNAME/xengager-mcp.git
cd xengager-mcp
bun install
# Configure credentials
cp .env.example .env
# Edit .env — paste your X_AUTH_TOKEN and X_CT0 values
# Run (stdio transport — for local MCP integration)
bun run stdio
# Or run as HTTP server (for remote/ngrok setups)
bun run start
Docker
# With ngrok tunneling (public MCP endpoint)
docker compose up
# Without ngrok
docker compose up mcp
The ngrok tunnel's public URL is printed on startup. Point your MCP client at it.
MCP Client Configuration
Claude Code
{
"mcpServers": {
"xengager": {
"command": "bun",
"args": ["run", "stdio"],
"cwd": "/path/to/xengager-mcp"
}
}
}
Remote (ngrok)
{
"mcpServers": {
"xengager": {
"type": "http",
"url": "https://your-tunnel.ngrok.io/mcp",
"headers": {
"Authorization": "Bearer your-mcp-api-key"
}
}
}
}
Set MCP_API_KEY in .env to enable Bearer token authentication on the HTTP server.
Quick Usage Examples
"What's trending?" → x_trends
"Search for AI news" → x_search("AI news", tab: "top")
"Show me @OpenAI's tweets" → x_user_posts("OpenAI")
"Get my notifications" → x_notifications
"Like and bookmark this" → x_like(url) → x_bookmark(url)
"Post a thread" → x_post_tweet(["Part 1", "Part 2", "Part 3"])
See SKILL.md for the complete agent usage guide with response shapes, pagination patterns, and workflow recipes.
Environment Variables
| Variable | Required | Description |
|---|---|---|
X_AUTH_TOKEN |
Yes | X.com auth_token cookie |
X_CT0 |
Yes | X.com ct0 cookie (CSRF token) |
PORT |
No | HTTP server port (default: 3000) |
MCP_API_KEY |
No | Bearer token for HTTP auth |
ALLOWED_ORIGINS |
No | Comma-separated CORS origins (default: *) |
NGROK_AUTHTOKEN |
No | Required for ngrok tunneling in docker compose |
Testing
bun test
Tests cover browser lifecycle, pagination logic, GraphQL client/parser/cache, and individual tools.
License
MIT © [Your Name]
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。