Skip to main content
Glama
darkangelpraha

x.ai Grok MCP Server

x.ai Grok MCP Server

Model Context Protocol (MCP) server for interacting with x.ai Grok API.

Features

  • Chat completions via x.ai Grok API

  • Support for multiple Grok models (grok-beta, grok-2-latest, grok-4-latest)

  • System and user message support

  • Configurable temperature and max tokens

  • Secure API key management via 1Password CLI

Installation

Via npm

npx -y mcp-server-xai-grok

Local Development

git clone https://github.com/darkangelpraha/xai-grok-mcp-server.git
cd xai-grok-mcp-server
npm install
npm run build
npm start

Configuration

Claude Desktop

Add to ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "xai-grok": {
      "command": "/usr/local/bin/npx",
      "args": ["-y", "mcp-server-xai-grok"],
      "env": {
        "XAI_API_KEY": "op://AI/API Credentials | Grok Business/API KEY"
      },
      "description": "x.ai Grok API MCP server for chat completions"
    }
  }
}

Environment Variables

  • XAI_API_KEY (required): Your x.ai API key. Use 1Password CLI reference: op://AI/API Credentials | Grok Business/API KEY

Usage

Available Tools

chat_completion

Send a chat completion request to x.ai Grok API.

Parameters:

  • messages (required): Array of chat messages with role and content

  • model (optional): Model to use (grok-beta, grok-2-latest, grok-4-latest). Default: grok-4-latest

  • temperature (optional): Sampling temperature (0-2). Default: 1.0

  • max_tokens (optional): Maximum tokens to generate

Example:

{
  "messages": [
    {
      "role": "system",
      "content": "You are a helpful assistant."
    },
    {
      "role": "user",
      "content": "Hello, how are you?"
    }
  ],
  "model": "grok-4-latest",
  "temperature": 0.7
}

Testing

With MCP Inspector

npx -y @modelcontextprotocol/inspector npx -y mcp-server-xai-grok

Local Testing

# Set API key
export XAI_API_KEY="your-api-key-here"

# Run server
npm run dev

Requirements

  • Node.js 20.0.0 or higher

  • x.ai API key with credits/licenses

License

MIT

Author

darkangelpraha

Repository

https://github.com/darkangelpraha/xai-grok-mcp-server

Available Tools

1 tool
chat_completionC

Send a chat completion request to x.ai Grok API. Supports system messages, user messages, and various models (grok-beta, grok-2-latest, grok-4-latest).

ParametersJSON Schema
NameRequiredDescriptionDefault
messagesYesArray of chat messages. Each message should have 'role' (system/user/assistant) and 'content' (string).
modelNoThe Grok model to use. Options: grok-beta, grok-2-latest, grok-4-latestgrok-4-latest
temperatureNoSampling temperature between 0 and 2. Higher values make output more random.
max_tokensNoMaximum number of tokens to generate

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It mentions the API target and supported features but fails to disclose critical behavioral traits: whether this is a read/write operation, authentication needs, rate limits, response format, error handling, or costs. For an API call tool with zero annotation coverage, this leaves significant gaps in understanding how the tool behaves.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose and key features. It avoids redundancy and wastes no words, though it could be slightly more structured for clarity. Every element earns its place, making it appropriately concise for the tool's complexity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (API interaction with 4 parameters) and lack of annotations or output schema, the description is incomplete. It covers basic functionality but misses essential context: no information on return values, error cases, authentication, or operational constraints. This leaves the agent under-informed for safe and effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, providing detailed documentation for all 4 parameters. The description adds minimal value beyond the schema, only reiterating supported models and message roles without new syntax or format details. With high schema coverage, the baseline score of 3 is appropriate, as the description doesn't significantly enhance parameter understanding.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Send a chat completion request') and target resource ('to x.ai Grok API'), with specific mention of supported message types and models. It distinguishes this as an API interaction tool, though without sibling tools, differentiation isn't applicable. The purpose is specific but could be more precise about the exact function beyond 'send a request'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives, prerequisites, or contextual constraints. It mentions supported features but lacks explicit usage scenarios, exclusions, or comparisons. Without sibling tools, this is less critical, but still a gap for effective agent decision-making.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 1 tool updatev1.0.0
    • First observedchat_completion

TDQS

B3.1/5.0

Scored across 1 tool

Disambiguation5/5

With only one tool, there is no possibility of ambiguity or overlap between tools. The tool's purpose is clearly defined as sending chat completion requests to the x.ai Grok API, making it distinct by default.

Naming Consistency5/5

The single tool name 'chat_completion' follows a clear and consistent verb_noun pattern. Since there are no other tools to compare against, there is no inconsistency in naming conventions.

Tool Count2/5

A single tool is too few for a server named 'x.ai Grok MCP Server', which suggests a broader scope for interacting with the Grok API. This minimal toolset feels thin and limits functionality, as it only covers chat completions without obvious support for other potential operations like model listing or configuration.

Completeness2/5

The tool surface is severely incomplete for the inferred domain of an AI chat API. While chat completions are a core function, there are significant gaps such as missing tools for managing models, handling conversations, or performing other API interactions, which could lead to agent failures in broader tasks.

Related MCP Connectors

Appeared in Searches