A Model Context Protocol (MCP) plugin that provides seamless access to Grok AI's powerful capabilities directly from Claude Code and Cline.
Fork Notice: This is an enhanced fork with real-time web/X search support via
search_parameters. Original: Bob-lance/grok-mcp
This plugin exposes three powerful tools through the MCP interface:
- Chat Completion - Generate text responses using Grok's language models with real-time web/X search support
- Image Understanding - Analyze images with Grok's vision capabilities
- Function Calling - Use Grok to call functions based on user input
This fork adds comprehensive search_parameters support to enable Grok's real-time web and X/Twitter search capabilities:
- mode:
auto(model decides),on(force search), oroff(disable) - sources: Array of
web,x,news,rss - Date filtering:
from_date,to_date(ISO 8601) - Geographic filtering:
countrycode - Website exclusions:
excluded_websitesarray - X-specific filters:
x_handles,x_min_favorites,x_min_views
- Node.js (v16 or higher)
- A Grok AI API key (obtain from console.x.ai)
- Cline with MCP support
-
Clone this repository:
git clone https://github.com/Bob-lance/grok-mcp.git cd grok-mcp -
Install dependencies:
npm install
-
Build the project:
npm run build
-
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-mcpwith the actual path to your installation andyour-grok-api-keywith your Grok AI API key.
Once installed and configured, the Grok MCP plugin provides three tools that can be used in Cline:
Generate text responses using Grok's language models:
<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>Enable real-time web and X/Twitter search:
<use_mcp_tool>
<server_name>grok-mcp</server_name>
<tool_name>chat_completion</tool_name>
<arguments>
{
"messages": [
{
"role": "user",
"content": "What are the latest AI developments this week?"
}
],
"model": "grok-4-1-fast",
"search_parameters": {
"mode": "auto",
"sources": ["web", "x"],
"from_date": "2026-01-11"
}
}
</arguments>
</use_mcp_tool>Analyze images with Grok's vision capabilities:
<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>You can also use base64-encoded images:
<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>Use Grok to call functions based on user input:
<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>Generate a response using Grok AI chat completion.
Parameters:
messages(required): Array of message objects with role and contentmodel(optional): Grok model to use (defaults to grok-4-1-fast)grok-4-1-fast- 2M context, reasoning, recommended for searchgrok-4-1-fast-non-reasoning- 2M context, instant responsesgrok-code-fast-1- 256K context, optimized for codinggrok-3-mini-beta- Economical option
temperature(optional): Sampling temperature (0-2, defaults to 1)max_tokens(optional): Maximum number of tokens to generate (defaults to 16384)search_parameters(optional): Enable real-time web/X searchmode(string):auto(model decides),on(force search), oroff(disable)sources(array): Array ofweb,x,news,rss(defaults to["web", "x"])from_date(string): Start date for results (ISO 8601, e.g., "2026-01-11")to_date(string): End date for results (ISO 8601)country(string): Country code filter (e.g., "US", "GB")excluded_websites(array): Websites to exclude from resultsx_handles(array): Specific X/Twitter accounts to searchx_min_favorites(integer): Minimum likes threshold for X postsx_min_views(integer): Minimum views threshold for X posts
Analyze images using Grok AI vision capabilities.
Parameters:
prompt(required): Text prompt to accompany the imageimage_url(optional): URL of the image to analyzebase64_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.
Use Grok AI to call functions based on user input.
Parameters:
messages(required): Array of message objects with role and contenttools(required): Array of tool objects with type, function name, description, and parameterstool_choice(optional): Tool choice mode (auto, required, none, defaults to auto)model(optional): Grok model to use (defaults to grok-4-1-fast)
src/index.ts- Main server implementationsrc/grok-api-client.ts- Grok API client implementation
npm run buildXAI_API_KEY="your-grok-api-key" node build/index.jsThis project is licensed under the MIT License - see the LICENSE file for details.