New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

grok-code-mcp-server

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grok-code-mcp-server

MCP server for xAI's grok-code-fast-1 model - Expert coding assistant with 256K context

latest
Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
2
-33.33%
Maintainers
1
Weekly downloads
 
Created
Source

Grok Code MCP Server

MCP Model Context Speed License

Expert coding assistant powered by xAI's grok-code-fast-1 model

FeaturesInstallationUsageToolsExamplesAPI

🚀 Features

  • 256K Context Window - Handle massive codebases and multi-file projects
  • 4x Faster - Optimized for speed compared to competing models
  • 1/10th Cost - Economical pricing at $0.20/1M input tokens
  • Native Reasoning - Access to model's reasoning traces in real-time
  • Tool Calling - Native function calling support for complex workflows
  • Production Ready - Battle-tested for real-world coding tasks

📦 Installation

npm install -g grok-code-mcp-server

Option 2: Install from GitHub

npm install -g github:yourusername/grok-code-mcp-server

Option 3: Local Development

git clone https://github.com/yourusername/grok-code-mcp-server.git
cd grok-code-mcp-server
npm install
npm run build
npm link

🔧 Configuration

1. Get your API Key

Get your xAI API key from x.ai/api

2. Configure MCP

Add to your Claude Desktop or compatible MCP client configuration:

Claude Desktop (claude_desktop_config.json)

Windows: %APPDATA%\Claude\claude_desktop_config.json
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Linux: ~/.config/claude/claude_desktop_config.json

{
  "mcpServers": {
    "grok-code": {
      "command": "npx",
      "args": ["-y", "grok-code-mcp-server"],
      "env": {
        "XAI_API_KEY": "your-xai-api-key-here"
      }
    }
  }
}

Alternative: Using .mcp.json in your project

{
  "mcpServers": {
    "grok-code": {
      "command": "npx",
      "args": ["-y", "grok-code-mcp-server"],
      "env": {
        "XAI_API_KEY": "your-xai-api-key-here"
      },
      "timeout": 45000,
      "autoApprove": [
        "grok_generate_code",
        "grok_refactor_code",
        "grok_analyze_code"
      ]
    }
  }
}

3. Environment Variables

VariableDescriptionDefault
XAI_API_KEYYour xAI API key (required)-
XAI_API_URLAPI endpoint URLhttps://api.x.ai/v1/chat/completions
XAI_TIMEOUTRequest timeout in ms30000

🛠️ Available Tools

grok_generate_code

Generate production-ready code with tests and documentation.

Parameters:

  • task (required): Description of code to generate
  • language: Programming language (typescript, python, go, etc.)
  • framework: Framework to use (React, FastAPI, Next.js, etc.)
  • context: Additional context or requirements
  • includeTests: Generate unit tests (default: false)
  • includeComments: Include helpful comments (default: true)
  • style: Coding style preferences

Example:

{
  "tool": "grok_generate_code",
  "arguments": {
    "task": "Create a React hook for managing localStorage",
    "language": "typescript",
    "framework": "React",
    "includeTests": true
  }
}

grok_refactor_code

Refactor existing code for better quality and maintainability.

Parameters:

  • code (required): Code to refactor
  • goal (required): Refactoring goal
  • language: Programming language
  • preserveBehavior: Ensure behavior remains unchanged (default: true)
  • targetPatterns: Design patterns to apply

grok_analyze_code

Analyze code for bugs, performance issues, and quality.

Parameters:

  • code (required): Code to analyze
  • aspects: Areas to analyze (performance, security, maintainability, bugs, style, complexity)
  • language: Programming language

grok_review_pr

Review pull request changes with detailed feedback.

Parameters:

  • diff (required): Git diff to review
  • context: PR description
  • focusAreas: Specific areas to focus on
  • standards: Coding standards to check

grok_explain_code

Explain code functionality with adjustable complexity.

Parameters:

  • code (required): Code to explain
  • targetAudience: Complexity level (beginner, intermediate, expert)
  • focusOn: Specific aspects to focus on

grok_debug_code

Debug code and identify issues with fixes.

Parameters:

  • code (required): Code with bugs
  • error: Error message
  • expectedBehavior: What the code should do
  • language: Programming language

grok_optimize_code

Optimize code for performance or readability.

Parameters:

  • code (required): Code to optimize
  • targetMetric: What to optimize (speed, memory, readability, all)
  • constraints: Constraints to maintain

📚 Examples

Generate a TypeScript Function

// Using with Claude
"Can you use grok to generate a TypeScript function that validates email addresses with comprehensive tests?"

// Direct tool call
{
  "tool": "grok_generate_code",
  "arguments": {
    "task": "Create a function to validate email addresses",
    "language": "typescript",
    "includeTests": true,
    "includeComments": true
  }
}

Refactor Legacy Code

{
  "tool": "grok_refactor_code",
  "arguments": {
    "code": "// your legacy code here",
    "goal": "Convert to modern async/await pattern",
    "language": "javascript",
    "preserveBehavior": true
  }
}

Analyze Code Quality

{
  "tool": "grok_analyze_code",
  "arguments": {
    "code": "// code to analyze",
    "aspects": ["performance", "security", "maintainability"],
    "language": "python"
  }
}

🔌 Integration with Claude

When using with Claude Desktop or Claude.ai, the tools are available directly:

Human: Can you help me create a React component for a todo list using the grok code server?

Keywords

mcp

FAQs

Package last updated on 07 Sep 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts