跳过安装。2 分钟内即可运行。
在 cloud.anythingmcp.com 开始免费试用,一键添加 xAI Grok,然后将你的 AI 客户端(Claude、ChatGPT、Copilot 或 Cursor)指向生成的 MCP 端点。无需 Docker,无需 git clone,无需任何工程经验。
AnythingMCP 已收录在 Claude 的连接器目录中:一键添加到 Claude (在新标签页中打开),然后登录并选择 Claude 可以使用哪些 MCP 服务器。
摘要
让你的 AI 用你自己的 xAI API 密钥向 Grok 提问:Grok 模型的回答、基于网络或 X 实时搜索并附来源的回答、在后台生成的长回答,以及直接在聊天中用 Grok Imagine 生成或编辑的图片。
试试这样问
xAI Grok 的示例提示
点击任意提示即可复制,然后粘贴到 Claude、ChatGPT、Cursor、Gemini、Copilot 或 OpenClaw 中,在该连接器上运行。
Claude 是 AI,可能会出错。请核对回答。
💡 无需安装? 直接使用 cloud.anythingmcp.com。 登录、点击 Connectors → xAI Grok、粘贴凭证、生成 MCP API key,即可完成。无 Docker、无
git clone、无本地服务器。
xAI Grok + Claude
让你的 AI 用你自己的 xAI API 密钥向 Grok 提问:Grok 模型的回答、基于网络或 X 实时搜索并附来源的回答、在后台生成的长回答,以及直接在聊天中用 Grok Imagine 生成或编辑的图片。
前提条件
完整的设置说明已内置在连接器中 (在 store 中选择连接器时可见)。所需环境变量:
XAI_API_KEY
步骤 1 — 获取凭证
- 登录
https://console.x.ai,在 Billing 中购买预付额度。Grok API 与 X Premium 或 SuperGrok 订阅相互独立,这些订阅不包含 API 使用;额度用完后请求会被拒绝。 - 打开 API Keys,创建一个密钥并复制(以
xai-开头)。 - 按 xAI 显示的原样将其粘贴到
XAI_API_KEY,不要加 Bearer 一词,然后安装连接器。密钥只会发送给 xAI。 - 先运行
xai_get_api_key_info:它不收费,并能显示密钥的名称、团队和权限。
计费使用你自己的 xAI 额度:每次调用 Grok 都会消耗你的预付额度。模型列表、密钥详情、token 计数和获取结果都是免费的。除非你要求更多,连接器默认使用低成本设置:文本用 grok-4.3(每百万输入 token 约 1.25 美元,每百万输出 token 约 2.50 美元,上下文 100 万 token),图片用 grok-imagine-image(每张约 0.02 美元)。旗舰模型是 grok-4.7(2 美元和 6 美元),grok-imagine-image-2.0 生成质量更高的图片(约 0.04 美元)。每个回答都会显示其费用。
功能:
xai_create_response通过 xAI 推荐的 Responses API 向 Grok 提问,支持通过链接输入图片、指令、推理强度和 JSON 输出。只有在你要求时才会保存回答;已保存的回答可以用xai_get_response读取并继续。- 借助
xai_web_search和xai_x_search,Grok 会自己搜索网络或 X 上的帖子,并附上来源回答。网络搜索可以限定在某些域名,X 搜索可以限定在某些账号和日期范围。搜索在 token 之外另行计费(网络约每 1,000 次搜索 5 美元;X 约每 1,000 条帖子 5 美元、每 1,000 个用户资料 10 美元),因此 AI 只在问题需要最新信息时才使用。 xai_start_deferred_completion和xai_get_deferred_completion在后台处理长回答。AI 每 10 到 30 秒查看一次,结果可在 24 小时内获取一次。xai_generate_image和xai_edit_image用 Grok Imagine 生成或修改图片,并直接显示在聊天中。编辑时,原图通过公开链接传入。xai_tokenize_text免费计算 token 数,xai_list_language_models、xai_list_image_models和xai_list_models显示你的密钥可以使用的模型及价格。
先确认:每张图片都要花钱,因此 AI 在每次调用 xai_generate_image 或 xai_edit_image 之前都会先征得你的确认,并且除非你要更多,只生成一张。xai_delete_response 在安装时处于关闭状态;启用后它同样会先确认,且删除的回答无法恢复。
时间限制:通过连接器的调用会在 30 秒后中断。快速回答请保持较低的推理强度,较长的回答交给后台工具。超过 4 MB 的图片不会在聊天中显示,所以请保持 1k 分辨率。
不可信内容:搜索结果、帖子和回答来自开放网络和 X。AI 会把其中的指令当作数据,而不是命令。
常见错误:400 Incorrect API key provided 表示密钥错误:xAI 对无效密钥返回 400 而不是 401,请从控制台重新复制。401 No credentials presented:缺少密钥。403:团队额度已用完,或密钥没有访问此端点或模型的权限(xai_get_api_key_info 会列出其权限);请在 Billing 中充值。404:模型不存在或你的团队无权访问,请查看 xai_list_language_models。422:某个字段格式不对,消息会指出是哪一个。429:速率限制;请稍候并重试一次。
该连接器不支持流式回答,不用 Chat Completions 生成普通回答(由 Responses API 负责),也不支持视频生成、语音、文件、collections、批处理任务以及兼容 Anthropic 的端点。
步骤 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 — 在 Claude 中添加连接器
你的服务器 URL: 在 AnythingMCP 中打开 MCP Servers → 此连接器所在的服务器,复制它的 URL(
https://cloud.anythingmcp.com/mcp/…)。本指南中出现YOUR_SERVER_ID的地方都用它替换。
推荐路径:在 claude.ai web 上工作,无需触碰任何配置文件。
- 在 Claude 中打开 Customize → Connectors。
- 点击 +,然后点击 Add custom connector。
- 输入名称(例如
xAI Grok)和远程 MCP 服务器 URLhttps://cloud.anythingmcp.com/mcp/YOUR_SERVER_ID,然后点击 Add。 - 点击 Connect,登录 AnythingMCP(OAuth)并允许访问。
下面所有工具都会出现在你的聊天中,开始输入提示。
可用工具
| Tool | What it does |
|---|---|
xai_list_language_models | List the Grok language models the API key can use, with id, aliases, input and output modalities, and prices |
xai_list_models | List every model id the xAI API key can use (language, image and video models) with owner and creation time |
xai_list_image_models | List the Grok Imagine image models the key can use, with id, aliases, maximum prompt length and price per image (pricing lists… |
xai_create_response | Ask Grok and get its answer through xAI's Responses API, the API xAI recommends |
xai_web_search | Ask Grok a question it answers by searching the web itself (Responses API with the web_search server-side tool; the old Live Search… |
xai_x_search | Ask Grok a question it answers by searching posts on X (Responses API with the x_search server-side tool), optionally limited to some… |
xai_get_response | Get a stored xAI response by id (one created with store true), with output_text, citations, status and usage |
xai_delete_response | Delete a stored xAI response, so it can no longer be read or continued |
xai_start_deferred_completion | Start a long Grok answer in the background (deferred chat completion) and get a request_id at once, for questions that may take longer than… |
xai_get_deferred_completion | Fetch the result of a deferred Grok answer started with xai_start_deferred_completion |
xai_generate_image | Create pictures from a text description with Grok Imagine and return them as images the user can see |
xai_edit_image | Change a picture with Grok Imagine from a text instruction (e.g. 'make the sky stormy', 'remove the car') and return the result as an image… |
xai_tokenize_text | Count the tokens a text uses with a Grok model's tokenizer, and list them, e.g. to estimate the cost of a long prompt |
xai_get_api_key_info | Get the details of the xAI API key in use: redacted key, name, team id, permissions (acls) and whether the key or the team is blocked or… |
示例提示
- “让 Grok 在 X 上搜索本周大家对我们产品发布的评价,并列出它用到的帖子。”
- “用 Grok 的网络搜索查找 Node.js 最新的发布说明,并附上来源做个总结。”
- “用 Grok Imagine 为我们的电子报生成一张温馨阅读角的图片,但先和我确认费用。”
- “这份合同文本用 Grok 的分词器有多少个 token?用 grok-4.3 做摘要大概要花多少钱?”
FAQ
Claude Code 和 Claude Desktop 一样工作吗? 是的,两者都指向 https://cloud.anythingmcp.com/mcp/YOUR_SERVER_ID。
下一步
这份指南对你有帮助吗?