The Grok MCP Plugin provides seamless access to Grok AI's powerful capabilities directly from Cline using the Model Context Protocol (MCP). It enables you to use Grok's language models, vision capabilities, and function calling features through a simple 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
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.json
Add 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.
Once installed and configured, you can use three different tools with the Grok MCP plugin 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.
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 > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
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 explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.