grok-mcp
by TuTouPower
README.md
# grok-mcp
把本机 Grok Build 的 `grok-bridge.mjs` 暴露为 **MCP stdio server**,任意支持 MCP 的 code agent(Claude Code / OpenCode / …)可调用。
```
MCP client
│ stdio
▼
grok-mcp
│
▼
grok-bridge.mjs → grok headless
```
**不是** Claude Code 插件本体;不打包 slash commands / hooks。只包 bridge CLI。
## 工具
| Tool | Bridge | 说明 |
|------|--------|------|
| `grok_check` | `check --json` | 就绪探测(node / grok / auth) |
| `grok_run` | `run …` | 主路径;`background` / `write` / `model` / `effort` |
| `grok_runs` | `runs --json` | 列表或指定 run |
| `grok_show` | `show --json` | 状态/结果 |
| `grok_stop` | `stop --json` | 取消 |
| `grok_bridge_path` | — | 解析到的 bridge 路径 |
审阅类任务:`write=false`(默认),需要改文件时再 `write=true`。
## 前置
- Node ≥ 18
- 本机已装 `grok` CLI 并登录(`grok` / bridge `check` 通过)
- 可找到 `grok-bridge.mjs`(见路径解析)
## 安装
```bash
cd ~/karson_ubuntu/grok-mcp
npm install
npm run build
```
## 路径解析(GROK_BRIDGE)
按顺序找 `grok-bridge.mjs`:
1. 环境变量 `GROK_BRIDGE`
2. `~/github_repo/grok-build-plugin-cc/plugins/grok-build/scripts/grok-bridge.mjs`
3. `~/.claude/plugins/cache/xai-grok-build/grok-build/<ver>/scripts/grok-bridge.mjs`(最新 ver)
4. `$CLAUDE_PLUGIN_ROOT/scripts/grok-bridge.mjs`
## 接入 Claude Code
```bash
claude mcp add grok -s user \
-e GROK_BRIDGE=$HOME/github_repo/grok-build-plugin-cc/plugins/grok-build/scripts/grok-bridge.mjs \
-- node $HOME/karson_ubuntu/grok-mcp/dist/index.js
```
- 前台 `grok_run` 默认超时 **15 分钟**(`timeout_ms` 可改)。
- **background=true**:只等 bridge **入队并返回 jobId**(默认最长 60s),不跑满 agent;完成靠 `grok_show` / 报告文件。
- Prompt 经 `--prompt-file` 写在 **tmpdir**(不污染项目 cwd)。
重启 Claude Code 后 `/mcp` 应见 `grok`。工具名形如 `mcp__grok__grok_check`。
## 接入 OpenCode
在 `~/.config/opencode/opencode.json` 的 `mcp` 段增加等价 stdio 配置(command/args/env 同上)。
## multi-model-review
skill 的 Grok 路:**优先** MCP `grok_run`(`background=true`, `write=false`, `model=grok-4.5`);无 MCP 时回退 Bash 调 bridge。
## 开发
```bash
npm run typecheck
npm run build
node dist/index.js # stdio MCP;不要手动交互跑
```
手动验 bridge(不经 MCP):
```bash
node "$GROK_BRIDGE" check --json
```
TDQS
A3.7/5.0
Scored across 6 tools
Disambiguation5/5
Each tool has a clearly distinct purpose: check readiness, run a task, list runs, show status, stop a job, and resolve bridge path. No overlap or ambiguity.
Naming Consistency5/5
All tools follow a consistent 'grok_' prefix with descriptive verb/noun names (check, run, runs, show, stop, bridge_path). No mixing of conventions.
Tool Count5/5
Six tools is ideal for the domain, covering readiness, execution, listing, status, stopping, and configuration. Each tool earns its place without excess.
Completeness5/5
The tool surface covers the full lifecycle of Grok build runs: check (readiness), run (create), runs (list), show (read), stop (delete/stop), plus configuration (bridge_path). No obvious gaps.
Maintenance
ActivityStale
ResponsivenessNo issues