grok-build-mcp
v0.1.1
Published
MCP server that wraps the xAI Grok CLI. Exposes grok_chat / grok_review / grok_consult / grok_challenge tools to any MCP-compatible host (Claude Code, Cursor, Cline, OpenClaw, ...).
Maintainers
Readme
grok-build-mcp
把 xAI 的 Grok Build CLI 包成 MCP server,讓 Claude Code、Cursor、Cline、OpenClaw 等 MCP host 都能直接調用 Grok 來做 code review、對抗測試、第二意見諮詢。
English: README.md
提供什麼
四個 tool,全部 stateless:
| Tool | 用途 |
|------|------|
| grok_chat | 一次性問答 |
| grok_review | 給 diff(或自動 git diff main...HEAD),回結構化 code review |
| grok_consult | 多輪對話,caller 自己重送 history |
| grok_challenge | 對抗模式:請 Grok 找 bug、race condition、security hole |
前置需求
- Node.js ≥ 18
- 已安裝並登入 Grok CLI:
curl -fsSL https://x.ai/cli/install.sh | bash grok # 第一次跑會處理登入
安裝
npm install -g grok-build-mcp
# 或直接 npx 不裝
npx grok-build-mcp串到 MCP host
Claude Code
claude mcp add grok npx -- grok-build-mcp或直接編輯 ~/.claude.json:
{
"mcpServers": {
"grok": {
"command": "npx",
"args": ["-y", "grok-build-mcp"]
}
}
}Cursor
.cursor/mcp.json(專案)或 ~/.cursor/mcp.json(全域):
{
"mcpServers": {
"grok": {
"command": "npx",
"args": ["-y", "grok-build-mcp"]
}
}
}Cline (VS Code)
Settings → Cline → MCP Servers:
{
"grok": {
"command": "npx",
"args": ["-y", "grok-build-mcp"]
}
}其他 MCP host
grok-build-mcp 跑標準 stdio MCP。任何 client 指向 npx -y grok-build-mcp 即可。
Tool 用法
grok_chat
{ "prompt": "兩句話解釋 consistent hashing。" }可選 model 覆寫預設 Grok model。
grok_review
{ "base_ref": "main", "focus": "security" }沒給 diff 就跑 git diff <base_ref>...HEAD。回傳 markdown 評審,含整體判決、五維度評分(correctness / readability / architecture / security / performance)、具體修正建議。
grok_consult
{
"messages": [
{ "role": "system", "content": "你是資深後端工程師。" },
{ "role": "user", "content": "這個 query 怎麼 cache?" },
{ "role": "assistant", "content": "兩個方案..." },
{ "role": "user", "content": "方案 2 的 failure mode 是什麼?" }
]
}Server 不存 state,caller 每次帶完整 history。一般 MCP host 會自動處理。
grok_challenge
{
"code": "function transfer(from, to, amount) { from.balance -= amount; to.balance += amount; }",
"context": "Node.js,HTTP handler 並發呼叫"
}回傳 severity 分級的問題(Critical / High / Medium / Low),含重現步驟與修補建議。
設定
| 環境變數 | 預設值 | 用途 |
|---------|--------|------|
| GROK_MCP_BIN | grok | grok binary 路徑 |
| GROK_MCP_TIMEOUT | 120000 | 單次 call timeout(毫秒) |
認證與預設 model 在 Grok CLI 自己的 ~/.grok/config.toml。
Roadmap
- v0.1(本版):四個 stateless tool、stdio transport
- v0.2:server 端 session 持久化,
grok_consult可帶conversation_id - v0.3:透過 MCP
progressnotification 做 streaming
開發
git clone https://github.com/howardpen9/grok-mcp.git
cd grok-mcp
npm install
npm test
npm run buildLicense
MIT
