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., "@longwireStart 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.
| Name | Required | Description | Default |
|---|---|---|---|
| sessionId | Yes | ACP session id whose in-flight turn should be cancelled |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden and does state a concrete behavioral consequence: the corresponding grok_prompt call should finish with stopReason cancelled. It also discloses the notification mechanism. It stops short of describing idempotency or error behavior, but the core side effect is clear.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is two sentences with no filler. The primary action and target are front-loaded, and the second sentence adds the essential expected outcome. Every clause earns its place.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a single-parameter tool with no output schema, the description covers the purpose, the trigger condition, and the resulting state change. It omits edge cases such as canceling when no turn is in-flight or idempotency, but the essential information needed to invoke the tool correctly is present.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema already documents sessionId as 'ACP session id whose in-flight turn should be cancelled' with 100% coverage, so the description adds no new parameter-level meaning. It simply restates the session concept from the schema, which meets the baseline but does not exceed it.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description names a specific verb ('Cancel'), a precise object ('in-flight prompt turn'), and the mechanism ('ACP session/cancel notification'). It clearly differentiates from sibling tools like grok_prompt and grok_session_create by targeting cancellation rather than creation, prompting, or status checks.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description clearly implies when to use it: when a prompt turn is in-flight and should be stopped. It also explains the expected consequence on the corresponding grok_prompt call, which helps an agent reason about timing. It does not explicitly list exclusions, but there is no competing sibling tool for cancellation.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
grok_promptA
Send a user prompt (session/prompt), wait for turn completion, and return aggregated agent text plus a tool-call summary. Optional includeThoughts.
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | User prompt text to send to the agent | |
| sessionId | Yes | ACP session id from grok_session_create / load | |
| includeThoughts | No | When true, include aggregated agent_thought_chunk text |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full behavioral burden. It discloses that the tool waits for turn completion and returns aggregated text plus a tool-call summary, which is useful. However, it does not mention side effects on session state, potential long-running behavior, or how cancellation interacts with this wait, leaving some behavioral ambiguity.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The entire description is one well-structured sentence that front-loads the core action and outcome. Every clause earns its place, and the optional includeThoughts flag is mentioned without unnecessary detail.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the moderate complexity, no output schema, and no annotations, the description covers the essential return values and the wait-for-completion behavior. It could go further by mentioning prerequisites or cancellation, but the parameter schema fills in the sessionId origin, and the core call sequence is clear.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema already provides 100% parameter coverage, describing each parameter clearly, so the baseline is 3. The tool description adds minimal parameter-level meaning beyond referencing includeThoughts and the session context, which is acceptable but not especially enriching.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states a specific verb ('Send'), a clear resource (user prompt/session), and the expected outcome (return aggregated agent text plus a tool-call summary). It is easily distinguished from the sibling tools, which handle session creation, loading, cancellation, or status rather than sending prompts.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description makes it clear this is the tool for sending a prompt and waiting for a completed turn, which implies you must already have a session from grok_session_create/load. It does not explicitly name alternatives or exclusions, but the context is strong enough that an agent is unlikely to confuse it with session management tools.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
grok_session_createA
Create a new ACP session on the local Grok Build agent (session/new). Returns sessionId.
| Name | Required | Description | Default |
|---|---|---|---|
| cwd | No | Working directory for the new ACP session (default: GROK_AGENT_CWD) | |
| yoloMode | No | Always-approve tool permissions for this session (default: true) |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden. It does disclose that the tool creates a session and returns a sessionId, but it does not explain the surprising yoloMode default of true (auto-approve tool permissions) or any downstream effects of session creation. The schema documents the default, but the description adds little beyond the mutation and return value.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
A single sentence that front-loads the verb and purpose, names the endpoint, and states the return value. Every word earns its place with no filler.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a simple 2-parameter tool with a fully documented schema, the description covers the essential call semantics and return value. However, with no output schema and no guidance on session lifecycle relative to grok_session_load, an agent is left to infer when a new session is needed versus loading an existing one.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the baseline is 3. The description adds no parameter-level detail; both cwd and yoloMode are already well-documented in the schema with meanings and defaults. The description neither compensates for gaps nor repeats schema, so baseline applies.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states a specific verb and resource: 'Create a new ACP session on the local Grok Build agent (session/new).' This clearly distinguishes from siblings like grok_session_load, grok_prompt, grok_cancel, and grok_status, and even names the underlying endpoint.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies the use case (creating a fresh session) but gives no explicit guidance on when to use this tool versus grok_session_load for existing sessions, nor any mention of prerequisites. There is clear context but no exclusions or alternatives beyond what the name conveys.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
grok_session_loadA
Load/resume an existing ACP session (session/load).
| Name | Required | Description | Default |
|---|---|---|---|
| cwd | No | Working directory associated with the session | |
| sessionId | Yes | Existing ACP session id to load/resume |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden of behavioral disclosure. It only says 'load/resume' without explaining what that means for the agent's current session state, whether loading has side effects, whether an active session is replaced, or what happens if the sessionId is invalid. This is a significant transparency gap for a state-changing operation.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single short sentence with no filler or redundant content. It front-loads the core action and resource, and the parenthetical protocol reference adds useful context without bloat.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The tool is simple and the schema covers both parameters, but with no annotations and no output schema, the description is the only source of behavioral context. It adequately states the purpose but leaves gaps around when to use it and what loading a session actually entails, so it is minimally viable rather than complete.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the parameters are already fully documented in the input schema. The description adds no extra meaning about sessionId or cwd, but given the high schema coverage, the baseline score of 3 is appropriate and the description does not need to compensate.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states a specific action ('Load/resume') and a specific resource ('an existing ACP session'), making the tool's purpose immediately clear. The word 'existing' differentiates it from the sibling grok_session_create, so an agent can distinguish them without opening the schema.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Usage is only implied through the word 'existing' — an agent can infer this is for resuming prior sessions rather than creating new ones. However, there is no explicit guidance on when to use this tool versus grok_session_create, grok_prompt, grok_cancel, or grok_status, and no prerequisites or exclusions are stated.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
grok_statusA
Return connection status: connected?, initialized, sessionIds, lastError, wsUrl.
| Name | Required | Description | Default |
|---|---|---|---|
No parameters | |||
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the full burden of behavioral disclosure. It does state the returned fields, which implies a read-only health-check operation, but it does not explicitly confirm there are no side effects, whether it refreshes the connection, or what error behavior looks like beyond exposing lastError.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
One compact sentence with a colon-delimited field list. Every word earns its place and the core purpose is front-loaded.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a zero-parameter status tool with no output schema, the description lists the relevant return fields clearly. It leaves some ambiguity about types or structure (e.g., whether sessionIds is an array or whether connected? is a boolean), but it is largely sufficient for a simple status check.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The tool has zero parameters, so the schema already exhaustively documents all inputs. The baseline of 4 applies, and the description does not need to add further parameter semantics.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description uses a specific verb ('Return') and a clear resource ('connection status'), then enumerates the exact fields returned. This makes it immediately distinguishable from the sibling action tools like grok_session_create and grok_prompt.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies that this tool is for checking connection health, especially alongside action-oriented siblings, but it never states when to call it or when to prefer another tool. There is no explicit guidance such as 'use before creating sessions' or 'call this to diagnose errors.'
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
5 tool updates
v0.1.0- First observed
grok_cancel - First observed
grok_prompt - First observed
grok_session_create - First observed
grok_session_load - First observed
grok_status
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.
Maintenance
Related MCP Connectors
- QuallaaOAuthcom.quallaa
Talk to your public-facing AI from any MCP client — Claude, ChatGPT, Cursor, Cline, Windsurf.
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.
Remote MCP server for supportsheep: run AI interviews and manage support content for your blog.
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-
- FlicenseNot 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.-
- AlicenseAqualityDmaintenanceBridges any MCP client (like Claude Code, Zed, VS Code) to any ACP coding agent, enabling multi-agent orchestration from a single chat interface.24109 npm9Apache 2.0
- AlicenseAqualityCmaintenanceExposes local Grok Build bridge as MCP stdio server, enabling code agents like Claude Code to run Grok models, check status, and manage runs.640 npmMIT