Install 23step and the turn adapter
Grok Bot has no live hook system. This installs
23step,23step-mcp,23step-grokbot-turn, and the trace helper into~/.local/binand~/.local/share/23step. Create a key on the create-key page (or [withruns:read+runs:write](https://app.23step.com/app/account?create=1&scopes=runs%3Aread+runs%3Awrite&name=grok-bot) if also installing 23step Overlay; AI agents should first ask whether the Electron app should be installed and whether to opt in to the live widget progress bar—off by default because it uses extra tokens and slows down turns—then open that URL in the user's desktop browser, appending&progress=1if opted in, and print the link when no~/.config/23step/otel-keyexists yet). The key is read fromSTEP23_KEYor a hidden prompt and saved at~/.config/23step/otel-key(mode 0600, directory 0700). Never print or commit the key. Add--overlayto also install the 23step Overlay Electron desktop app (and--progress-barif opting in to the live widget progress bar). Add--devto targethttps://dev.23step.cominstead of prod. Run it again any time; an existing key file is kept unlessSTEP23_KEYis set.Open in browser pre-filled scopes url='https://app.23step.com/app/account?create=1&scopes=runs%3Awrite&name=grok-bot' if command -v open >/dev/null 2>&1; then open "$url" elif command -v xdg-open >/dev/null 2>&1 && { [ -n "${DISPLAY:-}" ] || [ -n "${WAYLAND_DISPLAY:-}" ]; }; then xdg-open "$url" >/dev/null 2>&1 & elif command -v wslview >/dev/null 2>&1; then wslview "$url" fi printf 'Create your 23step API key: %s\n' "$url"Terminal https://api.23step.com/install.sh --grokbot export STEP23_KEY='st_REPLACE_WITH_YOUR_WRITE_KEY' curl -fsSL https://api.23step.com/install.sh | sh -s -- --grokbot # dev instead of prod: # curl -fsSL https://api.23step.com/install.sh | sh -s -- --grokbot --devConnect Grok Bot to the MCP serverOptional
Put a
runs:readkey inSTEP23_MCP_KEYor~/.config/23step/mcp-key(mode 0600).mcp-remotereads${AUTH_HEADER}from the environment, so the key is not one of its arguments. The header isAuthorization:${AUTH_HEADER}with no space around the colon.Terminal mcp-remote mkdir -p ~/.config/23step printf '%s\n' "$STEP23_MCP_KEY" > ~/.config/23step/mcp-key chmod 700 ~/.config/23step chmod 600 ~/.config/23step/mcp-key # mcp-remote expands ${AUTH_HEADER} from the environment. No space around the # colon, so clients that split args on spaces still pass one header. # (With --dev, replace https://mcp.23step.com/mcp with https://dev.23step.com/mcp.) sh -c 'AUTH_HEADER="Bearer $(cat ~/.config/23step/mcp-key)" exec npx -y mcp-remote@latest https://mcp.23step.com/mcp --transport http-only --header "Authorization:${AUTH_HEADER}"'Capture each turn as it happens
Call
--beginat turn start with the user message verbatim. Do not passsession_id: the adapter reuses the current session if the previous turn ended less than 30 minutes ago, or starts a newgrokbot-<bot>-<date>-<n>session, and writes both the session ID and the openrun_idto~/.local/share/23step/current.json. Call--eventafter each tool call with the call and a short result (never secrets). Call--endbefore the final reply with the reply text to finalize the run.Terminal --begin, --event, --end export PATH="$HOME/.local/bin:$PATH" # Start of turn: pass the user message verbatim. Omit session_id so the adapter # reuses the current session under 30 minutes idle or creates grokbot-<bot>-<date>-<n>, # writing the session and open run_id to ~/.local/share/23step/current.json. 23step-grokbot-turn --begin - <<'JSON' {"prompt":"Check the deploy","model":"grok-4"} JSON # After each tool call, send the call and its short result (never secrets). 23step-grokbot-turn --event - <<'JSON' {"events":[ {"kind":"tool_call","tool":"Shell","id":"c1","input":{"command":"git status"}}, {"kind":"tool_result","tool":"Shell","id":"c1","ok":true,"output":"clean"} ]} JSON # Before the final reply: stops any running recorder for the run, sends the reply, and finalizes. 23step-grokbot-turn --end - <<'JSON' {"status":"completed","events":[ {"kind":"response","text":"The tree is clean."} ]} JSONAttach browser and desktop screenshots
Once Chrome is open on the bot's
DISPLAY, find its live loopback DevTools port (ss -ltnp | grep chrome) and run23step start --join-session --cdp http://127.0.0.1:<port>with--token-file ~/.config/23step/otel-keyin the background.--join-sessionreads~/.local/share/23step/current.jsonand attaches frames directly to the turn's open run instead of creating a second run. Stop it (kill -INTor23step stop) when browser work ends—stopping detaches and drains queued frames while leaving the turn open until--end(and--endalso stops any recorder still running). You can also pass--recordon--beginso--beginstarts the recorder and--endstops it automatically.Terminal 23step start --join-session # Once Chrome is open, find its live DevTools port (e.g. ss -ltnp | grep chrome) # and attach frames to the open run in ~/.local/share/23step/current.json: DISPLAY=:1 23step start --join-session --cdp http://127.0.0.1:9222 \ --token-file ~/.config/23step/otel-key > /tmp/23step.log 2>&1 & RECORDER_PID=$! # Stop when browser or desktop work ends (drains frames without closing the run): kill -INT "$RECORDER_PID" # Or let --begin start the recorder and --end stop it in a single command: # 23step-grokbot-turn --begin --record --cdp http://127.0.0.1:9222 - <<'JSON' ...Replay a finished turnOptional
Fallback when the turn is already finished and live mode did not run. Passing a turn JSON file with no flag replays the whole turn in one shot. Prefer
--begin,--event, and--endwhile the turn is in progress.Terminal no flag # Fallback when the turn is already over. No --begin / --event / --end. 23step-grokbot-turn ~/.cache/23step/turn.json
Run one turn that calls a tool and opens a page, finishing with --end. At app.23step.com/app/runs (or https://dev.23step.com/app/runs with --dev), a single run appears with the prompt, tool calls, browser screenshots, and final reply together. Nothing there? Check that ~/.config/23step/otel-key holds a runs:write key (mode 0600) and ~/.local/bin is on PATH.