home / mcp / xai mcp server

xAI MCP Server

Provides access to Grok image generation, chat, image analysis, live web search, and video generation via MCP for Claude Code.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "joemccann-xai-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "github:joemccann/xai-mcp-server"
      ],
      "env": {
        "XAI_API_KEY": "xai-your-api-key-here"
      }
    }
  }
}

You can run an MCP server that connects Claude Code to xAI's Grok APIs, allowing you to generate images, chat with Grok models, analyze images, perform live web searches, and create videos directly from natural language prompts. This guide shows you how to install, configure, and use the server with your Claude Code session so you can access xAI capabilities inside your workflow.

How to use

To use the MCP server, install it on your machine using one of the supported methods, then configure Claude Code to talk to the local or remote MCP endpoint. Once configured, you can issue natural language prompts to generate images, chat with Grok models, analyze images, perform live searches, and generate videos without leaving Claude Code.

How to install

Choose one of the following installation methods and follow the exact commands.

Additional setup and notes

Configure Claude Code to access the MCP server by adding an MCP server entry in your Claude Code settings. You will need your xAI API key and the appropriate command and arguments for your chosen installation method. After adding the MCP server, restart Claude Code to load the new configuration. Use the available tools by issuing natural language prompts in Claude Code.

Troubleshooting

If you encounter issues connecting to the MCP server, verify that the MCP process is running, the API key is correct, and Claude Code is restarted after changes. Check that the MCP entry in Claude Code is using the correct command and arguments, and ensure the environment variable XAI_API_KEY is set correctly.

Tools and capabilities

The MCP server exposes the following tools to Claude Code: generate_image to create images using Grok Imagine, chat to converse with Grok models, analyze_image to describe and interpret images, live_search to perform real-time web searches, and generate_video to produce videos from text prompts.

Available tools

generate_image

Generate images from text prompts using Grok Imagine.

chat

Interact with Grok language models to generate responses.

analyze_image

Analyze and describe the content of images.

live_search

Perform real-time web, news, and social searches.

generate_video

Create videos from textual descriptions.