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

-
security - not tested
A
license - permissive license
-
quality - not tested

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/darkangelpraha/xai-grok-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server