
TwittrAPI
io.github.twittrapi由 GitHub 账号 twittrapi 发布v1.2.0更新于 Nov 2, 2026
Read public Twitter/X data: tweets, profiles, followers, search. No X developer account.
概览
TwittrAPI 的 MCP 服务器,让助手无需 X 开发者账号即可读取公开的 Twitter/X 数据:推文、个人资料、关注者、搜索、列表、社区和趋势。
- 可以做什么
- 查询账号与关系:把用户名解析为 ID、批量获取资料、关注者、正在关注、认证关注者、关联账号及互相关注情况
- 读取推文:用户的推文、回复和媒体,单条推文及其回复串、转推、引用、回复,以及按 ID 批量获取
- 用 X 搜索语法检索推文,并按 Top、Latest、People、Photos 或 Videos 筛选
- 浏览列表、社区、X Space 以及按地区查询热门话题
- 可选:配置 X 会话 Cookie 和代理后,操作自己的账号:发帖、回复、删除、点赞、转推、收藏、关注、发送私信、管理列表和草稿、处理 X Articles
- 适用场景
- 适合在聊天客户端里让助手调研或跟踪公开的 X 动态,例如账号资料、关注关系、推文串、关键词搜索、趋势或社区,而无需注册 X 开发者应用。只有需要助手代你发帖或管理自己的 X 账号时,才值得启用账号工具。
- 运行要求
- 可使用远程端点(托管服务器,通过 OAuth 登录),或用 npx 在本地运行,需要 Node.js 20 或更高版本。需要 TwittrAPI 密钥(TWITTRAPI_API_KEY),或已订阅 Twitter AIO API 的 RapidAPI 密钥(RAPIDAPI_KEY)。可选:TWITTRAPI_X_COOKIE 与 TWITTRAPI_X_PROXY 用于账号工具,TWITTRAPI_X_CHAT_PASSCODE 用于发送私信。需要能访问 TwittrAPI API 的网络。
安装
在 SourceWeft 中
- 打开 控制台中的 TwittrAPI,将其添加到工作区。
- 连接 所需的 凭据。它们会被私密存储,绝不会在公开页面上展示。
- 为需要使用其工具的对话启用该服务。
Web executable,通过 Streamable HTTP。 远程服务在工作区中配置后即可从网页运行时运行。
交给智能体安装
把这段提示词粘贴到 Claude Code、Codex、Cursor 等智能体,或 SourceWeft 对话中。智能体会读取该服务器的安装指南,先向你展示发布者、端点和登录方式,经你同意后再把它添加到你的客户端。密钥不会写进任何命令。
阅读 https://sourceweft.com/mcp/io.github.twittrapi%2Ftwittrapi-mcp/install.md,并按其中说明把这个 MCP 服务器接入我的客户端。修改任何配置之前,先告诉我它的发布者、端点和登录方式,等我确认。不要把 API 密钥写进命令或我会提交的文件;问我密钥应从哪里获取。其他 MCP 客户端
把它添加到你客户端的 mcpServers 配置中。 客户端会在首次连接时完成 OAuth 登录。
{
"mcpServers": {
"twittrapi": {
"type": "http",
"url": "https://mcp.twittrapi.com/mcp"
}
}
}README
[twittrapi-mcp: Twitter/X MCP server for AI agents, npx -y twittrapi-mcp]
twittrapi-mcp – Twitter/X MCP server for Claude, Cursor and other AI agents
An MCP server for TwittrAPI, a REST API for public Twitter/X data: tweets, profiles, followers, search, lists and communities. It lets Claude, Cursor and other MCP clients read that data, from $0.065 per 1,000 calls and with no X developer account.
Get an API key: twittrapi.com/start · Pricing · Docs · Status · also available on RapidAPI
SDKs and integrations: Python · Node.js · Go · n8n · Make · Apify · LangChain · LlamaIndex · Agent skill · Examples
Not affiliated with X Corp.
Hosted server (no install)
Apps that support remote MCP servers can connect by URL instead (available with the hosted release; see twittrapi.com/docs/hosted-mcp):
With OAuth the app never sees your API key; calls are billed to your balance like any other call. Connected apps are listed (and can be disconnected) in the dashboard under Connected apps.
What you need
- Node.js 20 or newer
- A TwittrAPI key, or a RapidAPI key subscribed to the Twitter AIO API
Every tool call is one billed API call on your account.
Install
Claude Code
Claude Desktop
Open Settings > Developer > Edit Config and add this to claude_desktop_config.json:
Restart Claude Desktop afterwards.
Cursor
Add this to ~/.cursor/mcp.json (all projects) or .cursor/mcp.json (one project):
Other clients
Any client that can start a stdio server works. The command is npx -y twittrapi-mcp.
Environment variables
If neither key is set, the server still starts and lists its tools, but every call returns an error explaining how to set a key.
Using RapidAPI instead
If you bought access through RapidAPI, set RAPIDAPI_KEY instead of TWITTRAPI_API_KEY:
Requests then go to https://twitter-aio.p.rapidapi.com with the x-rapidapi-key and
x-rapidapi-host headers. The tools and their output are the same.
Subscribed to another TwittrAPI listing on RapidAPI? Set its host:
"RAPIDAPI_HOST": "twttr.p.rapidapi.com".
Tools
These tools read public data and are always available. The account tools are added when you configure your X session.
The user timeline tools (get_user_tweets, get_followers and so on) accept either userId or
username. The batch tools are billed one call per handle; tweets_by_ids is one call however
many IDs.
Account tools
With TWITTRAPI_X_COOKIE and TWITTRAPI_X_PROXY set, the server also lists tools that act on
your own X account:
How to get the cookie and set up a proxy: twittrapi.com/docs/x-session.
The cookie needs auth_token and ct0; direct messages also need twid.
- The cookie and proxy stay in the server's configuration. They are not tool arguments, so the model never sees them, and they are never logged or returned in a result.
- Write tools are marked
readOnlyHint: false(deletions and undo actions alsodestructiveHint: true), so clients ask before running them. - Each call is one billed API call, like the read tools.
- Account tools are only available over stdio. HTTP mode and the hosted server do not offer them.
Response format
Tool results use the API's simple format by default:
flat camelCase JSON with a fixed schema ({"data": [...], "nextCursor": ..., "hasNextPage": ...}
for lists, {"data": {...}} for single objects). Tweets carry id, url, text, createdAt,
author, counts, media, quoted, retweetOf and a few more fields; users carry username,
name, description, counts and so on. That is about 60 % fewer tokens than X's raw GraphQL JSON.
To get the raw JSON instead (for cards, polls, edit history, community notes and other fields the simple format leaves out):
- per call: the tools take an optional
formatargument,"simple"or"raw"; - for the whole server: set
TWITTRAPI_RESPONSE_FORMAT=raw(theformatargument still wins).
A few endpoints have no simple format: get_space, get_community_about, the batch tools and the
newer account tools (bookmark folders and search, communities, articles). These tools have no
format argument and always return raw JSON.
Output size and pagination
Raw responses can be several hundred KB. Every tool takes an optional max_chars argument
(default 50,000, range 1,000 to 1,000,000). Longer output is cut and ends with a
[TRUNCATED ...] marker.
Paginated tools print the cursor above the JSON, so truncation never removes it:
On the last page the header reads next_cursor: none (last page, no more results). In the simple
format that is when hasNextPage is false. In the raw format it happens when the response has no
next cursor (empty likes timelines included), when X returns the cursor you just sent, or
when a page holds only cursors and no results.
Errors
API errors come back as tool errors with a short explanation, for example:
- 402: the account has no balance left
- 429: rate limit hit, wait before retrying
- 404: the user or tweet does not exist, is private or is suspended
- 5xx: temporary upstream problem
HTTP mode (remote hosting)
This serves a stateless Streamable HTTP
endpoint at /mcp and a health check at /health. The default host is 127.0.0.1. Every POST
gets its own server instance bound to the caller's credentials, so any number of instances can
run behind a load balancer without sticky sessions. GET /mcp answers 405 (no server-initiated
stream); the legacy SSE transport is not offered.
In HTTP mode the server does not use a key from its own environment. Each request carries the caller's credentials:
X-API-KEY: <key>orAuthorization: Bearer <key>for the direct APIx-rapidapi-key: <key>for RapidAPI, plusx-rapidapi-host: <host>for a listing other thantwitter-aio.p.rapidapi.com(must end in.p.rapidapi.com)Authorization: Bearer twa_at_...: a TwittrAPI OAuth access token (hosted mode, below)
The account tools are not offered in HTTP mode; TWITTRAPI_X_COOKIE and
TWITTRAPI_X_PROXY are ignored there. TWITTRAPI_BASE_URL and TWITTRAPI_RESPONSE_FORMAT are still read from the environment; callers
can pick the format per call with the format argument. Put the server behind HTTPS if it is
reachable from the internet.
Example client config for your own instance (Claude Code):
Hosted mode with OAuth
For clients that require OAuth (Claude.ai connectors, ChatGPT), the server acts as an OAuth 2.1 resource server and the TwittrAPI dashboard as the authorization server (dynamic client registration, PKCE S256, consent screen, rotating refresh tokens). The server:
- answers requests without credentials with
401andWWW-Authenticate: Bearer resource_metadata="<origin>/.well-known/oauth-protected-resource/mcp", scope="mcp"; - serves RFC 9728 metadata at
/.well-known/oauth-protected-resource/mcpand/.well-known/oauth-protected-resource, and relays the dashboard's RFC 8414 metadata at/.well-known/oauth-authorization-server; - checks each access token with the dashboard's internal introspection endpoint (shared secret),
caches valid results for up to
OAUTH_CACHE_SECONDS(30) and invalid ones for 5 s, and accepts only tokens whose audience isMCP_PUBLIC_URL; - calls the API with the key of the account behind the token. The key never reaches the client.
Invalid or revoked tokens get
401witherror="invalid_token"; if the dashboard cannot be reached the answer is503withRetry-After, so clients keep their tokens.
Environment (HTTP mode)
Logs are JSON lines on stdout, one per request: request id, client IP, auth kind
(api_key, rapidapi, oauth, none), a hashed key id (k_ + 12 hex characters), OAuth client
and account id, JSON-RPC method, tool name, status and duration. Keys and tokens are never logged.
Docker / Coolify
In Coolify: build pack Dockerfile, port 3000, health check path /health, domain
mcp.twittrapi.com, and the variables above. Set OAUTH_INTROSPECTION_URL to the dashboard's
internal address when both run on the same server.
Development
npm test builds first, then runs unit tests, a protocol test that starts the server over stdio
and HTTP against a local mock API, and tests of hosted mode (OAuth challenge and metadata, token
introspection and caching, audience check, limits, log redaction) against a fake dashboard.
To add or change a tool, edit src/endpoints.ts. Each entry has a name, description, API path and
zod parameter schemas. Every tool also gets max_chars, and format unless the entry sets rawOnly.
An entry can set a simplify function to reshape the parsed JSON further; none do. Account tools live in src/actions.ts.
Try the server interactively with the MCP Inspector:
Support
Questions, bugs or a higher rate limit: email [email protected] or open an issue in this repository. Service status: twittrapi.com/status. News and changes: the TwittrAPI Telegram channel (link on the website).
License
MIT
来源:README.md,提交 8431a1d
工具
0版本历史
3- v1.2.0最新Oct 19, 2026
- v0.3.1Oct 14, 2026
- v0.3.0Oct 12, 2026
评分
已满足适用检查项的 85%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通必需25 分
- 已声明认证方式必需10 分
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分