X Tools for Claude MCP

by 0xGval

Claude MCP 的 X 工具

一个轻量级的开源工具包,使 Claude 能够使用自然语言高效地搜索 Twitter,并根据用户意图显示结果。它专为查看原始数据和进行可选分析而设计。

特征

  • 自然语言搜索:让 Claude 用简单的英语搜索 Twitter
  • Twitter 搜索:使用自然语言或高级 Twitter 语法搜索推文
  • 专业格式:清晰、markdown 格式的推文显示
  • 灵活的输出:显示原始推文或根据您的要求添加分析
  • 高级过滤:按关键词、用户、日期、参与度指标等查找推文
  • 分页支持:需要时,每次搜索可检索超过默认的 20 条推文

安装

先决条件

  • Node.js v16+
  • 克劳德桌面版
  • 免费的 RapidAPI 密钥,可访问“The Old Bird API”(Twitter154)端点

RapidAPI 密钥设置

  1. 访问RapidAPI 上的 The Old Bird API
  2. 如果您没有 RapidAPI 帐户,请注册一个
  3. 订阅 API(有免费套餐可用)
  4. 订阅后,从仪表板复制您的 RapidAPI 密钥

设置步骤

  1. 克隆此存储库
    git clone https://github.com/0xGval/twitter-X-mcp-server cd twitter-X-mcp-tools
  2. 安装依赖项
    npm install
  3. 创建您的配置
    • mcp.json.example复制到 Claude Desktop 目录中的mcp.json
    • 编辑mcp.json以包含您的 RapidAPI 密钥和正确的文件路径
    { "mcpServers": { "x-tools": { "command": "node", "args": ["YOUR_ABSOLUTE_PATH_TO/main.js"], "env": { "RAPIDAPI_KEY": "your_rapidapi_key" } } } }
  4. 配置 Claude 桌面版
    • 在 Windows 上:将mcp.json文件放在%APPDATA%\Claude\
    • 在 macOS 上:将mcp.json文件放在~/Library/Application Support/Claude/
    • claude-rules.mdknowledge/TwitterSearchSyntaxGuide.txt复制到你的 Claude 知识库目录
    • 重新启动 Claude Desktop 以使更改生效

可用工具

Twitter 搜索

该工具主要设计用于自然语言。只需让 Claude 在 Twitter 上搜索某个内容,它就会翻译你的请求。

searchTwitter(query: "keyword", section: "latest", limit: 20)

使用自然语言或高级语法搜索 Twitter:

  • query :搜索查询(支持 Twitter 的高级搜索运算符)
  • section :“最新”或“顶级”结果(默认值:“最新”)
  • limit :返回的推文数量(默认值:20)

自然语言示例

简单查询

问克劳德:

Show me recent tweets about artificial intelligence

以用户为中心的查询

问克劳德:

Find the latest tweets from Elon Musk that mention SpaceX

复杂自然查询

问克劳德:

Search for tweets about climate change with at least 100 likes from the past month

分析请求

问克劳德:

What's the sentiment around the new Bitcoin ETF based on recent tweets?

直接语法示例

对于那些喜欢直接语法的人来说:

from:elonmusk spacex since:2023-01-01
"artificial intelligence" filter:images min_faves:100
climate action min_retweets:50 -filter:retweets

所需文件

此工具包含几个必须正确设置的重要文件:

  • main.js :主应用程序文件
  • tools/twitter.js :Twitter 搜索实现
  • claude-rules.md :Claude 正确显示搜索结果的说明
  • knowledge/TwitterSearchSyntaxGuide.txt :Twitter 搜索语法参考指南

确保所有这些文件都放置在 Claude 设置中的正确位置。

搜索语法

该工具支持所有标准 Twitter 搜索运算符,Claude 可以通过您的自然语言应用这些运算符:

用户

  • from:username - 特定帐户发送的推文
  • to:username - 回复特定帐户
  • @username - 提及该帐户的推文

媒体和链接

  • filter:media - 包含任何媒体的推文
  • filter:images - 带图片的推文
  • filter:native_video - 带有视频的推文
  • filter:links - 带链接的推文

日期

  • since:YYYY-MM-DD - 此日期之后的推文
  • until:YYYY-MM-DD - 此日期之前的推文

订婚

  • min_retweets:n - 至少有 n 次转发的推文
  • min_faves:n - 至少有 n 个赞的推文
  • min_replies:n - 至少有 n 条回复的推文

故障排除

常见问题:

  • 未找到 API 密钥:确保您的 RapidAPI 密钥在mcp.json中正确设置
  • 路径错误:确保您使用完整的绝对路径,并在 Windows 中正确转义( \\
  • 无结果:请检查您的搜索查询是否有效且没有太多限制
  • Claude 行为问题:确保您拥有最新版本的claude-rules.md ,其中包含灵活的输出指令
  • 缺少文件:验证claude-rules.mdTwitterSearchSyntaxGuide.txt是否已正确添加到您的 Claude 规则和知识库中

发展

要修改该工具:

  1. 编辑tools/目录中的文件
  2. 如果需要,更新formatTwitterResults()函数中的格式
  3. 重新启动 Claude for Desktop 即可看到更改

执照

该项目已获得 MIT 许可。

致谢

  • Anthropic 的模型上下文协议 (MCP)
  • RapidAPI Twitter154 API
  • Axios
  • 佐德

注意:此工具旨在与 Claude AI 助手配合使用,并根据用户意图为 Twitter 搜索结果提供灵活的显示选项。

-
security - not tested
-
license - not tested
-
quality - not tested

这是一个轻量级工具包,使 Claude 能够使用自然语言查询搜索 Twitter 并根据用户意图显示结果,支持推文过滤、分页和灵活的输出格式等功能。

  1. Features
    1. Installation
      1. Prerequisites
      2. RapidAPI Key Setup
      3. Setup Steps
    2. Available Tools
      1. Twitter Search
    3. Natural Language Examples
      1. Simple Query
      2. User-Focused Query
      3. Complex Natural Query
      4. Analysis Request
    4. Direct Syntax Examples
      1. Required Files
        1. Search Syntax
          1. Users
          2. Media and Links
          3. Dates
          4. Engagement
        2. Troubleshooting
          1. Development
            1. License
              1. Acknowledgements

                Related MCP Servers

                • -
                  security
                  A
                  license
                  -
                  quality
                  Interact with Twitter search and timeline
                  Last updated -
                  4
                  41
                  Python
                  MIT License
                • A
                  security
                  A
                  license
                  A
                  quality
                  Server for X (Twitter) integration that provides tools for reading your timeline and engaging with tweets. Designed for use with Claude desktop.
                  Last updated -
                  3
                  0
                  9
                  JavaScript
                  MIT License
                • A
                  security
                  A
                  license
                  A
                  quality
                  An MCP server that enables Claude to interact with Twitter, allowing for posting tweets and searching Twitter content.
                  Last updated -
                  2
                  90
                  151
                  TypeScript
                  MIT License
                  • Apple
                • -
                  security
                  F
                  license
                  -
                  quality
                  Provides tools for interacting with Twitter to retrieve tweets by ID and post new tweets using the agent-twitter-client library.
                  Last updated -
                  4
                  JavaScript

                View all related MCP servers

                ID: qvpthi7w1o