Skip to main content
Glama

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 应用中移除帖子。

工具

工具

类型

说明

whoami

读取

凭据所代表的账户

get_tweet

读取

按 ID 获取一条帖子

get_user_posts

读取

从某个用户名获取最近的帖子

get_mentions

读取

对已验证账户的提及

get_home_timeline

读取

逆时间顺序的主页时间线

search_recent

读取

最近 7 天的搜索(取决于计划)

draft_post

暂存

验证 + 预览。不发布任何内容。

list_drafts

读取

已暂存的草稿及其剩余 TTL

publish_post

写入

发布草稿。公开且永久。

草稿存储在内存中:重启会清除它们,因此过期的确认令牌永远不会 比显示预览的进程存活更久。

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.py

Related MCP Connectors

Related MCP Servers

  • A
    license
    B
    quality
    D
    maintenance
    Enables interacting with Twitter/X through natural language, including searching tweets, posting, sending DMs, and managing timelines via any MCP client.
    8
    MIT
  • F
    license
    A
    quality
    D
    maintenance
    Enables 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
    -
  • F
    license
    B
    quality
    D
    maintenance
    MCP 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.
    8
    9 npm
    -
  • A
    license
    A
    quality
    B
    maintenance
    Enables 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.
    41
    54 npm
    1
    MIT