The Grok MCP Plugin integrates Grok AI's capabilities directly with Cline, providing seamless access to chat completion, image understanding, and function calling tools through the Model Context Protocol (MCP) interface.
Clone the repository:
git clone https://github.com/Bob-lance/grok-mcp.git
cd grok-mcp
Install dependencies:
npm install
Build the project:
npm run build
Configure in Cline MCP settings:
For VSCode Cline extension, edit the settings file at:
~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
Add this 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": []
}
}
}
Make sure to:
/path/to/grok-mcp
with your actual installation pathyour-grok-api-key
to your actual Grok AI API keyThe Grok MCP plugin provides three main 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>
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>
Note: Either image_url
or base64_image
must be provided.
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "grok-mcp" '{"command":"node","args":["/path/to/grok-mcp/build/index.js"],"env":{"XAI_API_KEY":"your-grok-api-key"},"disabled":false,"autoApprove":[]}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"grok-mcp": {
"command": "node",
"args": [
"/path/to/grok-mcp/build/index.js"
],
"env": {
"XAI_API_KEY": "your-grok-api-key"
},
"disabled": false,
"autoApprove": []
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"grok-mcp": {
"command": "node",
"args": [
"/path/to/grok-mcp/build/index.js"
],
"env": {
"XAI_API_KEY": "your-grok-api-key"
},
"disabled": false,
"autoApprove": []
}
}
}
3. Restart Claude Desktop for the changes to take effect