npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

grok-code-mcp-server

v1.0.0

Published

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

Readme

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

Option 1: Install from npm (Recommended)

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

| Variable | Description | Default | |----------|-------------|---------| | XAI_API_KEY | Your xAI API key (required) | - | | XAI_API_URL | API endpoint URL | https://api.x.ai/v1/chat/completions | | XAI_TIMEOUT | Request timeout in ms | 30000 |

🛠️ 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?