opentwitter-mcp-server

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

opentwitter-mcp-server

opentwitter-mcp-server

Skill by ara.so — MCP Skills collection.
Skill by ara.so — MCP Skills collection.

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

前置条件

  1. Get your API token from https://6551.io/mcp
  2. Clone or download the repository
  3. Have
    uv
    package manager installed
  1. https://6551.io/mcp获取API令牌
  2. 克隆或下载代码仓库
  3. 安装
    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-mcp
bash
claude mcp add twitter \\
  -e TWITTER_TOKEN=$TWITTER_TOKEN \\
  -- uv --directory /path/to/twitter-mcp run twitter-mcp

Manual Configuration

手动配置

Claude Desktop (
~/Library/Application Support/Claude/claude_desktop_config.json
):
json
{
  "mcpServers": {
    "twitter": {
      "command": "uv",
      "args": ["--directory", "/path/to/twitter-mcp", "run", "twitter-mcp"],
      "env": {
        "TWITTER_TOKEN": "${TWITTER_TOKEN}"
      }
    }
  }
}
Cursor (
~/.cursor/mcp.json
):
json
{
  "mcpServers": {
    "twitter": {
      "command": "uv",
      "args": ["--directory", "/path/to/twitter-mcp", "run", "twitter-mcp"],
      "env": {
        "TWITTER_TOKEN": "${TWITTER_TOKEN}"
      }
    }
  }
}
Continue.dev (
~/.continue/config.yaml
):
yaml
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.json
):
json
{
  "mcpServers": {
    "twitter": {
      "command": "uv",
      "args": ["--directory", "/path/to/twitter-mcp", "run", "twitter-mcp"],
      "env": {
        "TWITTER_TOKEN": "${TWITTER_TOKEN}"
      }
    }
  }
}
Cursor
~/.cursor/mcp.json
):
json
{
  "mcpServers": {
    "twitter": {
      "command": "uv",
      "args": ["--directory", "/path/to/twitter-mcp", "run", "twitter-mcp"],
      "env": {
        "TWITTER_TOKEN": "${TWITTER_TOKEN}"
      }
    }
  }
}
Continue.dev
~/.continue/config.yaml
):
yaml
mcpServers:
  - name: twitter
    command: uv
    args:
      - --directory
      - /path/to/twitter-mcp
      - run
      - twitter-mcp
    env:
      TWITTER_TOKEN: ${TWITTER_TOKEN}

Environment Variables

环境变量

VariableRequiredDescription
TWITTER_TOKEN
YesBearer token from 6551.io
TWITTER_API_BASE
NoOverride API URL (default:
https://ai.6551.io
)
TWITTER_MAX_ROWS
NoMax results per query (default: 100)
Alternative: Create
config.json
in project root:
json
{
  "api_base_url": "https://ai.6551.io",
  "api_token": "your-token-here",
  "max_rows": 100
}
变量是否必填描述
TWITTER_TOKEN
来自6551.io的Bearer令牌
TWITTER_API_BASE
覆盖API地址(默认值:
https://ai.6551.io
TWITTER_MAX_ROWS
每次查询的最大结果数(默认值:100)
替代方案:在项目根目录创建
config.json
文件:
json
{
  "api_base_url": "https://ai.6551.io",
  "api_token": "your-token-here",
  "max_rows": 100
}

Available Tools

可用工具

User Profile Tools

用户资料工具

get_twitter_user
- Get user by username
python
undefined
get_twitter_user
- 通过用户名获取用户信息
python
undefined

Example 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_tweets
- Get recent tweets from a user
python
undefined
get_twitter_user_tweets
- 获取用户近期推文
python
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_id
- Get Twitter article/long-form content
python
{
  "article_id": "1234567890"
}
{ "username": "VitalikButerin", "count": 20 }

**`get_twitter_tweet_by_id`** - 获取包含嵌套回复/引用的特定推文
```python
{
  "tweet_id": "1234567890"
}
get_twitter_article_by_id
- 获取Twitter文章/长内容
python
{
  "article_id": "1234567890"
}

Search Tools

搜索工具

search_twitter
- Basic keyword search
python
undefined
search_twitter
- 基础关键词搜索
python
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_id
- Get tweets quoting a specific tweet
python
undefined
get_twitter_quote_tweets_by_id
- 获取引用特定推文的内容
python
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 }
undefined

Monitoring Tools

监控工具

get_twitter_watch
- List all monitored accounts
python
undefined
get_twitter_watch
- 列出所有被监控的账号
python
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_events
- Get follower/unfollower events
python
undefined
get_twitter_follower_events
- 获取粉丝/取消关注事件
python
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 }
undefined

Data 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
wss://ai.6551.io/open/twitter_wss?token=YOUR_TOKEN
for real-time events.
连接至
wss://ai.6551.io/open/twitter_wss?token=YOUR_TOKEN
获取实时事件。

Subscribe

订阅

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
undefined
python
undefined

High-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" )
undefined
search_twitter_advanced( query="AI", min_likes=1000, min_retweets=500, since="2024-01-01", until="2024-12-31", verified_only=True, language="en" )
undefined

Monitor Multiple Accounts

监控多个账号

python
undefined
python
undefined

Add 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}" )
undefined
for username in ["elonmusk", "VitalikButerin", "naval"]: add_twitter_watch( username=username, event_types=["NEW_TWEET", "NEW_FOLLOWER"], remark=f"Tracking {username}" )
undefined

Track Engagement

追踪互动数据

python
undefined
python
undefined

Get 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")
undefined
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")
undefined

Follower Analysis

粉丝分析

python
undefined
python
undefined

Compare 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")
undefined
all_followers = get_twitter_follower_events( username="elonmusk", event_type="NEW_FOLLOWER" ) kol_followers = get_twitter_kol_followers(username="elonmusk")
undefined

Development

开发指南

Run Locally

本地运行

bash
cd /path/to/twitter-mcp
uv sync
export TWITTER_TOKEN=your-token
uv run twitter-mcp
bash
cd /path/to/twitter-mcp
uv sync
export TWITTER_TOKEN=your-token
uv run twitter-mcp

Debug with MCP Inspector

使用MCP Inspector调试

bash
npx @modelcontextprotocol/inspector \
  uv --directory /path/to/twitter-mcp run twitter-mcp
bash
npx @modelcontextprotocol/inspector \\
  uv --directory /path/to/twitter-mcp run twitter-mcp

Project Structure

项目结构

src/twitter_mcp/
├── server.py      # Entry point
├── app.py         # FastMCP instance
├── config.py      # Config loader
├── api_client.py  # HTTP client
└── tools.py       # Tool implementations
src/twitter_mcp/
├── server.py      # 入口文件
├── app.py         # FastMCP实例
├── config.py      # 配置加载器
├── api_client.py  # HTTP客户端
└── tools.py       # 工具实现

Troubleshooting

故障排除

Authentication Errors

认证错误

  • Verify
    TWITTER_TOKEN
    is set correctly
  • Check token validity at https://6551.io/mcp
  • Ensure no extra whitespace in token value

Rate Limiting

速率限制

  • Default
    max_rows
    is 100; reduce if hitting limits
  • Space out requests when monitoring multiple accounts
  • 默认
    max_rows
    为100;若触发限制可降低该值
  • 监控多个账号时请间隔发送请求

Connection Issues

连接问题

  • Verify
    TWITTER_API_BASE
    if using custom endpoint
  • Check firewall/proxy settings for
    ai.6551.io
    access
  • 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
    uv
    is in PATH
  • Check project path is absolute, not relative
  • 修改配置后重启AI客户端
  • 确认
    uv
    已在PATH中
  • 检查项目路径为绝对路径,而非相对路径

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流设置监控,追踪突发新闻、产品发布或社区活动。",