Skip to main content
Glama

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 serve

What it is / isn't

Is

  • A thin MCP↔ACP bridge: create/load sessions, prompt, cancel, status

  • Runs on your machine next to grok agent serve

  • Speaks 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 -p one-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

GROK_AGENT_WS_URL

ws://127.0.0.1:2419

/ws is appended if missing

GROK_AGENT_SECRET

(required)

Must match agent --secret

GROK_AGENT_CWD

.

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

  1. grok_status — confirm connected

  2. grok_session_create — get sessionId

  3. grok_prompt — send work; wait for aggregated text + tool-call summary

  4. grok_cancel — abort an in-flight turn (session/cancel notification)

  5. grok_session_load — resume an existing session id

MCP tools

Tool

ACP method

Description

grok_session_create

session/new

Create session; returns sessionId

grok_session_load

session/load

Load/resume session

grok_prompt

session/prompt

Wait for turn completion; return text + tool summary; optional includeThoughts

grok_cancel

session/cancel

Cancel in-flight turn (notification)

grok_status

(local)

connected, sessionIds, lastError, wsUrl

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 GROK_AGENT_WS_URL at ws://100.x.y.z:2419

Prefer bind to Tailscale IP or use subnet routing; keep --secret strong

SSH tunnel

ssh -N -L 2419:127.0.0.1:2419 user@laptop from the bot host

Simple; requires SSH access

ngrok / similar

TCP or HTTP tunnel to 2419

Treat the public URL as hostile — rotate secrets, restrict CIDRs if possible

Security

  • Never commit .env or 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 serve on 127.0.0.1 unless you intentionally expose it; use --always-approve only 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

Roadmap

  • Optional permission proxy for non---always-approve sessions (session/request_permission)

  • Streaming MCP notifications for mid-turn session/update chunks

  • Auto-reconnect + session/resume after WS drops

  • npm package publish + npx longwire

  • Multi-agent / multi-cwd profiles

License

MIT — see LICENSE.

Available Tools

5 tools
grok_cancelA

Cancel an in-flight prompt turn via ACP session/cancel notification. The corresponding grok_prompt call should then finish with stopReason cancelled.

ParametersJSON Schema
NameRequiredDescriptionDefault
sessionIdYesACP session id whose in-flight turn should be cancelled

TDQS

A4.2/5.0
Behavior4/5

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.

Conciseness5/5

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.

Completeness4/5

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.

Parameters3/5

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.

Purpose5/5

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.

Usage Guidelines4/5

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.

ParametersJSON Schema
NameRequiredDescriptionDefault
textYesUser prompt text to send to the agent
sessionIdYesACP session id from grok_session_create / load
includeThoughtsNoWhen true, include aggregated agent_thought_chunk text

TDQS

A4/5.0
Behavior3/5

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.

Conciseness5/5

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.

Completeness4/5

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.

Parameters3/5

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.

Purpose5/5

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.

Usage Guidelines4/5

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.

ParametersJSON Schema
NameRequiredDescriptionDefault
cwdNoWorking directory for the new ACP session (default: GROK_AGENT_CWD)
yoloModeNoAlways-approve tool permissions for this session (default: true)

TDQS

A3.7/5.0
Behavior3/5

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.

Conciseness5/5

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.

Completeness3/5

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.

Parameters3/5

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.

Purpose5/5

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.

Usage Guidelines3/5

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).

ParametersJSON Schema
NameRequiredDescriptionDefault
cwdNoWorking directory associated with the session
sessionIdYesExisting ACP session id to load/resume

TDQS

A3.5/5.0
Behavior2/5

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.

Conciseness5/5

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.

Completeness3/5

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.

Parameters3/5

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.

Purpose5/5

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.

Usage Guidelines3/5

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.

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

A4/5.0
Behavior3/5

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.

Conciseness5/5

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.

Completeness4/5

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.

Parameters4/5

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.

Purpose5/5

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.

Usage Guidelines3/5

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.

  1. 5 tool updatesv0.1.0
    • First observedgrok_cancel
    • First observedgrok_prompt
    • First observedgrok_session_create
    • First observedgrok_session_load
    • First observedgrok_status

TDQS

A3.9/5.0

Scored across 5 tools

Disambiguation5/5

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.

Naming Consistency4/5

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).

Tool Count5/5

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.

Completeness4/5

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

ActivityMaintained
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    Not graded
    maintenance
    Bridges 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
    -
  • A
    license
    A
    quality
    C
    maintenance
    Exposes local Grok Build bridge as MCP stdio server, enabling code agents like Claude Code to run Grok models, check status, and manage runs.
    6
    40 npm
    MIT