Twitter MCP Server
快速安装
首先,前往 http://app.newsliquid.com/mcp 获取你的 API Token。
Claude Code
claude mcp add twitter \
-e OPENNEWS_TOKEN=<your-token> \
-- uv --directory /path/to/twitter-mcp run twitter-mcp将
/path/to/twitter-mcp替换为你本地项目路径,将<your-token>替换为你的 Token。
OpenClaw
export OPENNEWS_TOKEN="<your-token>"
cp -r openclaw-skill/opentwitter ~/.openclaw/skills/Related MCP server: Apex MCP for X Management
让 AI 帮你审核并安装
不确定这个 MCP 是否安全?将下面的提示词粘贴给你的 AI 助手——它会先审查源代码,确认安全后再安装:
复制这段提示词并发送给你的 AI 助手(将
<project-path>和<your-token>替换为实际值):
Please review and install the twitter-mcp MCP server for me. The project is at <project-path>.
Steps:
1. Review these files for security:
- src/twitter_mcp/api_client.py — Confirm it only connects to ai.6551.io, no data sent elsewhere
- src/twitter_mcp/config.py — Confirm token is only read from local config.json or env vars, no hardcoded secrets or leaks
- src/twitter_mcp/tools.py — Confirm all tools only perform API queries, no file writes, command execution, or dangerous operations
- pyproject.toml — Confirm dependencies are only mcp, httpx, no suspicious packages
2. Tell me your conclusion: safe / risky / problematic, with specific reasons
3. If safe, run the install (get Token from http://app.newsliquid.com/mcp):
claude mcp add twitter -e OPENNEWS_TOKEN=<your-token> -- uv --directory <project-path> run twitter-mcp它能做什么?
连接完成后,你只需直接告诉你的 AI 助手:
你说什么 | 它会做什么 |
"查看 @elonmusk 的 Twitter 主页" | 获取用户主页信息 |
"@VitalikButerin 最近发了什么推文" | 获取用户最近的推文 |
"搜索关于 Bitcoin 的推文" | 关键词搜索 |
"查找带 #crypto 标签的推文" | 话题标签搜索 |
"关于 ETH 且超过 1000 赞的热门推文" | 带互动筛选的搜索 |
"用粉丝追踪功能监控 @elonmusk" | 添加用户到监视列表并附带选项 |
"谁引用了这条推文" | 获取某条推文的引用推文 |
"谁转发了这条推文" | 获取转发了某条推文的用户 |
"最近谁关注了 @elonmusk" | 获取新增粉丝事件 |
"谁取关了 @elonmusk" | 获取取关事件 |
"@elonmusk 删除了哪些推文" | 获取已删除的推文 |
"哪些 KOL 关注了 @elonmusk" | 获取 KOL 粉丝 |
可用工具
工具 | 描述 |
| 通过用户名获取用户主页 |
| 通过数字 ID 获取用户主页 |
| 获取某用户最近的推文 |
| 使用基础筛选条件搜索推文 |
| 使用多重筛选条件的高级搜索 |
| 获取关注/取关事件 |
| 获取某用户已删除的推文 |
| 获取 KOL(关键意见领袖)粉丝 |
| 通过 ID 获取 Twitter 文章 |
| 通过 ID 获取推文(包含嵌套的回复/引用推文) |
| 获取引用了某条推文的所有推文 |
| 获取转发了某条推文的用户 |
| 获取所有 Twitter 监控用户 |
| 添加 Twitter 用户到监控列表(带事件类型选项) |
| 从监控列表中删除 Twitter 用户 |
配置
获取 API Token
前往 http://app.newsliquid.com/mcp 获取你的 API Token。
设置环境变量:
# macOS / Linux
export OPENNEWS_TOKEN="<your-token>"
# Windows PowerShell
$env:OPENNEWS_TOKEN = "<your-token>"变量 | 是否必须 | 描述 |
| 是 | 6551 API Bearer Token(从 http://app.newsliquid.com/mcp 获取) |
| 否 | 覆盖 REST API URL |
| 否 | 每次查询的最大结果数(默认:100) |
同时支持项目根目录下的 config.json(环境变量优先):
{
"api_base_url": "https://ai.6551.io",
"api_token": "<your-token>",
"max_rows": 100
}WebSocket 实时订阅
端点:wss://ai.6551.io/open/twitter_wss?token=YOUR_TOKEN
订阅你监控的 Twitter 账号的实时事件。
心跳
为保持连接存活,客户端可发送 ping,服务器将回复 pong。
订阅 Twitter 事件
{
"jsonrpc": "2.0",
"id": 1,
"method": "twitter.subscribe"
}响应:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"success": true
}
}取消订阅
{
"jsonrpc": "2.0",
"id": 2,
"method": "twitter.unsubscribe"
}服务器推送——Twitter 事件
当被监控的账号有活动时,服务器会推送:
{
"jsonrpc": "2.0",
"method": "twitter.event",
"params": {
"id": 123456,
"twAccount": "elonmusk",
"twUserName": "Elon Musk",
"profileUrl": "https://twitter.com/elonmusk",
"eventType": "NEW_TWEET",
"content": "...",
"ca": "0x1234...",
"remark": "Custom note",
"createdAt": "2026-03-06T10:00:00Z"
}
}注意:content 字段的结构因事件类型而异(见下文)。
**Event Types and Content Structure**:
#### Tweet Events
- `NEW_TWEET` - New tweet posted
- `NEW_TWEET_REPLY` - New reply tweet
- `NEW_TWEET_QUOTE` - New quote tweet
- `NEW_RETWEET` - Retweeted
- `CA` - Tweet with CA address
Content structure for tweet events:
```json
{
"id": "1234567890",
"text": "Tweet content...",
"createdAt": "2026-03-06T10:00:00Z",
"language": "en",
"retweetCount": 100,
"favoriteCount": 500,
"replyCount": 20,
"quoteCount": 10,
"viewCount": 10000,
"userScreenName": "elonmusk",
"userName": "Elon Musk",
"userIdStr": "44196397",
"userFollowers": 170000000,
"userVerified": true,
"conversationId": "1234567890",
"isReply": false,
"isQuote": false,
"hashtags": ["crypto", "bitcoin"],
"media": [
{
"type": "photo",
"url": "https://...",
"thumbUrl": "https://..."
}
],
"urls": [
{
"url": "https://...",
"expandedUrl": "https://...",
"displayUrl": "example.com"
}
],
"mentions": [
{
"username": "VitalikButerin",
"name": "Vitalik Buterin"
}
]
}粉丝事件
NEW_FOLLOWER- 该账号关注了某用户NEW_UNFOLLOWER- 该账号取关了某用户
粉丝事件的 content 结构(数组):
[
{
"id": 123,
"twId": 44196397,
"twAccount": "elonmusk",
"twUserName": "Elon Musk",
"twUserLabel": "Verified",
"description": "User bio...",
"profileUrl": "https://...",
"bannerUrl": "https://...",
"followerCount": 170000000,
"friendCount": 500,
"createdAt": "2026-03-06T10:00:00Z"
}
]主页更新事件
UPDATE_NAME- 用户名变更(content:新的名字字符串)UPDATE_DESCRIPTION- 个人简介更新(content:新的简介字符串)UPDATE_AVATAR- 头像更换(content:新的头像 URL 字符串)UPDATE_BANNER- 横幅图片更换(content:新的横幅 URL 字符串)
其他事件
TWEET_TOPPING- 推文置顶DELETE- 推文删除SYSTEM- 系统事件TRANSLATE- 推文翻译CA_CREATE- CA 代币创建
数据结构
Twitter 用户
{
"userId": "44196397",
"screenName": "elonmusk",
"name": "Elon Musk",
"description": "...",
"followersCount": 170000000,
"friendsCount": 500,
"statusesCount": 30000,
"verified": true
}推文
{
"id": "1234567890",
"text": "Tweet content...",
"createdAt": "2024-02-20T12:00:00Z",
"retweetCount": 1000,
"favoriteCount": 5000,
"replyCount": 200,
"userScreenName": "elonmusk",
"hashtags": ["crypto", "bitcoin"],
"urls": [{"url": "https://..."}]
}在以下所有配置中,将
/path/to/twitter-mcp替换为你实际的本地项目路径,将<your-token>替换为从 http://app.newsliquid.com/mcp 获取的 Token。
Claude Desktop
编辑配置(macOS:~/Library/Application Support/Claude/claude_desktop_config.json,Windows:%APPDATA%\Claude\claude_desktop_config.json):
{
"mcpServers": {
"twitter": {
"command": "uv",
"args": ["--directory", "/path/to/twitter-mcp", "run", "twitter-mcp"],
"env": {
"OPENNEWS_TOKEN": "<your-token>"
}
}
}
}Cursor
~/.cursor/mcp.json 或设置 > MCP 服务器:
{
"mcpServers": {
"twitter": {
"command": "uv",
"args": ["--directory", "/path/to/twitter-mcp", "run", "twitter-mcp"],
"env": {
"OPENNEWS_TOKEN": "<your-token>"
}
}
}
}Windsurf
~/.codeium/windsurf/mcp_config.json:
{
"mcpServers": {
"twitter": {
"command": "uv",
"args": ["--directory", "/path/to/twitter-mcp", "run", "twitter-mcp"],
"env": {
"OPENNEWS_TOKEN": "<your-token>"
}
}
}
}Cline
VS Code 侧边栏 > Cline > MCP 服务器 > 配置,编辑 cline_mcp_settings.json:
{
"mcpServers": {
"twitter": {
"command": "uv",
"args": ["--directory", "/path/to/twitter-mcp", "run", "twitter-mcp"],
"env": {
"OPENNEWS_TOKEN": "<your-token>"
},
"disabled": false,
"autoApprove": []
}
}
}Continue.dev
~/.continue/config.yaml:
mcpServers:
- name: twitter
command: uv
args:
- --directory
- /path/to/twitter-mcp
- run
- twitter-mcp
env:
OPENNEWS_TOKEN: <your-token>Cherry Studio
设置 > MCP 服务器 > 添加 > 类型 stdio:命令 uv,参数 --directory /path/to/twitter-mcp run twitter-mcp,环境变量 OPENNEWS_TOKEN。
Zed Editor
~/.config/zed/settings.json:
{
"context_servers": {
"twitter": {
"command": {
"path": "uv",
"args": ["--directory", "/path/to/twitter-mcp", "run", "twitter-mcp"],
"env": {
"OPENNEWS_TOKEN": "<your-token>"
}
}
}
}
}任意 stdio MCP 客户端
OPENNEWS_TOKEN=<your-token> \
uv --directory /path/to/twitter-mcp run twitter-mcp兼容性
客户端 | 安装方式 | 状态 |
Claude Code |
| 一行命令 |
OpenClaw | 复制技能目录 | 一行命令 |
Claude Desktop | JSON 配置 | 已支持 |
Cursor | JSON 配置 | 已支持 |
Windsurf | JSON 配置 | 已支持 |
Cline | JSON 配置 | 已支持 |
Continue.dev | YAML / JSON | 已支持 |
Cherry Studio | 图形界面 | 已支持 |
Zed | JSON 配置 | 已支持 |
开发
cd /path/to/twitter-mcp
uv sync
uv run twitter-mcp# MCP Inspector
npx @modelcontextprotocol/inspector uv --directory /path/to/twitter-mcp run twitter-mcp项目结构
├── README.md
├── docs/
│ ├── README_JA.md # 日本語
│ └── README_KO.md # 한국어
├── openclaw-skill/opentwitter/ # OpenClaw Skill
├── pyproject.toml
├── config.json
└── src/twitter_mcp/
├── server.py # Entry point
├── app.py # FastMCP instance
├── config.py # Config loader
├── api_client.py # HTTP client
└── tools.py # 8 tools许可证
MIT
Available Tools
12 toolsadd_twitter_watchB
Add a Twitter user to monitoring list.
Args: username: Twitter username to monitor (without @).
Inputs: username (required).
delete_twitter_watchC
Delete a Twitter user from monitoring list.
Args: watch_id: The monitoring record ID to delete.
Inputs: watch_id (required).
get_twitter_article_by_idC
Get Twitter article by ID.
Args: article_id: Twitter article ID.
Inputs: article_id (required).
get_twitter_deleted_tweetsB
Get deleted tweets from a Twitter/X user.
Args: username: Twitter username (without @). limit: Maximum tweets to return (default 20, max 100).
Inputs: username (required), limit.
get_twitter_follower_eventsB
Get follower/unfollower events for a Twitter/X user.
Args: username: Twitter username (without @). is_follow: True for new followers, False for unfollowers. limit: Maximum events to return (default 20, max 100).
Inputs: username (required), is_follow, limit.
get_twitter_kol_followersC
Get KOL (Key Opinion Leader) followers for a Twitter/X user.
Returns which influential accounts (KOLs) are following this user.
Args: username: Twitter username (without @).
Inputs: username (required).
get_twitter_userA
Get Twitter/X user profile information by username.
Args: username: Twitter username (without @, e.g. "elonmusk").
Inputs: username (required).
get_twitter_user_by_idB
Get Twitter/X user profile information by user ID.
Args: user_id: Twitter user ID (numeric string).
Inputs: user_id (required).
get_twitter_user_tweetsA
Get recent tweets from a specific Twitter/X user.
Args: username: Twitter username (without @). limit: Maximum tweets to return (default 20, max 100). include_replies: Include reply tweets (default False). include_retweets: Include retweets (default False).
Inputs: username (required), limit, include_replies, include_retweets.
get_twitter_watchB
Get all Twitter monitoring users for the current user.
Returns a list of Twitter accounts being monitored.
Inputs: no named parameters.
search_twitterA
Search Twitter/X for tweets matching criteria.
Args: keywords: Search keywords. from_user: Filter tweets from specific user (without @). hashtag: Filter by hashtag (without #). min_likes: Minimum likes threshold. limit: Maximum tweets to return (default 20, max 100).
Inputs: keywords, from_user, hashtag, min_likes, +1 more.
search_twitter_advancedB
Advanced Twitter/X search with multiple filters.
Args: keywords: Search keywords. from_user: Filter tweets from specific user. to_user: Filter tweets to specific user. mention_user: Filter tweets mentioning specific user. hashtag: Filter by hashtag (without #). exclude_replies: Exclude reply tweets. exclude_retweets: Exclude retweets. min_likes: Minimum likes threshold. min_retweets: Minimum retweets threshold. min_replies: Minimum replies threshold. since_date: Start date (YYYY-MM-DD). until_date: End date (YYYY-MM-DD). lang: Language code (e.g. "en", "zh"). product: Sort by "Top" or "Latest" (default "Top"). limit: Maximum tweets to return (default 20, max 100).
Inputs: keywords, from_user, to_user, mention_user, +11 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 12 tools
Most tools have distinct purposes, but there is some overlap between get_twitter_user and get_twitter_user_by_id (both retrieve user profiles via different identifiers) and between search_twitter and search_twitter_advanced (both search tweets, with the latter being a superset). The descriptions clarify the differences, preventing major confusion.
All tool names follow a consistent snake_case pattern with clear verb_noun structures (e.g., add_twitter_watch, get_twitter_user_tweets, search_twitter_advanced). The naming is predictable and uniform across all 12 tools.
With 12 tools, the server is well-scoped for Twitter/X monitoring and data retrieval. The count is appropriate, covering user management, tweet fetching, search, and monitoring without being overwhelming or insufficient for the domain.
The toolset provides strong coverage for monitoring and retrieving Twitter data, including user profiles, tweets, searches, and follower events. Minor gaps exist, such as no tools for posting tweets or interacting with tweets (e.g., liking, retweeting), but core retrieval and monitoring workflows are well-covered.
Maintenance
Related MCP Connectors
Live X/Twitter data: profiles, tweets, search, followers, lists and trends. 29 read-only tools.
Real-time Twitter (X) advanced search, user timelines, profiles & followers MCP ($0.03/1K tweets).
Read-only public X (Twitter) data: profiles, tweets, threads, followers, search. Pay per result.
X (formerly Twitter): X (formerly Twitter) public and private data API for search, posts (Tweets).
Related MCP Servers
- AlicenseBqualityCmaintenanceEnables interaction with X (formerly Twitter), allowing for posting tweets, searching content, managing accounts, and organizing lists.113MIT
- AlicenseNot gradedqualityDmaintenanceEnables complete management of X (Twitter) accounts through a single API key, supporting functions like getting tweets, searching, generating and posting replies.2MIT
- AlicenseNot gradedqualityDmaintenanceEnables interaction with X (Twitter) to post tweets, threads, and replies while retrieving tweet metrics and account information. It supports core management tasks like deleting tweets and verifying authentication through the Twitter API.MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI assistants to access Twitter/X data including user profiles, tweets, search, and follower events via a set of MCP tools.MIT