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.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。