连接器指南阅读约 6 分钟41 个 MCP 工具7 种语言

如何通过 MCP 将 X (Twitter) 连接到 Gemini

让你的 AI 使用 X(原 Twitter):读取和搜索帖子、你的时间线、提及、书签、列表和私信,查找账号和关注者,并在你确认后发布帖子、回复和引用,点赞、转发和发送私信。

HC作者:HelpCode 团队更新于 6 分钟阅读 在 GitHub 开源

无需信用卡 · 7 天试用 · 提供自托管方案

X (Twitter)

X (Twitter)

Let your AI work with X (formerly Twitter): read and search posts, your timeline, mentions, bookmarks, Lists and direct messages, look up accounts and followers, and publish posts, replies and quotes, like, repost and send DMs after your confirmation.

个工具

41

区域

INTL

类别

社交媒体

身份验证

OAuth 2.0

所需环境变量

X_CLIENT_IDX_CLIENT_SECRET
在 Cloud 上一键安装

7 天免费试用 · 无需信用卡

  • 7 天免费试用
    无需信用卡
  • 符合 GDPR,SOC 2 就绪
    数据驻留欧盟,审计日志
  • 在 GitHub 开源
    开源 · AGPL-3.0
  • 支持 ChatGPT、Claude、Gemini
    任何兼容 MCP 的客户端

跳过安装。2 分钟内即可运行。

在 cloud.anythingmcp.com 开始免费试用,一键添加 X (Twitter),然后将你的 AI 客户端(Claude、ChatGPT、Copilot 或 Cursor)指向生成的 MCP 端点。无需 Docker,无需 git clone,无需任何工程经验。

开始免费试用

摘要

让你的 AI 使用 X(原 Twitter):读取和搜索帖子、你的时间线、提及、书签、列表和私信,查找账号和关注者,并在你确认后发布帖子、回复和引用,点赞、转发和发送私信。

试试这样问

X (Twitter) 的示例提示

点击任意提示即可复制,然后粘贴到 Claude、ChatGPT、Cursor、Gemini、Copilot 或 OpenClaw 中,在该连接器上运行。

X (Twitter) · 通过 MCP 实时
分享
Opus 4.7

Claude 是 AI,可能会出错。请核对回答。

💡 无需安装? 直接使用 cloud.anythingmcp.com。 登录、点击 Connectors → X (Twitter)、粘贴凭证、生成 MCP API key,即可完成。无 Docker、无 git clone、无本地服务器。

X (Twitter) + Gemini

让你的 AI 使用 X(原 Twitter):读取和搜索帖子、你的时间线、提及、书签、列表和私信,查找账号和关注者,并在你确认后发布帖子、回复和引用,点赞、转发和发送私信。

前提条件

完整的设置说明已内置在连接器中 (在 store 中选择连接器时可见)。所需环境变量:

X_CLIENT_ID, X_CLIENT_SECRET

步骤 1 — 获取凭证

  1. 打开 https://console.x.com 上的 X Developer Console,用将拥有该应用的 X 账号登录,然后点击 Create App。
  2. 在账单(billing)中充值 API 额度。X API 采用预付额度、按用量计费的方式,新开发者没有免费套餐:没有额度时,X 会拒绝所有调用。
  3. 打开应用的 User authentication settings,点击 Set up。应用权限选择 Read and write and Direct message(如果不使用私信工具,Read and write 就够了),应用类型选择 Web App, Automated App or Bot,再填写一个网站 URL 和回调 URI https://cloud.anythingmcp.com/api/mcp-oauth/callback。如果你自托管 AnythingMCP,则为 <your AnythingMCP URL>/api/mcp-oauth/callback。X 会逐字符比对,包括末尾的斜杠。本地部署请使用 127.0.0.1,不要用 localhost:http://127.0.0.1:<port>/api/mcp-oauth/callback。
  4. 把 OAuth 2.0 Client ID 和 Client Secret 复制到 X_CLIENT_ID 和 X_CLIENT_SECRET。X 只显示一次 secret。应用的 API Key、API Secret 和 Bearer Token 属于其他登录方式,这里不使用。
  5. 安装连接器,点击 Authorize with Provider,并在 X 上允许访问。登录使用 OAuth 2.0,因此 AnythingMCP 永远看不到你的 X 密码,并会自动续期访问令牌(有效期两小时)。
  6. 先运行 x_get_me:它返回你的账号以及数字用户 ID,时间线、点赞、转发、书签和关注工具都需要这个 ID。x_get_user_by_username 可以把任意 @username 转换为对应的 ID。

费用:X 会从你的额度余额中扣除每一次读取和每一次发布的费用。发布比读取贵,带链接的帖子则贵得多。如果你登录所用的账号同时也是开发者应用的所有者,读取你自己的数据会更便宜;同一条内容在同一个 UTC 日内读取两次只计费一次。请在 Developer Console 中设置支出上限,并在 https://docs.x.com/x-api/getting-started/pricing 查看 X 的最新价格。请求更少的结果可以降低费用,因为返回的每一条内容都会计费。

先确认:帖子、回复、引用、转发和私信(x_create_post、x_reply_to_post、x_quote_post、x_repost、x_send_dm、x_send_dm_to_conversation)会立即发出,因此 AI 会先给你看确切的文字和接收者,等你同意后再发送。关注和取消关注账号也需要确认。x_delete_post 和 x_delete_dm 在安装时处于关闭状态。

回复:只有当原帖作者提及或引用了你的账号时,X 才接受通过 API 发送的回复。在你自己的帖子串中回复,以及回复提及你的帖子,都可以正常使用。

搜索和消息:搜索覆盖最近 7 天,并支持 X 的运算符,例如 from:、to:、#hashtag、"exact phrase"、-is:retweet 或 lang:en。x_count_recent_posts 只统计匹配帖子的数量,不读取内容。私信覆盖最近 30 天;加密会话无法通过 API 获取。

只读或不含私信:在连接器的 OAuth 设置中删除 .write scope 或 dm. scope,重新授权,并关闭需要它们的工具。

常见错误:401 表示授权已被撤销或 client secret 已更改,请重新授权。带有 client-forbidden 或 client-not-enrolled 的 403 表示应用没有使用按量付费:在 Developer Console 中把它移到 Pay-per-use 套餐和 Production 环境,并充值额度。以前正常的调用开始失败,通常意味着额度或支出上限已用完。429 是 X 的速率限制,每 15 分钟重置一次。

连接器不会上传媒体(帖子仅限文字或投票)、搜索完整存档、以流式方式获取帖子、管理列表、静音或屏蔽账号,也不会投放广告。

步骤 2 — 安装 adapter

curl -fsSL https://raw.githubusercontent.com/HelpCode-ai/anythingmcp/main/docker-compose.quickstart.yml -o docker-compose.yml
printf 'JWT_SECRET=%s\nENCRYPTION_KEY=%s\n' "$(openssl rand -hex 32)" "$(openssl rand -hex 32)" > .env
docker compose up -d

步骤 3 — 在 Gemini 中添加连接器

你的服务器 URL: 在 AnythingMCP 中打开 MCP Servers → 此连接器所在的服务器,复制它的 URL(https://cloud.anythingmcp.com/mcp/…)。本指南中出现 YOUR_SERVER_ID 的地方都用它替换。

Gemini CLI 从 ~/.gemini/settings.json(Windows 上为 %USERPROFILE%\.gemini\settings.json)读取 MCP 服务器。添加:

{
  "mcpServers": {
    "anythingmcp": {
      "httpUrl": "https://cloud.anythingmcp.com/mcp/YOUR_SERVER_ID",
      "headers": { "X-API-Key": "YOUR_MCP_API_KEY" }
    }
  }
}
  1. 在 AnythingMCP 的 MCP Servers → 你的服务器 → API keys 中创建 MCP API 密钥,并用它替换 YOUR_MCP_API_KEY。
  2. 保存文件并重启 gemini。
  3. 在 Gemini CLI 中运行 /mcp(或在终端运行 gemini mcp list),anythingmcp 应显示为已连接。
  4. 开始输入提示,Gemini CLI 现在可以调用 X (Twitter) 的工具。

可用工具

ToolWhat it does
x_get_meRead the X account that authorized the connector: id, name, @username and the user fields asked for
x_get_user_by_usernameLook up one X account by its @username (without the @): id, name, bio, follower and post counts and more
x_get_users_by_usernamesLook up up to 100 X accounts by @username in one call
x_get_userLook up one X account by its numeric user id: name, @username, bio, counts and the user fields asked for
x_search_usersFind X accounts by name or @username keywords
x_get_postRead one post by id: text, author_id, time, metrics and the fields asked for
x_get_postsRead up to 100 posts by id in one call
x_list_user_postsList the most recent posts of an account (up to the last 3,200), newest first
x_list_user_mentionsList the most recent posts that mention an account (up to the last 800), newest first
x_get_home_timelineRead your home timeline in reverse chronological order: posts and reposts from you and the accounts you follow
x_search_recent_postsSearch posts from the last 7 days with X search operators, e.g. "anythingmcp lang:en -is:retweet", from:username, to:username, #hashtag…
x_count_recent_postsCount the posts of the last 7 days that match a search query, per minute, hour or day, without reading them
x_list_quote_postsList the posts that quote a given post, newest first, with the quoting text and author_id
x_list_reposted_byList the accounts that reposted a post, with the user fields asked for
x_list_liking_usersList the accounts that liked a post
x_create_postPublish a new post on the authorized account, visible to everyone at once
x_reply_to_postPublish a reply to a post, visible to everyone at once
x_quote_postPublish a post that quotes another post with your comment, visible to everyone at once
x_delete_postDelete one of your own posts for good
x_list_liked_postsList the posts an account liked, newest like first
x_like_postLike a post as the authorized account
x_unlike_postRemove your like from a post you liked before
x_repostRepost a post to your followers, visible to everyone at once
x_undo_repostTake back your repost of a post; the original post stays
x_list_bookmarksList your bookmarked posts, most recently bookmarked first (up to the last 800)
x_add_bookmarkBookmark a post
x_remove_bookmarkRemove a post from your bookmarks
x_list_followersList the accounts that follow an account, newest follower first
x_list_followingList the accounts an account follows, most recently followed first
x_follow_userFollow an account as the authorized account; the other account is notified
x_unfollow_userStop following an account as the authorized account
x_list_owned_listsList the X Lists an account owns: id, name, description, member and follower counts
x_list_followed_listsList the X Lists an account follows: id, name, description, member and follower counts
x_get_listRead one X List: name, description, member and follower counts, whether it is private and when it was created
x_list_list_postsRead the latest posts from the members of an X List, newest first
x_list_list_membersList the accounts that are members of an X List, with the user fields asked for
x_list_dm_eventsList your recent direct messages across all conversations (the last 30 days), newest first
x_list_dm_conversation_with_userRead your one-to-one direct message conversation with another account (the last 30 days), newest first
x_send_dmSend a direct message to an account, in your one-to-one conversation with it (created when needed)
x_send_dm_to_conversationSend a direct message into an existing conversation (one-to-one or group) by its dm_conversation_id from x_list_dm_events
x_delete_dmDelete one of your direct messages, for you only (the other side keeps it)

示例提示

  • “显示今天提及我账号的帖子,并为其中提问的帖子起草回复。”
  • “搜索最近 7 天关于我们产品发布的帖子,并总结整体语气。”
  • “本周每天有多少帖子提到了 #ourbrand?”
  • “起草一条宣布我们新定价页面的帖子,在我批准文字后发布。”

FAQ

Gemini CLI 从哪里读取 MCP 服务器? 用户级配置位于 ~/.gemini/settings.json,项目级配置位于项目内的 .gemini/settings.json。gemini mcp list 会列出每个服务器及其连接状态。

下一步

这份指南对你有帮助吗?

你的 X 智能体只差一次点击。

安装连接器,粘贴密钥,向 Gemini 提问。免费试用 7 天,无需信用卡。

相关指南

连接器

如何通过 MCP 将 X (Twitter) 连接到 ChatGPT

让你的 AI 使用 X(原 Twitter):读取和搜索帖子、你的时间线、提及、书签、列表和私信,查找账号和关注者,并在你确认后发布帖子、回复和引用,点赞、转发和发送私信。

连接器

如何通过 MCP 将 X (Twitter) 连接到 Claude

让你的 AI 使用 X(原 Twitter):读取和搜索帖子、你的时间线、提及、书签、列表和私信,查找账号和关注者,并在你确认后发布帖子、回复和引用,点赞、转发和发送私信。

连接器

如何通过 MCP 将 X (Twitter) 连接到 Cursor

让你的 AI 使用 X(原 Twitter):读取和搜索帖子、你的时间线、提及、书签、列表和私信,查找账号和关注者,并在你确认后发布帖子、回复和引用,点赞、转发和发送私信。

连接器

如何通过 MCP 将 X (Twitter) 连接到 Meta Muse

让你的 AI 使用 X(原 Twitter):读取和搜索帖子、你的时间线、提及、书签、列表和私信,查找账号和关注者,并在你确认后发布帖子、回复和引用,点赞、转发和发送私信。

连接器

X (Twitter) 接入 MCP:从任意 AI 代理驱动 X (Twitter)

让你的 AI 使用 X(原 Twitter):读取和搜索帖子、你的时间线、提及、书签、列表和私信,查找账号和关注者,并在你确认后发布帖子、回复和引用,点赞、转发和发送私信。

连接器

如何通过 MCP 将 Canva 连接到 Gemini

让你的 AI 在 Canva 中工作:查找和读取设计,创建新设计,将设计导出为 PDF、PNG、PowerPoint 或视频并获取下载链接,整理文件夹,通过链接上传图片,读取品牌模板,并在设计上发表评论。