实时X搜索服务

一个基于xAI的Grok API,通过Model Context Protocol服务器为Claude提供实时的X/Twitter搜索功能,包括帖子、用户、线程和趋势话题的即时访问。

  • by guzus
  • Python
  • 本地部署
  • 4 星标
  • 更新于
在 GitHub 查看 guzus/grok-mcp

使用说明

Grok MCP服务器

使用xAI的Grok API实时搜索X.com-直接从Claude

A. 模型上下文协议 服务器带来 实时X/Twitter搜索 克劳德。由xAI的Live Search API提供支持,它提供对帖子、用户、线程和趋势主题的即时访问。

为什么选择Grok MCP?

  • 实时数据 -访问实时X.com内容,而不是缓存或过时的信息
  • 克劳德原住民融合 -与Claude Desktop和Claude Code无缝协作
  • 简单设置 -一个安装命令,一个添加配置
  • 开源 -麻省理工学院授权,社区驱动

快速开始

1.获取xAI API密钥

从获取API密钥 console.x.ai

2.安装

uvx grok-mcp

3.配置Claude

克劳德代码 -添加到 .mcp.json 在您的项目中:

{
  "mcpServers": {
    "grok": {
      "command": "uvx",
      "args": ["grok-mcp"],
      "env": {
        "XAI_API_KEY": "your-api-key"
      }
    }
  }
}

适用于克劳德桌面 -添加到您的配置文件中:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • 窗户: %APPDATA%\Claude\claude_desktop_config.json
{
  "mcpServers": {
    "grok": {
      "command": "uvx",
      "args": ["grok-mcp"],
      "env": {
        "XAI_API_KEY": "your-api-key"
      }
    }
  }
}

4.使用它

问克劳德这样的问题:

  • “在X上搜索有关AI的帖子”
  • “现在X的趋势是什么?”
  • “查找@elonmusk关于特斯拉的推文”

可用工具

工具 说明
search_posts 使用过滤器(句柄、日期范围、分析模式)搜索帖子
search_users 查找用户资料
search_threads 发现对话线索
get_trends 按位置获取热门话题
health_check 验证API连接

例子

搜索文章

Search X for posts about "AI safety" from the last week

按用户筛选

Find recent posts from @anthropic about Claude

获取趋势

What are the trending topics in tech right now?

发展

# Clone
git clone https://github.com/guzus/grok-mcp.git
cd grok-mcp

# Install dependencies
uv sync --dev

# Run tests
uv run pytest

# Run locally
XAI_API_KEY=your-key uv run python -m grok_mcp

建筑

src/grok_mcp/
├── server.py           # MCP server implementation
├── grok_client.py      # xAI Live Search API client
├── search_tools.py     # Tool implementations
├── response_formatter.py
├── config.py
└── exceptions.py

贡献

欢迎投稿!请随时提交拉取请求。

  1. 克隆该仓库
  2. 创建功能分支(git checkout -b feature/amazing-feature)
  3. 提交您的更改(git commit -m 'Add amazing feature')
  4. 推到分支(git push origin feature/amazing-feature)
  5. 打开拉取请求

许可证

MIT许可证-请参阅 许可证 了解详情。

链接


建于 xAI Grok 和 模型上下文协议