x-mcp
x-mcp
位于 X(Twitter)API v2 之前的 MCP 服务器。镜像:ghcr.io/robertdwhite/x-mcp。
清单位于 whitehouse-rke2(apps/ai/x-mcp/)。
读取是免费的。写入是两步的 — draft_post 返回预览以及一个
一次性使用的 confirm_token,在调用 publish_post 并传入该确切令牌之前不会发布任何内容。代理无法在一次调用中发布,因此始终会先出现人类可见的预览。当输出是公开且永久的时候,这一点很重要。
故意没有删除工具。删除是破坏性的且不可逆的;请从 X 应用中移除帖子。
工具
工具 | 类型 | 说明 |
| 读取 | 凭据所代表的账户 |
| 读取 | 按 ID 获取一条帖子 |
| 读取 | 从某个用户名获取最近的帖子 |
| 读取 | 对已验证账户的提及 |
| 读取 | 逆时间顺序的主页时间线 |
| 读取 | 最近 7 天的搜索(取决于计划) |
| 暂存 | 验证 + 预览。不发布任何内容。 |
| 读取 | 已暂存的草稿及其剩余 TTL |
| 写入 | 发布草稿。公开且永久。 |
草稿存储在内存中:重启会清除它们,因此过期的确认令牌永远不会 比显示预览的进程存活更久。
Related MCP server: x-mcp
端点
POST /mcp— 可流式 HTTP MCP,受Authorization: Bearer $MCP_TOKEN保护GET /healthz— 开放,用于存活/就绪检查
所有其他路径返回 404,而不是 401 — 包括 MCP 客户端在启动时进行的 /.well-known/oauth-* 探测。那里的 401 会使客户端尝试交互式 OAuth 流程,这会导致无头客户端因连接超时而挂起。
配置
| 环境变量 | 必需 | 用途 |
| ----------------------- | --------- ----------------------------------------------- |
| MCP_TOKEN | 推荐 | /mcp 的 Bearer。未设置 = 未认证。 |
| X_API_KEY | 是 | 消费者密钥 |
| X_API_SECRET | 是 | 消费者密钥 |
| XACCESS_TOKEN | 是 | 访问令牌(用户上下文) |
| X_ACCESS_TOKEN_SECRET |是 | 访问令牌密钥 |
| X_MAXARS | 否 | 长度限制,默认 280。为高级版。 | | _DRAFT_T | 否 | 草稿生命周期(秒),默认 `` | |X_TIMEOUT | 否 | 超时默认30` |
对 X 的认证是OAuth 1.0a 用户上下文**,每个请求都签名。仅应用 Bear 令牌无法发布,因为发布是以账户身份进行的。从具有 读取和写入 权限 X 应用获取值:消费者密钥以及为你的账户生成的一对访问令牌/密钥。
如果凭据缺失,每个工具都会返回清晰的“未配置”错误,而不是堆栈跟踪 — 因此服务可以在凭据存在之前部署。
关于 X API 计划的说明
写入访问受 X 付费 API 层级限制,免费层级受到严格限制。来自此服务器的 429 会在 X 提供时显示速率限制重置时间。如果写入立即失败,请查看 developer.x.com上的计划。
本地运行
pip install -r requirements.txt
MCP_TOKEN=dev X_API_KEY=... X_API_SECRET=... \
X_ACCESS_TOKEN=... X_ACCESS_TOKEN_SECRET=... python server.pyThis server cannot be deployed
Maintenance
Related MCP Connectors
Official twitterapi.io hosted MCP: Twitter/X tweets, users, followers, trends. OAuth or API key.
Official MCP server for twitterapis.com. Twitter/X search, users, DMs, Grok, monitoring and writes.
Hosted X (Twitter) MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
Twitter/X read-only MCP server — 12 tools: search, users, tweets, followers, timelines, trends.
Related MCP Servers
- AlicenseBqualityDmaintenanceEnables interacting with Twitter/X through natural language, including searching tweets, posting, sending DMs, and managing timelines via any MCP client.8MIT
- FlicenseAqualityDmaintenanceEnables interaction with the X (Twitter) API through MCP tools for managing users, posts, bookmarks, likes, and lists. Supports markdown or JSON output and uses OAuth 2.0 PKCE authentication.22-
- FlicenseBqualityDmaintenanceMCP server for the official X API, enabling agents to read and publish posts, look up users, and search posts with safe read-only default and explicit write mode.89 npm-
- AlicenseAqualityBmaintenanceEnables MCP clients to interact with the X (Twitter) API v2 through 41 typed tools for reading, searching, engaging, publishing, and managing content, with policy-based access control and session credit budgets to prevent overspending.4154 npm1MIT