Grok MCP Plugin
Grok MCP 插件
模型上下文协议 (MCP) 插件可直接从 Cline 无缝访问 Grok AI 的强大功能。
特征
该插件通过 MCP 接口公开了三个强大的工具:
聊天完成- 使用 Grok 的语言模型生成文本响应
图像理解——利用 Grok 的视觉功能分析图像
函数调用——使用 Grok 根据用户输入调用函数
Related MCP server: Grok MCP Server
先决条件
Node.js(v16 或更高版本)
Grok AI API 密钥(从console.x.ai获取)
Cline 与 MCP 支持
安装
克隆此存储库:
git clone https://github.com/Bob-lance/grok-mcp.git cd grok-mcp安装依赖项:
npm install构建项目:
npm run build将 MCP 服务器添加到您的 Cline MCP 设置:
对于 VSCode Cline 扩展,请编辑以下文件:
~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json添加以下配置:
{ "mcpServers": { "grok-mcp": { "command": "node", "args": ["/path/to/grok-mcp/build/index.js"], "env": { "XAI_API_KEY": "your-grok-api-key" }, "disabled": false, "autoApprove": [] } } }将
/path/to/grok-mcp替换为您的安装的实际路径,并将your-grok-api-key替换为您的 Grok AI API 密钥。
用法
安装并配置完成后,Grok MCP 插件将提供三个可在 Cline 中使用的工具:
聊天完成
使用 Grok 的语言模型生成文本响应:
<use_mcp_tool>
<server_name>grok-mcp</server_name>
<tool_name>chat_completion</tool_name>
<arguments>
{
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Hello, what can you tell me about Grok AI?"
}
],
"temperature": 0.7
}
</arguments>
</use_mcp_tool>图像理解
使用 Grok 的视觉功能分析图像:
<use_mcp_tool>
<server_name>grok-mcp</server_name>
<tool_name>image_understanding</tool_name>
<arguments>
{
"image_url": "https://example.com/image.jpg",
"prompt": "What is shown in this image?"
}
</arguments>
</use_mcp_tool>您还可以使用 base64 编码的图像:
<use_mcp_tool>
<server_name>grok-mcp</server_name>
<tool_name>image_understanding</tool_name>
<arguments>
{
"base64_image": "base64-encoded-image-data",
"prompt": "What is shown in this image?"
}
</arguments>
</use_mcp_tool>函数调用
使用 Grok 根据用户输入调用函数:
<use_mcp_tool>
<server_name>grok-mcp</server_name>
<tool_name>function_calling</tool_name>
<arguments>
{
"messages": [
{
"role": "user",
"content": "What's the weather like in San Francisco?"
}
],
"tools": [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the current weather in a given location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA"
},
"unit": {
"type": "string",
"enum": ["celsius", "fahrenheit"],
"description": "The unit of temperature to use"
}
},
"required": ["location"]
}
}
}
]
}
</arguments>
</use_mcp_tool>API 参考
聊天完成
使用 Grok AI 聊天完成生成响应。
参数:
messages(必需):具有角色和内容的消息对象数组model(可选):要使用的 Grok 模型(默认为 grok-2-latest)temperature(可选):采样温度(0-2,默认为1)max_tokens(可选):要生成的最大令牌数(默认为 16384)
图像理解
使用 Grok AI 视觉功能分析图像。
参数:
prompt(必需):与图片一起出现的文字提示image_url(可选):要分析的图像的 URLbase64_image(可选):Base64 编码的图像数据(不带 data:image 前缀)model(可选):要使用的 Grok 视觉模型(默认为 grok-2-vision-latest)
注意:必须提供image_url或base64_image 。
函数调用
使用 Grok AI 根据用户输入调用函数。
参数:
messages(必需):具有角色和内容的消息对象数组tools(必需):具有类型、函数名称、描述和参数的工具对象数组tool_choice(可选):工具选择模式(自动、必需、无,默认为自动)model(可选):要使用的 Grok 模型(默认为 grok-2-latest)
发展
项目结构
src/index.ts- 主服务器实现src/grok-api-client.ts- Grok API 客户端实现
建筑
npm run build跑步
XAI_API_KEY="your-grok-api-key" node build/index.js执照
该项目根据 MIT 许可证获得许可 - 有关详细信息,请参阅LICENSE文件。
致谢
Available Tools
3 toolschat_completionC
Generate a response using Grok AI chat completion
Inputs: messages (required), max_tokens, model, temperature.
function_callingC
Use Grok AI to call functions based on user input
Inputs: messages (required), tools (required), model, tool_choice.
image_understandingC
Analyze images using Grok AI vision capabilities (Note: Grok 3 may support image creation)
Inputs: prompt (required), base64_image, image_url, model.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 3 tools
Each tool has a clearly distinct purpose: chat_completion handles text generation, function_calling manages function execution, and image_understanding focuses on visual analysis. There is no overlap in functionality, making tool selection straightforward for an agent.
The tools follow a consistent snake_case naming convention, but the pattern is not strictly verb_noun (e.g., chat_completion, function_calling, image_understanding). The naming is readable and logical, with only minor deviations from a perfect pattern.
With only 3 tools, the set feels thin for a general-purpose AI plugin, potentially lacking operations like text summarization, translation, or audio processing. However, it covers core AI functionalities adequately for basic use cases.
The tools cover key AI areas (text, functions, images), but there are notable gaps such as missing text analysis tools (e.g., sentiment analysis, summarization) and no explicit support for audio or video processing. The surface is functional but not comprehensive for a full AI suite.
Maintenance
Related MCP Connectors
One thread for every AI assistant you use. Share tasks and context across ChatGPT, Claude and Grok.
Pay-per-call chat on GPT-6.1, Claude, Gemini and Grok over x402. No API key; a failed call is free.
Pay-per-call chat on GPT-6.1, Claude, Gemini and Grok over x402. No API key; a failed call is free.
Source-checked CLI guides and model-aware planning for Claude Code, Codex, and Grok Build.
Related MCP Servers
- AlicenseNot gradedqualityFmaintenanceA custom Model Context Protocol implementation that integrates Perplexity AI with Claude Desktop, allowing users to access Perplexity's AI models for both single questions and multi-turn conversations.23 npmISC
- AlicenseBqualityDmaintenanceEnables interaction with the Grok AI through an MCP server, supporting chat completions, text completions, embeddings, and model operations with streaming capabilities.516 npm7MIT
- AlicenseBqualityDmaintenanceProvides seamless access to Grok AI models through the Model Context Protocol by wrapping the official Grok CLI, offering tools for general queries, multi-turn conversations, and code generation.39MIT
- AlicenseBqualityFmaintenanceEnables chat completions using x.ai's Grok API with support for multiple Grok models (grok-beta, grok-2-latest, grok-4-latest) and configurable parameters like temperature and max tokens.14 npmMIT