{
  "markdown": "# mcp-server-grok-image\n\nAn MCP (Model Context Protocol) server for xAI's Grok image generation API. Built in Rust, exposes image generation and editing as MCP tools.\n\nCommunicates via stdio using JSON-RPC 2.0, like all MCP servers.\n\n## Tools\n\n| Tool | Description |\n|------|-------------|\n| `generate_image` | Generate an image from a text prompt |\n| `edit_image` | Edit an existing image using natural language instructions |\n| `headshot` | Corporate headshot from a source portrait (pad to 3:2 + fixed edit prompt) |\n| `list_styles` | List available image styles for use with `generate_image` |\n\n### generate_image\n\nGenerate an image from a text description.\n\n**Parameters:**\n\n| Name | Type | Required | Description |\n|------|------|----------|-------------|\n| `prompt` | string | yes | Text description of the desired image |\n| `model` | string | no | Model to use (default: `grok-imagine-image-2.0`) |\n| `n` | integer | no | Number of images to generate (1-10, default 1) |\n| `aspect_ratio` | string | no | Aspect ratio: `1:1`, `16:9`, `9:16`, `4:3`, `3:4`, `3:2`, `2:3`, `2:1`, `1:2`, `19.5:9`, `9:19.5`, `20:9`, `9:20`, `21:9`, `5:2`, `auto` |\n| `resolution` | string | no | Output resolution: `1k` (~1024px, default) or `2k` (~2048px) |\n| `quality` | string | no | `low`, `medium`, or `auto` (2.0 only; omitted = `auto`. Auto currently serves `low` for generation) |\n| `response_format` | string | no | Output format: `url` (default, temporary) or `b64_json` |\n| `style` | string | no | Style name to apply (use `list_styles` to see options) |\n\nWhen a style is set, the prompt is wrapped in the style's template. For example, with `style: \"watercolor\"` and `prompt: \"a cat on a roof\"`, the API receives `\"a cat on a roof, as a watercolor painting\"`. Avoid including style language in the prompt itself when using this parameter.\n\nThe response includes the resolved prompt so you can see exactly what was sent to the API.\n\n### edit_image\n\nEdit an existing image using natural language instructions.\n\n**Parameters:**\n\n| Name | Type | Required | Description |\n|------|------|----------|-------------|\n| `image_url` | string | no* | URL, base64 data URI, or local file path of the source image. Mutually exclusive with `images`. |\n| `images` | string[] | no* | Up to 5 source images for multi-image editing. Reference them in the prompt as `<IMAGE_0>`, `<IMAGE_1>`, … |\n| `prompt` | string | yes | Natural language edit instructions |\n| `model` | string | no | Model to use (default: `grok-imagine-image-2.0`) |\n| `n` | integer | no | Number of variations to generate (1-10, default 1) |\n| `aspect_ratio` | string | no | Same set as `generate_image`, including `21:9` and `5:2` |\n| `resolution` | string | no | Output resolution: `1k` (~1024px, default) or `2k` (~2048px) |\n| `quality` | string | no | `low`, `medium`, or `auto` (2.0 only; omitted = `auto`. Auto currently serves `medium` for editing) |\n| `response_format` | string | no | Output format: `url` (default, temporary) or `b64_json` |\n\n\\* Provide either `image_url` or `images`.\n\nNote: The `style` parameter is intentionally not available on `edit_image` -- edit prompts are instructions (e.g. \"remove the background\"), not descriptions, so wrapping them in style templates would produce nonsense.\n\n### headshot\n\n**Expand-only** portrait fix (Gemini pipeline equivalent on Imagine). Does **not** reframe pose, cut out hair, or redesign the person.\n\n1. Resize full source (default 550px wide) — **never crop**\n2. Letterbox with **white** gutters to canvas width (default 780)\n3. Call **`grok-imagine-image-2.0`** at **quality medium**: complete cut-off shoulders if needed; clean solid **white background**; keep face/hair/pose/clothing/logos\n\n**No cutout / no rembg / no transparent alpha** — same job as the original Gemini headshot skill.\n\n**Parameters:**\n\n| Name | Type | Required | Description |\n|------|------|----------|-------------|\n| `image` | string | yes | Local path, http(s) URL, or `data:` URI |\n| `clothing` | string | no | For missing-shoulder fill only |\n| `notes` | string | no | Must-preserve details (glasses, exact logo text, …) |\n| `pronoun` | string | no | `his` / `her` / `their` (default `their`) |\n| `gravity` | string | no | Letterbox gravity (`North` default) |\n| `content_width` | integer | no | Resize width before pad (default `550`) |\n| `canvas_width` | integer | no | Padded width (default `780`) |\n| `resolution` | string | no | `1k` or `2k` (default `2k`) |\n| `output_path` | string | no | Optional final path (also under `save_dir`) |\n| `n` | integer | no | Variations (1–10, default 1) |\n| `quality` | string | no | `low` / `medium` / `auto` (default **`medium`**) |\n| `model` | string | no | Default **`grok-imagine-image-2.0`** |\n\nPadded intermediate: `save_dir/headshot-padded_*.jpg`.\n\n### list_styles\n\nReturns all available image styles with their name, description, and prompt template. No parameters.\n\n### Built-in Styles\n\n| Style | Description |\n|-------|-------------|\n| `watercolor` | Watercolor painting style |\n| `oil-painting` | Oil painting with visible brushstrokes |\n| `pencil-sketch` | Detailed pencil sketch |\n| `pixel-art` | Retro pixel art |\n| `anime` | Anime style illustration |\n| `pop-art` | Bold pop art style |\n| `art-nouveau` | Art nouveau with flowing organic lines |\n| `cinematic` | Cinematic photography with dramatic lighting |\n| `portrait` | Professional portrait photography |\n| `macro` | Extreme macro photography |\n| `aerial` | Aerial drone photography |\n| `studio` | Studio photography on clean background |\n| `noir` | Dark film noir style |\n| `vintage` | Faded vintage photograph |\n\n### Available Models\n\n| Model | Notes |\n|-------|-------|\n| `grok-imagine-image-2.0` (default) | Optional `quality` (`low` / `medium` / `auto`), up to 5 edit references, `21:9` and `5:2`. Auto currently serves `low` for generation and `medium` for editing. |\n| `grok-imagine-image` | 1.0. Still available; no `quality` param. |\n| `grok-imagine-image-quality` | Retires **2026-11-02**. After that the slug is served by `grok-imagine-image-2.0` at `quality: low` ($0.01 less per image than the quality model). |\n\n## Prerequisites\n\n- Rust (edition 2024)\n- An xAI API key from [console.x.ai](https://console.x.ai)\n\n## Setup\n\nCreate the config file:\n\n```bash\nmkdir -p ~/.config/mcp-server-grok-image\n```\n\nCreate `~/.config/mcp-server-grok-image/config.toml`:\n\n```toml\napi_key = \"xai-...\"\n```\n\n### Custom Styles\n\nAdd custom styles to your config file. Custom styles with the same name as a built-in will override it.\n\n```toml\napi_key = \"xai-...\"\n\n[[styles]]\nname = \"my-style\"\ndescription = \"My custom look\"\ntemplate = \"{prompt}, in my custom style\"\n\n[[styles]]\nname = \"watercolor\"\ndescription = \"My watercolor variant\"\ntemplate = \"{prompt}, as a loose expressive watercolor with ink outlines\"\n```\n\nTemplates must contain the `{prompt}` placeholder. Any custom style missing it will be skipped with a warning at startup.\n\n## Build\n\n```bash\ncargo build --release\n```\n\nThis produces `target/release/mcp-server-grok-image`.\n\nFor development:\n\n```bash\ncargo build              # debug build\ncargo run                # run in dev mode\nRUST_LOG=debug cargo run # run with debug logging\n```\n\n## MCP Configuration\n\nAdd to your Claude Desktop config (`~/.config/Claude/claude_desktop_config.json`):\n\n```json\n{\n  \"mcpServers\": {\n    \"grok-image\": {\n      \"command\": \"/path/to/mcp-server-grok-image\"\n    }\n  }\n}\n```\n\n## Project Structure\n\n```\nsrc/\n  main.rs      process entry (stdio MCP)\n  config.rs    TOML / env config\n  styles.rs    built-in + custom styles\n  grok.rs      xAI request/response types\n  params.rs    MCP tool params + validation\n  image_io.rs  data URIs, local files, mime, fetch\n  headshot.rs  letterbox pad + expand prompt\n  server.rs    MCP tools and Grok HTTP\n```\n\n## License\n\nMIT\n",
  "bytes": 7808,
  "sha": "6e2bd960fa92963598b14f1a3dd42f68c90e35a913990f923baeee1a27433ab9",
  "repo_slug": "codechap/mcp-server-grok-image",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/mcp_io_github_codechap_grok_image_0126fc29/readme"
}