grok-mcp
MCP server for Grok AI API integration
Documentation
Grok MCP Plugin
A Model Context Protocol (MCP) plugin that provides seamless access to Grok AI's powerful capabilities directly from Cline.
Features
This plugin exposes three powerful tools through the MCP interface:
1. Chat Completion - Generate text responses using Grok's language models
2. Image Understanding - Analyze images with Grok's vision capabilities
3. Function Calling - Use Grok to call functions based on user input
Prerequisites
- Node.js (v16 or higher)
- A Grok AI API key (obtain from console.x.ai)
- Cline with MCP support
Installation
1. Clone this repository:
git clone https://github.com/Bob-lance/grok-mcp.git
cd grok-mcp2. Install dependencies:
npm install3. Build the project:
npm run build4. Add the MCP server to your Cline MCP settings:
For VSCode Cline extension, edit the file at:
~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.jsonAdd the following configuration:
{
"mcpServers": {
"grok-mcp": {
"command": "node",
"args": ["/path/to/grok-mcp/build/index.js"],
"env": {
"XAI_API_KEY": "your-grok-api-key"
},
"disabled": false,
"autoApprove": []
}
}
}Replace `/path/to/grok-mcp` with the actual path to your installation and `your-grok-api-key` with your Grok AI API key.
Usage
Once installed and configured, the Grok MCP plugin provides three tools that can be used in Cline:
Chat Completion
Generate text responses using Grok's language models:
grok-mcp
chat_completion
{
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Hello, what can you tell me about Grok AI?"
}
],
"temperature": 0.7
}Image Understanding
Analyze images with Grok's vision capabilities:
grok-mcp
image_understanding
{
"image_url": "https://example.com/image.jpg",
"prompt": "What is shown in this image?"
}You can also use base64-encoded images:
grok-mcp
image_understanding
{
"base64_image": "base64-encoded-image-data",
"prompt": "What is shown in this image?"
}Function Calling
Use Grok to call functions based on user input:
grok-mcp
function_calling
{
"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"]
}
}
}
]
}API Reference
Chat Completion
Generate a response using Grok AI chat completion.
Parameters:
- `messages` (required): Array of message objects with role and content
- `model` (optional): Grok model to use (defaults to grok-3-mini-beta)
- `temperature` (optional): Sampling temperature (0-2, defaults to 1)
- `max_tokens` (optional): Maximum number of tokens to generate (defaults to 16384)
Image Understanding
Analyze images using Grok AI vision capabilities.
Parameters:
- `prompt` (required): Text prompt to accompany the image
- `image_url` (optional): URL of the image to analyze
- `base64_image` (optional): Base64-encoded image data (without the data:image prefix)
- `model` (optional): Grok vision model to use (defaults to grok-2-vision-latest)
Note: Either `image_url` or `base64_image` must be provided.
Function Calling
Use Grok AI to call functions based on user input.
Parameters:
- `messages` (required): Array of message objects with role and content
- `tools` (required): Array of tool objects with type, function name, description, and parameters
- `tool_choice` (optional): Tool choice mode (auto, required, none, defaults to auto)
- `model` (optional): Grok model to use (defaults to grok-3-mini-beta)
Development
Project Structure
- `src/index.ts` - Main server implementation
- `src/grok-api-client.ts` - Grok API client implementation
Building
npm run buildRunning
XAI_API_KEY="your-grok-api-key" node build/index.jsLicense
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgements
Frequently asked questions
What is grok-mcp?
grok-mcp is MCP server for Grok AI API integration
How do I install grok-mcp?
Open the GitHub repository and follow its README. Most MCP servers are added to your client's MCP config, then called by your agent.
Is grok-mcp open source?
Yes — it is hosted on GitHub at https://github.com/Bob-lance/grok-mcp and has 25 stars.
Related MCP tools
🔥 Official Firecrawl MCP Server - Adds powerful web scraping and search to Cursor, Claude and any other LLM clients.
Use any LLMs (Large Language Models) for Deep Research. Support SSE API and MCP server.
Enhanced MCP server for interactive user feedback and command execution in AI-assisted development, featuring dual interface support (Web UI and Desktop Application) with intelligent environment detection and cross-platform compatibility.
A powerful Zotero AI and MCP plugin with ChatGPT, Gemini 3.7, Claude Fable 5, Claude Opus 5, DeepSeek V4, Grok, OpenRouter, Kimi k3, GLM 5.3, SiliconFlow, GPT-oss, Gemma 4, Qwen 3.8
Connect your browser to AI models. Just use Dia on Chrome, Arc or Firefox.
文颜 MCP Server 可以让 AI 自动将 Markdown 文章排版后发布至微信公众号。
Run your own MCP server? See who uses it and what to fix.
Measure it with TrackMCP