opentwitter-mcp-server
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chineseopentwitter-mcp-server
opentwitter-mcp-server
Overview
概述
The opentwitter-mcp is an MCP (Model Context Protocol) server that provides AI assistants with Twitter/X data access capabilities. It enables fetching user profiles, searching tweets, monitoring follower events, tracking deleted tweets, and managing watch lists for KOL (Key Opinion Leader) accounts.
The server connects to the 6551.io API service and exposes 13 tools for Twitter data operations.
opentwitter-mcp 是一款MCP(Model Context Protocol)服务器,为AI助手提供Twitter/X数据访问能力。它支持获取用户资料、搜索推文、监控粉丝事件、追踪已删除推文,以及管理KOL(Key Opinion Leader)账号的关注列表。
该服务器连接至6551.io API服务,提供13种用于Twitter数据操作的工具。
Installation
安装
Prerequisites
前置条件
- Get your API token from https://6551.io/mcp
- Clone or download the repository
- Have package manager installed
uv
- 从https://6551.io/mcp获取API令牌
- 克隆或下载代码仓库
- 安装包管理器
uv
Quick Install (Claude Code)
快速安装(Claude Code)
bash
claude mcp add twitter \
-e TWITTER_TOKEN=$TWITTER_TOKEN \
-- uv --directory /path/to/twitter-mcp run twitter-mcpbash
claude mcp add twitter \\
-e TWITTER_TOKEN=$TWITTER_TOKEN \\
-- uv --directory /path/to/twitter-mcp run twitter-mcpManual Configuration
手动配置
Claude Desktop ():
~/Library/Application Support/Claude/claude_desktop_config.jsonjson
{
"mcpServers": {
"twitter": {
"command": "uv",
"args": ["--directory", "/path/to/twitter-mcp", "run", "twitter-mcp"],
"env": {
"TWITTER_TOKEN": "${TWITTER_TOKEN}"
}
}
}
}Cursor ():
~/.cursor/mcp.jsonjson
{
"mcpServers": {
"twitter": {
"command": "uv",
"args": ["--directory", "/path/to/twitter-mcp", "run", "twitter-mcp"],
"env": {
"TWITTER_TOKEN": "${TWITTER_TOKEN}"
}
}
}
}Continue.dev ():
~/.continue/config.yamlyaml
mcpServers:
- name: twitter
command: uv
args:
- --directory
- /path/to/twitter-mcp
- run
- twitter-mcp
env:
TWITTER_TOKEN: ${TWITTER_TOKEN}Claude Desktop():
~/Library/Application Support/Claude/claude_desktop_config.jsonjson
{
"mcpServers": {
"twitter": {
"command": "uv",
"args": ["--directory", "/path/to/twitter-mcp", "run", "twitter-mcp"],
"env": {
"TWITTER_TOKEN": "${TWITTER_TOKEN}"
}
}
}
}Cursor():
~/.cursor/mcp.jsonjson
{
"mcpServers": {
"twitter": {
"command": "uv",
"args": ["--directory", "/path/to/twitter-mcp", "run", "twitter-mcp"],
"env": {
"TWITTER_TOKEN": "${TWITTER_TOKEN}"
}
}
}
}Continue.dev():
~/.continue/config.yamlyaml
mcpServers:
- name: twitter
command: uv
args:
- --directory
- /path/to/twitter-mcp
- run
- twitter-mcp
env:
TWITTER_TOKEN: ${TWITTER_TOKEN}Environment Variables
环境变量
| Variable | Required | Description |
|---|---|---|
| Yes | Bearer token from 6551.io |
| No | Override API URL (default: |
| No | Max results per query (default: 100) |
Alternative: Create in project root:
config.jsonjson
{
"api_base_url": "https://ai.6551.io",
"api_token": "your-token-here",
"max_rows": 100
}| 变量 | 是否必填 | 描述 |
|---|---|---|
| 是 | 来自6551.io的Bearer令牌 |
| 否 | 覆盖API地址(默认值: |
| 否 | 每次查询的最大结果数(默认值:100) |
替代方案:在项目根目录创建文件:
config.jsonjson
{
"api_base_url": "https://ai.6551.io",
"api_token": "your-token-here",
"max_rows": 100
}Available Tools
可用工具
User Profile Tools
用户资料工具
get_twitter_userpython
undefinedget_twitter_userpython
undefinedExample use from AI assistant:
AI助手调用示例:
"Show me @elonmusk's profile"
"展示@elonmusk的资料"
{
"username": "elonmusk"
}
**`get_twitter_user_by_id`** - Get user by numeric ID
```python
{
"user_id": "44196397"
}{
"username": "elonmusk"
}
**`get_twitter_user_by_id`** - 通过数字ID获取用户信息
```python
{
"user_id": "44196397"
}Tweet Retrieval Tools
推文获取工具
get_twitter_user_tweetspython
undefinedget_twitter_user_tweetspython
undefined"What did @VitalikButerin tweet recently"
"@VitalikButerin最近发了什么推文"
{
"username": "VitalikButerin",
"count": 20
}
**`get_twitter_tweet_by_id`** - Get specific tweet with nested replies/quotes
```python
{
"tweet_id": "1234567890"
}get_twitter_article_by_idpython
{
"article_id": "1234567890"
}{
"username": "VitalikButerin",
"count": 20
}
**`get_twitter_tweet_by_id`** - 获取包含嵌套回复/引用的特定推文
```python
{
"tweet_id": "1234567890"
}get_twitter_article_by_idpython
{
"article_id": "1234567890"
}Search Tools
搜索工具
search_twitterpython
undefinedsearch_twitterpython
undefined"Search Bitcoin related tweets"
"搜索和Bitcoin相关的推文"
{
"query": "Bitcoin",
"count": 50
}
**`search_twitter_advanced`** - Advanced search with filters
```python{
"query": "Bitcoin",
"count": 50
}
**`search_twitter_advanced`** - 带筛选条件的高级搜索
```python"Popular tweets about ETH with 1000+ likes"
"搜索获得1000+点赞的热门ETH相关推文"
{
"query": "ETH",
"min_likes": 1000,
"min_retweets": 100,
"language": "en",
"count": 30
}
Available filters:
- `min_likes`, `max_likes`
- `min_retweets`, `max_retweets`
- `min_replies`, `max_replies`
- `language` (ISO code: en, ja, etc.)
- `since`, `until` (dates)
- `verified_only` (boolean){
"query": "ETH",
"min_likes": 1000,
"min_retweets": 100,
"language": "en",
"count": 30
}
可用筛选条件:
- `min_likes`, `max_likes`
- `min_retweets`, `max_retweets`
- `min_replies`, `max_replies`
- `language`(ISO代码:en、ja等)
- `since`, `until`(日期)
- `verified_only`(布尔值)Engagement Tools
互动分析工具
get_twitter_quote_tweets_by_idpython
undefinedget_twitter_quote_tweets_by_idpython
undefined"Who quoted this tweet"
"哪些用户引用了这条推文"
{
"tweet_id": "1234567890",
"count": 50
}
**`get_twitter_retweet_users_by_id`** - Get users who retweeted
```python{
"tweet_id": "1234567890",
"count": 50
}
**`get_twitter_retweet_users_by_id`** - 获取转发特定推文的用户
```python"Who retweeted this tweet"
"哪些用户转发了这条推文"
{
"tweet_id": "1234567890",
"count": 100
}
undefined{
"tweet_id": "1234567890",
"count": 100
}
undefinedMonitoring Tools
监控工具
get_twitter_watchpython
undefinedget_twitter_watchpython
undefined"Show my Twitter watch list"
"展示我的Twitter关注列表"
{}
**`add_twitter_watch`** - Add account to monitoring
```python{}
**`add_twitter_watch`** - 添加账号至监控列表
```python"Monitor @elonmusk with follower tracking"
"监控@elonmusk的粉丝动态"
{
"username": "elonmusk",
"event_types": ["NEW_FOLLOWER", "NEW_UNFOLLOWER", "NEW_TWEET"],
"remark": "Tesla CEO",
"ca": "0x1234..." # Optional contract address
}
Event types:
- `NEW_TWEET` - New tweets
- `NEW_TWEET_REPLY` - Replies
- `NEW_TWEET_QUOTE` - Quote tweets
- `NEW_RETWEET` - Retweets
- `NEW_FOLLOWER` - New followers
- `NEW_UNFOLLOWER` - Unfollowers
- `DELETE` - Deleted tweets
- `UPDATE_NAME` - Username changes
- `UPDATE_DESCRIPTION` - Bio updates
- `UPDATE_AVATAR` - Profile picture changes
- `UPDATE_BANNER` - Banner changes
- `CA` - Tweets with contract addresses
**`delete_twitter_watch`** - Remove from monitoring
```python
{
"username": "elonmusk"
}{
"username": "elonmusk",
"event_types": ["NEW_FOLLOWER", "NEW_UNFOLLOWER", "NEW_TWEET"],
"remark": "Tesla CEO",
"ca": "0x1234..." # 可选合约地址
}
事件类型:
- `NEW_TWEET` - 新推文
- `NEW_TWEET_REPLY` - 回复
- `NEW_TWEET_QUOTE` - 引用推文
- `NEW_RETWEET` - 转发
- `NEW_FOLLOWER` - 新粉丝
- `NEW_UNFOLLOWER` - 取消关注
- `DELETE` - 删除推文
- `UPDATE_NAME` - 用户名变更
- `UPDATE_DESCRIPTION` - 简介更新
- `UPDATE_AVATAR` - 头像更新
- `UPDATE_BANNER` - 封面更新
- `CA` - 包含合约地址的推文
**`delete_twitter_watch`** - 从监控列表移除账号
```python
{
"username": "elonmusk"
}Event Tracking Tools
事件追踪工具
get_twitter_follower_eventspython
undefinedget_twitter_follower_eventspython
undefined"Who followed @elonmusk recently"
"@elonmusk最近新增了哪些粉丝"
{
"username": "elonmusk",
"event_type": "NEW_FOLLOWER",
"count": 50
}
**`get_twitter_deleted_tweets`** - Get deleted tweets
```python{
"username": "elonmusk",
"event_type": "NEW_FOLLOWER",
"count": 50
}
**`get_twitter_deleted_tweets`** - 获取已删除推文
```python"What tweets did @elonmusk delete"
"@elonmusk删除了哪些推文"
{
"username": "elonmusk",
"count": 20
}
**`get_twitter_kol_followers`** - Get KOL (influential) followers
```python{
"username": "elonmusk",
"count": 20
}
**`get_twitter_kol_followers`** - 获取KOL(有影响力的)粉丝
```python"Which KOLs follow @elonmusk"
"哪些KOL关注了@elonmusk"
{
"username": "elonmusk",
"count": 100
}
undefined{
"username": "elonmusk",
"count": 100
}
undefinedData Structures
数据结构
User Object
用户对象
python
{
"userId": "44196397",
"screenName": "elonmusk",
"name": "Elon Musk",
"description": "Bio text...",
"followersCount": 170000000,
"friendsCount": 500,
"statusesCount": 30000,
"verified": true,
"profileImageUrl": "https://...",
"profileBannerUrl": "https://...",
"createdAt": "2009-06-02T20:12:29Z"
}python
{
"userId": "44196397",
"screenName": "elonmusk",
"name": "Elon Musk",
"description": "Bio text...",
"followersCount": 170000000,
"friendsCount": 500,
"statusesCount": 30000,
"verified": true,
"profileImageUrl": "https://...",
"profileBannerUrl": "https://...",
"createdAt": "2009-06-02T20:12:29Z"
}Tweet Object
推文对象
python
{
"id": "1234567890",
"text": "Tweet content...",
"createdAt": "2024-02-20T12: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://t.co/...",
"expandedUrl": "https://example.com",
"displayUrl": "example.com"
}
],
"mentions": [
{
"username": "VitalikButerin",
"name": "Vitalik Buterin"
}
]
}python
{
"id": "1234567890",
"text": "Tweet content...",
"createdAt": "2024-02-20T12: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://t.co/...",
"expandedUrl": "https://example.com",
"displayUrl": "example.com"
}
],
"mentions": [
{
"username": "VitalikButerin",
"name": "Vitalik Buterin"
}
]
}WebSocket Real-time Subscriptions
WebSocket实时订阅
Connect to for real-time events.
wss://ai.6551.io/open/twitter_wss?token=YOUR_TOKEN连接至获取实时事件。
wss://ai.6551.io/open/twitter_wss?token=YOUR_TOKENSubscribe
订阅
json
{
"jsonrpc": "2.0",
"id": 1,
"method": "twitter.subscribe"
}json
{
"jsonrpc": "2.0",
"id": 1,
"method": "twitter.subscribe"
}Event Notification
事件通知
json
{
"jsonrpc": "2.0",
"method": "twitter.event",
"params": {
"id": 123456,
"twAccount": "elonmusk",
"twUserName": "Elon Musk",
"profileUrl": "https://twitter.com/elonmusk",
"eventType": "NEW_TWEET",
"content": { /* tweet object */ },
"ca": "0x1234...",
"remark": "Custom note",
"createdAt": "2026-03-06T10:00:00Z"
}
}json
{
"jsonrpc": "2.0",
"method": "twitter.event",
"params": {
"id": 123456,
"twAccount": "elonmusk",
"twUserName": "Elon Musk",
"profileUrl": "https://twitter.com/elonmusk",
"eventType": "NEW_TWEET",
"content": { /* tweet object */ },
"ca": "0x1234...",
"remark": "Custom note",
"createdAt": "2026-03-06T10:00:00Z"
}
}Unsubscribe
取消订阅
json
{
"jsonrpc": "2.0",
"id": 2,
"method": "twitter.unsubscribe"
}json
{
"jsonrpc": "2.0",
"id": 2,
"method": "twitter.unsubscribe"
}Common Patterns
常见使用模式
Search with Filters
带筛选条件的搜索
python
undefinedpython
undefinedHigh-engagement tweets in specific timeframe
特定时间段内高互动推文
search_twitter_advanced(
query="AI",
min_likes=1000,
min_retweets=500,
since="2024-01-01",
until="2024-12-31",
verified_only=True,
language="en"
)
undefinedsearch_twitter_advanced(
query="AI",
min_likes=1000,
min_retweets=500,
since="2024-01-01",
until="2024-12-31",
verified_only=True,
language="en"
)
undefinedMonitor Multiple Accounts
监控多个账号
python
undefinedpython
undefinedAdd multiple KOLs to watch list
添加多个KOL至关注列表
for username in ["elonmusk", "VitalikButerin", "naval"]:
add_twitter_watch(
username=username,
event_types=["NEW_TWEET", "NEW_FOLLOWER"],
remark=f"Tracking {username}"
)
undefinedfor username in ["elonmusk", "VitalikButerin", "naval"]:
add_twitter_watch(
username=username,
event_types=["NEW_TWEET", "NEW_FOLLOWER"],
remark=f"Tracking {username}"
)
undefinedTrack Engagement
追踪互动数据
python
undefinedpython
undefinedGet full engagement picture for a tweet
获取某条推文的完整互动情况
tweet = get_twitter_tweet_by_id(tweet_id="1234567890")
quotes = get_twitter_quote_tweets_by_id(tweet_id="1234567890")
retweet_users = get_twitter_retweet_users_by_id(tweet_id="1234567890")
undefinedtweet = get_twitter_tweet_by_id(tweet_id="1234567890")
quotes = get_twitter_quote_tweets_by_id(tweet_id="1234567890")
retweet_users = get_twitter_retweet_users_by_id(tweet_id="1234567890")
undefinedFollower Analysis
粉丝分析
python
undefinedpython
undefinedCompare followers vs KOL followers
对比普通粉丝与KOL粉丝
all_followers = get_twitter_follower_events(
username="elonmusk",
event_type="NEW_FOLLOWER"
)
kol_followers = get_twitter_kol_followers(username="elonmusk")
undefinedall_followers = get_twitter_follower_events(
username="elonmusk",
event_type="NEW_FOLLOWER"
)
kol_followers = get_twitter_kol_followers(username="elonmusk")
undefinedDevelopment
开发指南
Run Locally
本地运行
bash
cd /path/to/twitter-mcp
uv sync
export TWITTER_TOKEN=your-token
uv run twitter-mcpbash
cd /path/to/twitter-mcp
uv sync
export TWITTER_TOKEN=your-token
uv run twitter-mcpDebug with MCP Inspector
使用MCP Inspector调试
bash
npx @modelcontextprotocol/inspector \
uv --directory /path/to/twitter-mcp run twitter-mcpbash
npx @modelcontextprotocol/inspector \\
uv --directory /path/to/twitter-mcp run twitter-mcpProject Structure
项目结构
src/twitter_mcp/
├── server.py # Entry point
├── app.py # FastMCP instance
├── config.py # Config loader
├── api_client.py # HTTP client
└── tools.py # Tool implementationssrc/twitter_mcp/
├── server.py # 入口文件
├── app.py # FastMCP实例
├── config.py # 配置加载器
├── api_client.py # HTTP客户端
└── tools.py # 工具实现Troubleshooting
故障排除
Authentication Errors
认证错误
- Verify is set correctly
TWITTER_TOKEN - Check token validity at https://6551.io/mcp
- Ensure no extra whitespace in token value
- 确认已正确设置
TWITTER_TOKEN - 在https://6551.io/mcp检查令牌有效性
- 确保令牌值无多余空格
Rate Limiting
速率限制
- Default is 100; reduce if hitting limits
max_rows - Space out requests when monitoring multiple accounts
- 默认为100;若触发限制可降低该值
max_rows - 监控多个账号时请间隔发送请求
Connection Issues
连接问题
- Verify if using custom endpoint
TWITTER_API_BASE - Check firewall/proxy settings for access
ai.6551.io - For WebSocket: ensure WSS protocol is allowed
- 若使用自定义端点,请确认设置正确
TWITTER_API_BASE - 检查防火墙/代理是否允许访问
ai.6551.io - WebSocket连接:确保WSS协议被允许
Empty Results
结果为空
- Username lookup is case-insensitive but must be exact
- Some accounts may have restricted data access
- Recent tweets may take moments to appear in search
- 用户名查询不区分大小写但必须完全匹配
- 部分账号可能限制数据访问
- 最新推文可能需要片刻才会出现在搜索结果中
Tool Not Found
工具未找到
- Restart your AI client after config changes
- Verify is in PATH
uv - Check project path is absolute, not relative
- 修改配置后重启AI客户端
- 确认已在PATH中
uv - 检查项目路径为绝对路径,而非相对路径
Common Use Cases
常见应用场景
Content Research: Search tweets with advanced filters to find trending topics, viral content, or specific conversations.
Influencer Monitoring: Track follower growth, engagement patterns, and deleted tweets for transparency.
Community Management: Monitor mentions, replies, and engagement on your own tweets or brand accounts.
Competitive Analysis: Track competitors' follower changes, KOL supporters, and content strategies.
Event Tracking: Set up watches for breaking news, product launches, or community events via real-time WebSocket feeds.
内容研究:使用高级筛选条件搜索推文,发掘热门话题、病毒式内容或特定对话。
网红监控:追踪粉丝增长、互动模式和已删除推文,确保透明度。
社区管理:监控自身推文或品牌账号的提及、回复和互动情况。
竞品分析:追踪竞品的粉丝变化、KOL支持者和内容策略。
事件追踪:通过实时WebSocket流设置监控,追踪突发新闻、产品发布或社区活动。",