Grok Image Generation Server
FreeNot checkedEnables AI assistants to generate images via Grok Imagine by automating the web interface through a Chrome extension bridge.
About
Enables AI assistants to generate images via Grok Imagine by automating the web interface through a Chrome extension bridge.
README
An MCP (Model Context Protocol) server that generates images using Grok's Imagine feature through a Chrome extension bridge. This allows AI assistants like Claude to generate images by automating the Grok Imagine interface.
Architecture
This project consists of two main components:
1. MCP Server (src/)
- MCP Server: Exposes a
generate_imagetool via the Model Context Protocol (stdio) - WebSocket Server: Runs on port 3000 to communicate with the Chrome extension
- Image Bridge: Manages request/response flow between MCP and the extension
- Image Storage: Saves generated images to OS temp directory (
{tmpdir}/grok-imagine/)
2. Chrome Extension (extension/)
- Background Script: Connects to the WebSocket server at
ws://localhost:3000with keepalive via Chrome alarms - Content Script: Automates the Grok Imagine interface with localStorage-based aspect ratio control
- Popup UI: Shows connection status and extension information
- Built with React, TypeScript, and TailwindCSS
How It Works
MCP Client (Claude)
↓
MCP Server (stdio)
↓
WebSocket Server (port 3000)
↓
Chrome Extension
↓
grok.com/imagine (automation)
↓
Chrome Extension (captures image)
↓
WebSocket Server
↓
MCP Server (saves to temp dir)
|
MCP Client (receives file paths)
Prerequisites
- Bun v1.3.5 or higher
- Chrome browser
- Grok account (access to grok.com/imagine)
Installation
1. Install MCP Server Dependencies
bun install
2. Install Chrome Extension Dependencies
cd extension
bun install
3. Build the Chrome Extension
cd extension
bun run build
4. Load the Extension in Chrome
- Open Chrome and navigate to
chrome://extensions/ - Enable "Developer mode" (toggle in the top right)
- Click "Load unpacked"
- Select the
extension/builddirectory - The extension should now appear in your extensions list
Usage
Running the MCP Server
For development with hot reload:
bun run dev
For production:
bun run build
bun run build/index.js
Using with Claude Desktop
Add this configuration to your Claude Desktop config file:
MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"grok-imagine": {
"command": "bun",
"args": [
"/absolute/path/to/chrome-extension-mcp/build/index.js"
]
}
}
}
Replace /absolute/path/to/chrome-extension-mcp with the actual path to this project.
Generating Images
Once configured, you can ask Claude to generate images:
Generate an image of a sunset over mountains
The generate_image tool supports the following parameters:
prompt(required): Text description of the image to generateaspectRatio(optional): One of"1:1","3:2","2:3","16:9","9:16"(default:"1:1")imageCount(optional): Number of images to generate,"1"to"4"(default:"1")
Claude will use the generate_image tool, which will:
- Send a request to the Chrome extension via WebSocket
- The extension opens grok.com/imagine in a new tab
- Sets the correct aspect ratio (reloads page if needed)
- Automates entering the prompt and generating the image(s)
- Captures the generated image(s) as base64
- Closes the tab and sends the images back
- The MCP server saves images to the OS temp directory (
{tmpdir}/grok-imagine/) - Returns the file paths to the MCP client
Development
Project Structure
chrome-extension-mcp/
├── src/ # MCP Server source code
│ ├── index.ts # Entry point
│ ├── mcpServer.ts # MCP server with generate_image tool
│ ├── webServer.ts # WebSocket server (port 3000)
│ ├── imageRequestBridge.ts # Request/response management
│ └── imageStorage.ts # Image saving logic (saves to temp dir)
├── extension/ # Chrome Extension
│ ├── src/
│ │ ├── background.ts # Background script (WebSocket client with keepalive)
│ │ ├── contentScript.ts # Grok automation script
│ │ ├── types.ts # Type definitions
│ │ ├── utils.ts # Utility functions
│ │ ├── popup/ # Popup UI (React)
│ │ └── options/ # Options page (React)
│ ├── public/ # Extension assets (manifest, HTML, icons)
│ ├── config/ # Build scripts
│ └── build/ # Built extension (load this in Chrome)
├── build/ # Built MCP server
├── package.json # MCP server dependencies
└── tsconfig.json # TypeScript configuration
Available Scripts
MCP Server (root directory)
bun run dev # Run with hot reload
bun run build # Build for production
bun run lint # Lint code
bun run format # Format code
bun run typecheck # Type check
bun run fix # Lint, format, and type check
Chrome Extension (extension directory)
bun run dev # Development build with watch mode
bun run build # Production build
bun run pack # Package for Chrome Web Store
bun run lint # Lint code
bun run format # Format code
bun run typecheck # Type check
bun run fix # Lint, format, and type check
Configuration
Environment Variables
You can configure the MCP server behavior using environment variables:
IMAGE_REQUEST_TIMEOUT: Timeout for image generation requests in milliseconds (default: 60000)
Extension Settings
The Chrome extension connects to ws://localhost:3000 by default. If you need to change this, modify
extension/src/background.ts.
Troubleshooting
Extension Not Connecting
- Make sure the MCP server is running
- Check that the WebSocket server is listening on port 3000
- Look at the Chrome extension console (background script) for connection errors
- Try disconnecting and reconnecting by reloading the extension
Image Generation Fails
- Ensure you're logged into grok.com in Chrome
- Check that you have access to Grok Imagine
- Look at the console logs in both the MCP server and Chrome extension
- Verify that the content script is properly injecting into grok.com/imagine
MCP Tool Not Appearing in Claude
- Verify the config file path is correct
- Restart Claude Desktop
- Check the path to the built server is absolute
- Look at Claude Desktop logs for errors
License
This project is licensed under the MIT License - see the extension/license file for details.
Tech Stack
- Runtime: Bun
- MCP SDK: @modelcontextprotocol/sdk
- Chrome Extension: Manifest V3
- Frontend: React, TypeScript, TailwindCSS
- Linting: BiomeJS
- Communication: WebSocket (native Bun.serve)
Contributing
Contributions are welcome! Please ensure your code:
- Passes all linting and type checking (
bun run fix) - Follows the existing code style
- Includes appropriate error handling
- Updates documentation as needed
Installing Grok Image Generation Server
This server has no published package — it is built from source. Open the repository and follow its README.
▸ github.com/laruss/grok-imagine-mcp-extensionFAQ
Is Grok Image Generation Server MCP free?
Yes, Grok Image Generation Server MCP is free — one-click install via Unyly at no cost.
Does Grok Image Generation Server need an API key?
No, Grok Image Generation Server runs without API keys or environment variables.
Is Grok Image Generation Server hosted or self-hosted?
Self-hosted: the server runs locally on your machine via the install command above.
How do I install Grok Image Generation Server in Claude Desktop, Claude Code or Cursor?
Open Grok Image Generation Server on unyly.org, pick your client tab (Claude Desktop, Claude Code, Cursor) and press Install — the config is generated automatically, no JSON editing.
Related MCPs
Playwright
Browser automation, scraping, screenshots
by MicrosoftPuppeteer
Browser automation and web scraping.
by modelcontextprotocolopentabs-dev/opentabs
Plugin-based MCP server + Chrome extension that gives AI agents access to web applications through the user's authenticated browser session. 100+ plugins with a
by opentabs-devrobhunter/agentdeals
1,500+ developer infrastructure deals, free tiers, and startup programs across 54 categories. Search deals, compare vendors, plan stacks, and track pricing chan
by robhunterCompare Grok Image Generation Server with
Not sure what to pick?
Find your stack in 60 seconds
Author?
Embed badge for your README
Browse similar
All browse MCPs
