Skip to main content
Glama

Grok MCP Plugin

npm version Smithery Build Status

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

Related MCP server: Grok MCP Server

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-mcp
  2. Install dependencies:

    npm install
  3. Build the project:

    npm run build
  4. 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.

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:

<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>

Image Understanding

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>

Function Calling

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>

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 build

Running

XAI_API_KEY="your-grok-api-key" node build/index.js

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgements

Available Tools

3 tools
chat_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

    B3.1/5.0

    Scored across 3 tools

    Disambiguation5/5

    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.

    Naming Consistency4/5

    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.

    Tool Count3/5

    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.

    Completeness3/5

    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

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      F
      maintenance
      A 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.
      34 npm
      ISC
    • A
      license
      B
      quality
      D
      maintenance
      Enables interaction with the Grok AI through an MCP server, supporting chat completions, text completions, embeddings, and model operations with streaming capabilities.
      5
      51 npm
      7
      MIT
    • A
      license
      B
      quality
      D
      maintenance
      Provides 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.
      3
      9
      MIT
    • A
      license
      B
      quality
      F
      maintenance
      Enables 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.
      1
      4 npm
      MIT

    Appeared in Searches