longwire
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@longwire Start a new Grok session and ask it to write unit tests for the auth module."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
longwire
MCP (Model Context Protocol) server that bridges remote MCP clients (Cursor, Grok Bot, Claude Desktop, etc.) to a locally running Grok Build agent over ACP (Agent Client Protocol) WebSocket.
Remote MCP client --stdio MCP--> longwire --WebSocket ACP--> grok agent serveWhat it is / isn't
Is
A thin MCP↔ACP bridge: create/load sessions, prompt, cancel, status
Runs on your machine next to
grok agent serveSpeaks stdio MCP so any MCP-capable host can drive your local agent
Isn't
Not a hosted Grok cloud sandbox / Grok Bot replacement
Not a web UI (see grok-remote for a Tailscale web UI)
Not a substitute for
grok -pone-shot headless prompts
Related MCP server: workiq-mcp-bridge
Prerequisites
Node.js 20+
Grok CLI installed and authenticated (
curl -fsSL https://x.ai/cli/install.sh | bash)A shared secret for serve auth
Quickstart
1. Start the local agent
grok agent --always-approve serve --bind 127.0.0.1:2419 --secret <token>The agent listens at ws://127.0.0.1:2419/ws. Clients authenticate with:
Authorization: Bearer <token>(preferred), and/or?server-key=<token>query parameter
You can also set GROK_AGENT_SECRET instead of passing --secret.
2. Configure longwire
git clone https://github.com/ssubbotin/longwire.git
cd longwire
npm install
cp .env.example .env
# edit .env — set GROK_AGENT_SECRET to the same <token>Environment variables:
Variable | Default | Notes |
|
|
|
| (required) | Must match agent |
|
| Default cwd for new sessions |
3. Wire into Cursor (mcp.json)
{
"mcpServers": {
"longwire": {
"command": "node",
"args": ["/absolute/path/to/longwire/dist/index.js"],
"env": {
"GROK_AGENT_WS_URL": "ws://127.0.0.1:2419",
"GROK_AGENT_SECRET": "<token>",
"GROK_AGENT_CWD": "/absolute/path/to/your/project"
}
}
}
}Build first with npm run build (or use npx tsx src/index.ts for development).
4. Typical tool flow
grok_status— confirm connectedgrok_session_create— getsessionIdgrok_prompt— send work; wait for aggregated text + tool-call summarygrok_cancel— abort an in-flight turn (session/cancelnotification)grok_session_load— resume an existing session id
MCP tools
Tool | ACP method | Description |
|
| Create session; returns |
|
| Load/resume session |
|
| Wait for turn completion; return text + tool summary; optional |
|
| Cancel in-flight turn (notification) |
| (local) |
|
Reaching your laptop from cloud bots
MCP hosts that run in the cloud cannot see 127.0.0.1 on your laptop. Expose the agent (or longwire) through a private tunnel:
Option | Idea | Notes |
Tailscale | Put laptop + bot on a tailnet; point | Prefer bind to Tailscale IP or use subnet routing; keep |
SSH tunnel |
| Simple; requires SSH access |
ngrok / similar | TCP or HTTP tunnel to | Treat the public URL as hostile — rotate secrets, restrict CIDRs if possible |
Security
Never commit
.envor real secrets.Prefer private networks (Tailscale) over public ingress.
The serve secret is a bearer token: anyone who has it can drive the agent (tools, filesystem under the agent cwd).
Keep
grok agent serveon127.0.0.1unless you intentionally expose it; use--always-approveonly when you trust the clients.longwire itself speaks MCP over stdio to the local host process — protect that host the same way you protect any developer machine agent.
Development
npm install
npm test
npm run typecheck
npm run build
npm start # stdio MCP server (expects env set)CI definition: ci/github-actions.yml (typecheck + test + build on Node 20/22).
See docs/CI.md to enable GitHub Actions (requires workflow OAuth scope to place the file under .github/workflows/).
Protocol notes
Transport: WebSocket + ACP JSON-RPC (agentclientprotocol.com)
Auth scheme verified against
xai-org/grok-buildserver.rs: Bearer header orserver-keyquery param on/ws
Roadmap
Optional permission proxy for non-
--always-approvesessions (session/request_permission)Streaming MCP notifications for mid-turn
session/updatechunksAuto-reconnect +
session/resumeafter WS dropsnpm package publish +
npx longwireMulti-agent / multi-cwd profiles
License
MIT — see LICENSE.
Available Tools
5 toolsgrok_cancelA
Cancel an in-flight prompt turn via ACP session/cancel notification. The corresponding grok_prompt call should then finish with stopReason cancelled.
Inputs: sessionId (required).
grok_promptA
Send a user prompt (session/prompt), wait for turn completion, and return aggregated agent text plus a tool-call summary. Optional includeThoughts.
Inputs: text (required), sessionId (required), includeThoughts.
grok_session_createA
Create a new ACP session on the local Grok Build agent (session/new). Returns sessionId.
Inputs: cwd, yoloMode.
grok_session_loadA
Load/resume an existing ACP session (session/load).
Inputs: sessionId (required), cwd.
grok_statusA
Return connection status: connected?, initialized, sessionIds, lastError, wsUrl.
Inputs: no named parameters.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 5 tools
Each tool has a clearly distinct role: create or load a session, send a prompt, cancel an in-flight prompt, or check connection status. There is no meaningful overlap between any two tools.
All tools share the consistent grok_ prefix and use snake_case, which makes them recognizable as a family. Minor inconsistency exists because some names use verb-object order (session_create, session_load) while others are single verbs or nouns (prompt, cancel, status).
Five tools is well-scoped for a focused Grok Build ACP client. Each tool covers a necessary part of the session lifecycle and interaction flow without redundancy or bloat.
The tool surface covers the core workflow: session creation/loading, prompting, cancellation, and status checks. A session deletion/close tool is a minor missing piece, but agents can still complete practical workflows without it.
Related MCP Connectors
Talk to your public-facing AI from any MCP client — Claude, ChatGPT, Cursor, Cline, Windsurf.
Connect ChatGPT and Claude to your Mac, Windows or Linux with secure MCP remote access.
Real-time chat for AI agents. Claude Code, Cursor, Cline and Codex join channels over MCP.
Real-time chat hub for AI agents — Claude Code, Cursor, Cline, Codex over MCP or REST.
Related MCP Servers
- FlicenseNot gradedqualityNot gradedmaintenanceBridges STDIO-based MCP clients with SSE-based MCP servers, allowing applications like Claude Desktop to connect to remote MCP servers that use SSE transport.9-
- AlicenseNot gradedqualityDmaintenanceBridges any local agent or LLM to Microsoft Work IQ's remote MCP server for enterprise context grounding, tools, and chat via CLI or local MCP proxy.MIT
- AlicenseAqualityDmaintenanceBridges any MCP client (like Claude Code, Zed, VS Code) to any ACP coding agent, enabling multi-agent orchestration from a single chat interface.24627 npm12Apache 2.0
- AlicenseAqualityDmaintenanceExposes local Grok Build bridge as MCP stdio server, enabling code agents like Claude Code to run Grok models, check status, and manage runs.6MIT