grok-web-sdk MCP
Enables AI agents to generate text, images, and videos via Grok's web UI using MCP tools (grok_chat, grok_generate_image, grok_generate_video) without an API key.
README
grok-web-sdk
Drive your own Grok to generate content — text, images, video — from a local AI agent, the command line, HTTP, or Python. It automates the grok.com web UI using your logged-in session, so there's no API key and no per-token cost.
Runs locally by default: patchright drives a real Chrome on your machine (no Docker). A Browserless backend is available for remote/scale use.
flowchart LR
Agent[Local AI agent] -->|MCP| M[grok mcp]
You -->|CLI| C[grok chat / image / video]
M --> B[behaviours]
C --> B
B --> Chrome[local Chrome<br/>your logged-in Grok]
Chrome --> Out[text · images · video → files]
Install
With pipx (recommended — installs a global grok command in its own env):
pipx install grok-web-sdk # once published to PyPI
# …or from a local checkout today:
pipx install ./grok-web-sdk
grok install-browser # only if you don't have Google Chrome
From source (for development):
git clone <this repo> && cd grok-web-sdk
python3 -m venv .venv
.venv/bin/pip install -e ".[dev]"
Sign in once
grok login
A Chrome window opens — log into your Grok account, press Enter. The session
persists in a local profile (~/.grok-web-sdk/profile), so you only do this
once (repeat if it ever expires).
Use it
CLI
grok chat "explain quantum tunneling in one paragraph"
grok image "a red teapot on the moon" --aspect 16:9 --count 4 -o ./out
grok video "a paper plane looping" --res 720p --duration 10s -o ./out
Image/video files are downloaded to ./downloads (or -o <dir>) and the paths
are printed.
MCP (local AI agents) — expose Grok as tools to Claude Desktop, Claude Code, Cline, Cursor, etc.
Claude Desktop (claude_desktop_config.json):
{
"mcpServers": {
"grok": { "command": "/absolute/path/to/.venv/bin/grok", "args": ["mcp"] }
}
}
Claude Code:
claude mcp add grok -- /absolute/path/to/.venv/bin/grok mcp
Tools: grok_chat, grok_generate_image, grok_generate_video — image/video
tools return the saved file paths.
HTTP API
grok serve --port 8000
# POST /chat/messages · POST /imagine/images · POST /imagine/videos · GET /health
Python
from grok_web_sdk import grok_context, send_message, generate_image, generate_video
with grok_context() as ctx: # local backend by default
print(send_message(ctx, "hello").response)
img = generate_image(ctx, "a red teapot", aspect_ratio="1:1", count="4")
print(img.files) # downloaded paths
Capabilities
| Surface | Options |
|---|---|
| Chat | prompt → reply (+ reasoning header) |
| Image | quality Speed/Quality · aspect_ratio 2:3·3:2·1:1·9:16·16:9 · count Auto·4·8·12 |
| Video | resolution 480p·720p · duration 6s·10s · aspect_ratio |
Remote backend (optional)
To run against a Browserless container instead of local Chrome:
from grok_web_sdk import grok_context, BrowserlessConfig
with grok_context(BrowserlessConfig(url="ws://host:3000", token="…")) as ctx:
...
From a datacenter IP you'll also need a residential proxy (proxy= on the
config) — Cloudflare weighs IP reputation separately from browser fingerprint.
Tests
.venv/bin/pip install -e ".[dev]"
.venv/bin/pytest # unit + contract, no browser; live tier auto-skips
GROK_PROFILE_DIR=spike/.profile .venv/bin/pytest -m live # read-only live tier (needs a logged-in profile)
Notes
- Your account, your rules. This automates the web UI with your session; that likely runs against xAI's ToS. Use a dedicated/throwaway account if you're cautious, and keep request rates sane.
- Local-first & private. Everything runs on your machine; the session profile and downloads never leave it.
- Architecture:
core→pages(L1) →behaviours(L2) →api(MCP/HTTP/CLI), enforced by import-linter.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
Neon Database
MCP server for interacting with Neon Management API and databases
E2B
Using MCP to run code via e2b.
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.