Repository navigation
feat(integrations): add Grok Build CLI harness #2876
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
+2,212
−22
Closed
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
41f3557
feat(integrations): add Grok Build integration and related docs
antonvishal 304c403
fix(integrations): harden Grok ACP lifecycle
antonvishal a3743c2
Merge origin/main into acp+grok-build
antonvishal 88adff8
docs(integrations): list grok-build in the package overview
antonvishal 8b20f74
Merge remote-tracking branch 'upstream/main' into acp+grok-build
antonvishal ef54737
Merge remote-tracking branch 'upstream/main' into acp+grok-build
antonvishal 6219756
fix(integrations): address ACP review feedback
antonvishal 7744b73
Merge origin/main into ACP and Grok Build integration
antonvishal 46a63e6
feat(integrations): add Grok Build harness
antonvishal 5430351
fix(evals): use trusted Grok MCP config scope
antonvishal 8908144
fix(evals): preserve Grok tool results and browser evidence
antonvishal 1237840
fix(evals): recheck Grok task constraints before final answers
antonvishal ee547cd
Merge branch 'browserbase:main' into grok-build
antonvishal 03efa4a
Merge remote-tracking branch 'upstream/main' into grok-build
antonvishal 7ec8129
fix(integrations): handle Grok stop reasons and process failures
antonvishal 1528069
Merge remote-tracking branch 'upstream/main' into vishal/resolve-oct0…
antonvishal db1b52d
Merge upstream/main and align Grok Build with the shared eval contract.
antonvishal b03e756
Enhance Grok Build integration with always-approve configuration
antonvishal de1b771
fix CI
antonvishal 215a91a
fix(release): drain aborted registry probes before the 503 assertion
antonvishal beead32
Revert "fix(release): drain aborted registry probes before the 503 as…
antonvishal 58464db
Merge commit '7abca76d25cbc378ac363c246dd2fa9423492643' into HEAD
antonvishal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
117 changes: 117 additions & 0 deletions
117
packages/docs/v4/integrations/cli-agents/grok-build.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| --- | ||
| title: "Grok Build" | ||
| description: "Give Grok Build persistent Stagehand browser tools over MCP/stdio." | ||
| --- | ||
|
|
||
| The Grok Build integration connects the Grok CLI to the Stagehand facade MCP server over MCP/stdio. One server process owns the browser, so page state survives across `run`, `snapshot`, and `screenshot` calls. | ||
|
|
||
| <Note> | ||
| Stagehand ships this experimental integration from the repository rather than publishing it as a standalone adapter. | ||
| </Note> | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - Node.js 24 or newer | ||
| - pnpm 11.10.0 | ||
| - The Grok Build CLI and either `XAI_API_KEY` or an existing `grok login` | ||
| - A current Google Chrome installation for local browser mode | ||
|
|
||
| ## Quickstart | ||
|
|
||
| <Steps> | ||
| <Step title="Clone and build Stagehand"> | ||
| ```bash | ||
| git clone https://github.com/browserbase/stagehand.git | ||
| cd stagehand | ||
| pnpm install --frozen-lockfile | ||
| pnpm exec turbo run build \ | ||
| --filter @browserbasehq/stagehand-integrations | ||
| ``` | ||
| </Step> | ||
| <Step title="Install and authenticate Grok Build"> | ||
| ```bash | ||
| npm install --global @xai-official/grok | ||
| grok login | ||
| # or: export XAI_API_KEY="your-xai-api-key" | ||
| ``` | ||
| </Step> | ||
| <Step title="Configure the Stagehand MCP server"> | ||
| Copy `packages/integrations/grok-build/.grok/config.toml` into the project where Grok will run, then replace the facade path and browser credentials. Grok merges project MCP configuration over its user settings: | ||
|
|
||
| ```toml | ||
| [mcp_servers.stagehand] | ||
| command = "node" | ||
| args = [ | ||
| "/absolute/path/to/stagehand/packages/integrations/core/dist/facade/stdio-server.mjs", | ||
| "--max-screenshot-base64-bytes=60000", | ||
| ] | ||
| startup_timeout_sec = 60 | ||
| tool_timeout_sec = 300 | ||
|
|
||
| [mcp_servers.stagehand.env] | ||
| STAGEHAND_BROWSER = "browserbase" | ||
| BROWSERBASE_API_KEY = "bb_live_..." | ||
| ``` | ||
|
|
||
| Start Grok from that project so it loads `.grok/config.toml` and the included `AGENTS.md`. | ||
| </Step> | ||
| <Step title="Choose the browser"> | ||
| The example defaults to Browserbase when `BROWSERBASE_API_KEY` is set in the MCP server env. For local Chrome: | ||
|
|
||
| ```toml | ||
| [mcp_servers.stagehand.env] | ||
| STAGEHAND_BROWSER = "local" | ||
| ``` | ||
| </Step> | ||
| <Step title="Run a browser task"> | ||
| ```bash | ||
| cd packages/integrations/grok-build | ||
| grok | ||
| ``` | ||
|
|
||
| At the prompt, enter: | ||
|
|
||
| ```text | ||
| Use the Stagehand browser tools to open https://example.com, take a snapshot, | ||
| and report the heading with its snapshot ID. | ||
| ``` | ||
| </Step> | ||
| </Steps> | ||
|
|
||
| ## Configuration | ||
|
|
||
| | Variable | Purpose | | ||
| | --- | --- | | ||
| | `XAI_API_KEY` | Credential for the Grok CLI. Grok does not need to forward it to the MCP child. | | ||
| | `STAGEHAND_BROWSER` | Select `local` or `browserbase`. | | ||
| | `BROWSERBASE_API_KEY` | Required for Browserbase. | | ||
| | `BROWSERBASE_PROJECT_ID` | Optional Browserbase project ID. | | ||
| | `STAGEHAND_MODEL_NAME` | Optional model for Stagehand AI methods called inside `run`. | | ||
| | `STAGEHAND_MODEL_API_KEY` | Required with `STAGEHAND_MODEL_NAME`; the MCP child does not receive Grok credentials. | | ||
|
|
||
| Put Stagehand and Browserbase values in `[mcp_servers.stagehand.env]`. Grok does not expand shell variables in config values; paste the real keys or generate this file from your environment. | ||
|
|
||
| ## Keep the browser session alive | ||
|
|
||
| The package mounts one facade MCP server for the Grok session and raises MCP startup and tool timeouts because browser launches exceed the defaults. Preserve that lifetime if you adapt the integration; a new process per tool call starts a new browser. | ||
|
|
||
| The MCP child receives only Stagehand and Browserbase configuration plus the process values required to launch Node. The host's model credential remains in the Grok process. | ||
|
|
||
| ## Headless one-shot runs | ||
|
|
||
| Interactive sessions can approve tool calls when prompted. A `-p` run cannot accept approval responses, so tasks that require approval may fail. Pass `--always-approve` only when you want Grok to run tools without asking: | ||
|
|
||
| ```bash | ||
| cd packages/integrations/grok-build | ||
| grok \ | ||
| --always-approve \ | ||
| -p "Open https://example.com, snapshot it, and report the heading." | ||
| ``` | ||
|
|
||
| <Warning> | ||
| `run` executes model-authored JavaScript in the browser. Use Browserbase for untrusted tasks and review the [integration security boundary](/v4/integrations/cli-agents/overview#security-boundary). | ||
| </Warning> | ||
|
|
||
| <Card title="Grok Build integration source" icon="github" href="https://github.com/browserbase/stagehand/tree/main/packages/integrations/grok-build"> | ||
| Read the CLI configuration, MCP mount, and Stagehand tool guidance. | ||
| </Card> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this blocks the mirror pr @filip-michalsky @antonvishal. closing this one, please reopen without touching .github workflows, we will include this in the mirror pr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created the new PR: #3120