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

mcp-grok2api

v0.1.4

Published

MCP server for Grok2API with chat, image, edit, video, and model listing tools

Readme

mcp-grok2api

MCP server untuk Grok2API.

Apa ini?

mcp-grok2api adalah wrapper MCP yang memanggil endpoint dari server backend grok2api.

Backend yang dipakai:

  • Repo server: https://github.com/sodikinnaa/grok2api

Penting:

  • server grok2api harus sudah berjalan dulu
  • mcp-grok2api tidak berguna kalau backend grok2api belum aktif
  • MCP ini bukan pengganti backend; MCP ini hanya client / wrapper

Fitur

Tool yang tersedia:

  • chat_completion
  • generate_image
  • edit_image
  • generate_video
  • list_models

Catatan untuk video:

  • backend grok2api mendukung field OpenAI-style seperti size, seconds, quality
  • backend juga punya field native yang lebih presisi seperti aspect_ratio, video_length, resolution_name, dan preset
  • untuk hasil video yang benar-benar mengikuti target backend, lebih aman pakai field native tersebut

CLI helper yang tersedia:

  • mcp-grok2api status
  • mcp-grok2api config set api-key <value>
  • mcp-grok2api config set base-url <value>
  • mcp-grok2api test-chat --model <model> --message "..."
  • mcp-grok2api test-image --model <model> --prompt "..."
  • mcp-grok2api test-video --model <model> --prompt "..." --size <resolution>

Stack

  • Bun
  • TypeScript
  • @modelcontextprotocol/sdk
  • zod

Setup lokal

Urutan dasar:

# 1. Jalankan server grok2api terlebih dahulu
# 2. Baru jalankan MCP ini
cp .env.example .env
# isi GROK2API_API_KEY bila server membutuhkan bearer auth
bun install
bun run build
bun run start

Environment

  • GROK2API_BASE_URL default: http://127.0.0.1:8000
  • GROK2API_API_KEY optional
  • GROK2API_TIMEOUT_MS default: 120000

Pastikan GROK2API_BASE_URL mengarah ke server grok2api yang benar-benar sedang aktif.

CLI command

Set config

node dist/cli.js config set api-key sk-xxxxx
node dist/cli.js config set base-url http://127.0.0.1:8000

Kalau binary mcp-grok2api sudah ada di PATH:

mcp-grok2api config set api-key sk-xxxxx
mcp-grok2api config set base-url http://127.0.0.1:8000

Cek status

node dist/cli.js status

atau:

mcp-grok2api status

Test chat model

Untuk argumen --message, selalu bungkus prompt dengan tanda petik agar spasi terbaca sebagai satu pesan.

node dist/cli.js test-chat --model grok-4 --message "Halo"
node dist/cli.js test-chat --model grok-4 --message "berikan joke lucu"
node dist/cli.js test-chat --model grok-4 --message "Halo" --raw

Test image model

Untuk argumen --prompt, selalu bungkus prompt dengan tanda petik.

node dist/cli.js test-image --model grok-imagine-1.0 --prompt "seekor kucing lucu"
node dist/cli.js test-image --model grok-imagine-1.0-fast --prompt "robot di kota cyberpunk" --raw

Test video model

Untuk argumen --prompt, selalu bungkus prompt dengan tanda petik.

node dist/cli.js test-video --model grok-imagine-1.0-video --prompt "seekor kucing berjalan di taman" --size "720x1280" --aspect-ratio "9:16" --resolution-name "720p"
node dist/cli.js test-video --model grok-imagine-1.0-video --prompt "mobil futuristik di jalan neon" --size "1280x720" --aspect-ratio "16:9" --resolution-name "480p" --raw

Kalau binary global sudah tersedia:

mcp-grok2api test-chat --model grok-4 --message "Halo"
mcp-grok2api test-chat --model grok-4 --message "berikan joke lucu"
mcp-grok2api test-chat --model grok-4 --message "Halo" --raw
mcp-grok2api test-image --model grok-imagine-1.0 --prompt "seekor kucing lucu"
mcp-grok2api test-video --model grok-imagine-1.0-video --prompt "seekor kucing berjalan di taman" --size "720x1280" --aspect-ratio "9:16" --resolution-name "720p"

Default output dibuat human-readable. Gunakan --raw jika ingin melihat JSON mentah. Setiap command test juga menampilkan full access URL endpoint yang sedang dipakai.

Install dari npm

Jika package sudah terpublish ke npm:

npm install -g mcp-grok2api
# atau
bun add -g mcp-grok2api

Lalu set config:

mcp-grok2api config set api-key sk-xxxxx
mcp-grok2api config set base-url http://127.0.0.1:8000

Claude Desktop / MCP client

Gunakan command berikut untuk menjalankan server MCP:

{
  "mcpServers": {
    "grok2api": {
      "command": "bun",
      "args": ["run", "/home/gemari-pc/Documents/agents/projects/mcp-grok2api/src/index.ts"],
      "cwd": "/home/gemari-pc/Documents/agents/projects/mcp-grok2api"
    }
  }
}

Endpoint yang dipakai

  • chat_completion/v1/chat/completions
  • generate_image/v1/images/generations
  • edit_image/v1/images/edits
  • generate_video/v1/videos
  • list_models/v1/models

Catatan

  • semua logging server MCP dikirim ke stderr agar aman untuk stdio MCP
  • output CLI dibuat human-readable
  • backend grok2api harus aktif lebih dulu sebelum MCP dipakai