MG

merterbak/grok-mcp

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

57 stars 21 forks 质量 76 趋势 20MIT

merterbak/grok-mcp 是从 https://github.com/merterbak/grok-mcp. 导入的 MCP 服务器候选

概览

merterbak/grok-mcp 是从 https://github.com/merterbak/grok-mcp. 导入的 MCP 服务器候选

概述(AI 翻译)

支持xAI的Grok API的MCP服务器,支持Web/X搜索、视觉、图像/视频生成和文件支持。

特色

  • 代理工具调用:网页搜索、X搜索、代码执行和多步推理图像生成
  • 多个 Grok 模型:可访问最新型号,如 grok-4.6、grok-4.5、grok-build-0.1 等
  • 图像和视频生成:使用Grok Imagine创建图像和视频
  • 视觉能力:使用Grok的视觉模型分析图像
  • 文件API:上传、管理和聊天文档
  • 有状态对话:在多个请求中以id形式维护对话上下文
  • 本地聊天记录:将客户端聊天历史保存为JSON文件的选项。

先修条件

  • Python 3.11 或更高版本
  • xAI API 密钥(点击这里获取)
  • 星体紫外

安装

  1. 克隆仓库:

  2. 营造venv环境:

  3. 安装依赖:

配置

Claude桌面集成

将此添加到您的Claude桌面配置文件中:

Claude 代码集成

在项目目录中执行以下命令:

或者如果你有带有密钥的.env文件:

确认它已注册:

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

Grok-MCP

MCP server for xAI’s Grok API with Web/X search, vision, image/video generation and file support.

Features

  • Agentic Tool Calling: Web search, X search, code execution, and image generation with multi-step reasoning
  • Multiple Grok Models: Access to latest models such as grok-4.6, grok-4.5, grok-build-0.1 and more
  • Image and Video Generation: Create images and videos using Grok Imagine
  • Vision Capabilities: Analyze images with Grok’s vision models
  • Files API: Upload, manage, and chat with documents
  • Stateful Conversations: Maintain conversation context as id across multiple requests
  • Local Chat History: Option to save persistent client side chat history as JSON files in chats/

Prerequisites

Installation

  1. Clone the repository:
git clone https://github.com/merterbak/Grok-MCP.git
cd Grok-MCP
  1. Create a venv environment:
uv venv
source .venv/bin/activate # macOS/Linux or .venv\Scripts\activate on Windows
  1. Install dependencies:
uv sync

Configuration

Claude Desktop Integration

Add this to your Claude Desktop configuration file:

{
  "mcpServers": {
    "grok": {
      "command": "uv",
      "args": [
        "--directory",
        "/path/to/Grok-MCP",
        "run",
        "python",
        "main.py"
      ],
      "env": {
        "XAI_API_KEY": "your_api_key_here"
      }
    }
  }
}

Claude Code Integration

Run this command from inside the project directory:

claude mcp add grok-mcp -e XAI_API_KEY=your_api_key_here -- uv run --directory /path/to/Grok-MCP python main.py

Or if you have a .env file with your key:

 claude mcp add grok-mcp -- uv run --directory /path/to/Grok-MCP python main.py

Verify it’s registered:

claude mcp list

Filesystem MCP (Optional)

Claude Desktop can’t send uploaded images in the chat to an MCP tool. The easiest way to give access to files directly from your computer is official Filesystem MCP server. After setting it up you’ll be able to just write the image’s file path (such as /Users/mert/Desktop/image.png) in chat and Claude can use it with any vision chat tool.

{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-filesystem",
        "/Users//Desktop",
        "/Users//Downloads"
      ]
    }
  }
}


For stdio:

uv run python main.py

Docker:

docker compose up --build

Mcp Inspector:

mcp dev main.py

Available Tools

在 GitHub 查看完整 README

安装

npx -y @modelcontextprotocol/server-filesystem /Users/<your-username>/Desktop /Users/<your-username>/Downloads
新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "grok": { "command": "uv", "args": [ "--directory", "/path/to/Grok-MCP", "run", "python", "main.py" ], "env": { "XAI_API_KEY": "your_api_key_here" } } } }