backwire
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
backwire
Reverse WebSocket bridge for remote terminal and desktop operations.
Embed directly in a FastAPI backend, or run as an authenticated Streamable HTTP / stdio MCP server.
English · 简体中文
Enabling--allow-shell, --allow-write, or --allow-input grants the connected model or caller the corresponding privileges of the current OS account.
Clients start in read-only mode (
read, plusscreenon--kind desktop). Do not enable--allow-shellfor an untrusted model or user.Use a dedicated low-privilege OS account and a long, unique token per device.
Terminate TLS (
wss://) at a trusted reverse proxy on public networks; do not expose barews://./mcprequires a dedicatedBACKWIRE_MCP_TOKENseparate from device tokens and rejects requests when unset.
Overview
backwire connects machines behind a LAN, NAT, or container (without public IPs, inbound ports, or VPN/TUN interfaces) to a hub over an outbound WebSocket. An embedded FastAPI application or an MCP client routes explicitly authorized operations back to each connected device.
flowchart LR
subgraph Devices["Devices (Outbound Only)"]
M["macOS / Windows\n(desktop: screen + input)"]
L["Linux / Container\n(headless: single .py script)"]
end
H["backwire Hub\n/ws/terminal (Per-device Bearer Auth)\nCapability Check · Audit Log · Rate Limit"]
subgraph Callers["Callers (Provider-Neutral)"]
A["FastAPI Backend\nhub.invoke(...)"]
C["Remote / Local MCP Clients\n/mcp (Dedicated MCP Token)"]
end
M -- "Outbound wss://" --> H
L -- "Outbound wss://" --> H
A <--> H
C <--> HTwo integration modes: mount
create_ws_routerinside an existing FastAPI backend (without installingmcp), or runbackwire-server(Streamable HTTP/mcp) orbackwire-mcp(local stdio).Standalone device script: copy
client/backwire_client.pyto any Python 3.9+ machine; headless mode depends only onwebsockets.Access controls & logging: per-device tokens (wildcard
*disabled), capability checks on both hub and client,--workdirpath restriction for file APIs, and redacted JSONL audit logging.
Support for remote Streamable HTTP MCP clients depends on each client's current version and account capabilities. Verify client support before deployment.
Related MCP server: Universal Host Manager MCP
Installation
Install from source:
git clone https://github.com/chuli1122/backwire.git
cd backwire
python3 -m venv .venv
. .venv/bin/activate
# Core package and WebSocket hub (Python 3.10+; no MCP dependency)
pip install -e .
# Core package + optional Streamable HTTP / stdio MCP transport
pip install -e '.[mcp]'
# Optional desktop automation dependencies
pip install -e '.[desktop]'Without
.[mcp](or withbackwire-server --no-mcp),/mcpis not mounted and returns404.Tested with MCP SDK
1.27.0and2.x(MCPServer); if another SDK version changes transport APIs and fails to initialize, check startup logs and pin a tested version.Device client:
client/backwire_client.pyis standalone and supports Python3.9+(websocketsfor headless; pluspyautogui,pillow, andpyperclipfor desktop mode).
Quick Start
Option A: Embed in a FastAPI Backend (No MCP Required)
from fastapi import FastAPI
from backwire import BackwireConfig, BackwireHub, create_ws_router
config = BackwireConfig.with_tokens({
"laptop": "REPLACE_WITH_LONG_RANDOM_DEVICE_TOKEN",
})
hub = BackwireHub(config)
app = FastAPI()
app.include_router(create_ws_router(hub, config))
# Call directly from your application code:
# devices = await hub.list_devices()
# result = await hub.invoke("read_file", {"path": "notes.txt"})
# result = await hub.invoke("run_bash", {"command": "uname -a"}, timeout=65)See examples/embed_fastapi.py for a complete example with application-layer Bearer authentication and explicit target device selection. Application routes calling hub.invoke require their own authentication and must not be exposed unauthenticated.
Option B: Standalone Server + Remote / Local MCP
Device tokens and MCP tokens are configured separately (plaintext or sha256:<64 hex>):
export BACKWIRE_TOKENS_JSON='{"laptop":"REPLACE_WITH_LONG_RANDOM_DEVICE_TOKEN"}'
export BACKWIRE_MCP_TOKEN='REPLACE_WITH_LONG_RANDOM_MCP_TOKEN'
backwire-server --host 127.0.0.1 --port 8000Endpoint | Purpose |
| Minimal health check ( |
| Device reverse-WebSocket endpoint ( |
| Canonical Streamable HTTP MCP URL ( |
MCP tools:
list_devices,run_command(maps to corerun_bash),read_file,write_file,screenshot,mouse_click,keyboard_type,hotkey,scroll.Default device routing: when
deviceis omitted, the hub checksBACKWIRE_DEFAULT_DEVICE, then prefers adesktopdevice ifBACKWIRE_PREFER_DESKTOP_DEFAULT=true, then picks the first connected device. Specifydeviceexplicitly in production.Local stdio MCP:
backwire-mcp --ws-host 127.0.0.1 --ws-port 8765runs a stdio MCP server alongside a WebSocket listener (it does not serve HTTP/mcpor/healthz). Binding--ws-hostto a non-local interface exposes plaintext WebSocket.
Connect a Device Client
Create the working directory first (--workdir validates path boundaries and does not create directories):
mkdir -p "$HOME/backwire-work"
python3 client/backwire_client.py \
--url wss://your-host.example/ws/terminal \
--token 'REPLACE_WITH_LONG_RANDOM_DEVICE_TOKEN' \
--name laptop \
--kind headless \
--workdir "$HOME/backwire-work"Default capabilities & transport: read-only (
read, plusscreenfor--kind desktop). Non-local plaintextws://is rejected by default unless--allow-insecure-wsis passed (which prints a warning). Higher capabilities require--allow-write,--allow-shell, and--allow-input.File & screenshot limits:
--workdirblocks path traversal and symlink escapes forread_fileandwrite_file; if omitted, file APIs can access any path readable by the current OS account.read_filerejects non-regular files, caps each call at 200,000 characters / 512 KiB, and supports byte-offset pagination viaoffset(returningoffset,next_offset,truncated,size_bytes).screenshotreturns in-memory PNG base64 and does not write to disk.Shell & reconnection:
--workdiris not an OS sandbox for shell commands.run_bashusessubprocess.run(..., shell=True)on Windows and prefers/bin/bash(falling back to the default shell) on POSIX, with hard caps on timeout (300 s) and output (200 KiB) plus process-group / process-tree termination. Disconnected clients retry with 1–30 s exponential backoff.
backwire vs. Tailscale + SSH
| Tailscale + SSH | |
Connection direction | Device initiates outbound WebSocket (no inbound ports or TUN) | Operator reaches device over private network |
Model / tool integration | Embedded FastAPI hub and structured MCP tools | Requires separate SSH wrapper / integration |
Desktop screen & input | Optional explicit capabilities ( | Not included in SSH |
Security boundary | Per-device token, capability checks, | Network identity, SSH keys, OS account policy |
Best fit | A controlled application or agent needing a small tool surface | Human administration and general-purpose shell |
Configuration & Deployment Reference
Match both /mcp and /mcp/*, forward Host, and disable response buffering:
location /ws/terminal {
proxy_pass http://127.0.0.1:8000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
}
location ~ ^/mcp(?:/|$) {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffering off;
proxy_cache off;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
}Set
BACKWIRE_MCP_ALLOWED_HOSTS(e.g.mcp.example.com,mcp.example.com:443) on public deployments to enable DNS rebinding protection matching the proxy'sHostheader. When unset, DNS rebinding protection is disabled for reverse-proxy compatibility.Auth-failure rate limiting keys on
client.hostby default and does not parse unverifiedX-Forwarded-Forheaders; trust proxy headers only from a fixed reverse proxy.
Variable | Default / Notes |
|
|
| Per-device tokens (JSON takes priority; plaintext or |
| Dedicated MCP tokens ( |
| Empty (DNS rebinding check off); comma-separated host allowlist |
|
|
|
|
|
|
|
|
| Empty (off); writes redacted JSONL entries (rejects symlink targets) |
| Empty; explicit default device name |
|
|
| Device-client env equivalents ( |
deploy/ contains device-client startup templates only (no server unit or TLS configuration):
systemd (Linux): system-level template; install
deploy/systemd/backwire-client@.serviceto/etc/systemd/system/, create the user's~/.config/backwire/client.env(chmod 600) withBACKWIRE_URL,BACKWIRE_TOKEN,BACKWIRE_NAME,BACKWIRE_WORKDIR, copyclient/backwire_client.pyto~/bin/, then runsudo systemctl daemon-reload && sudo systemctl enable --now backwire-client@<user>.service. Do not use arootinstance orsystemctl --user.launchd (macOS): copy
deploy/launchd/com.backwire.client.plistto~/Library/LaunchAgents/anddeploy/launchd/run_backwire_client.sh(chmod +x) to~/bin/, store credentials in~/.config/backwire/client.env(chmod 600, parsed as key-value pairs rather than sourced), update the wrapper path, and runlaunchctl load.Windows: copy
client/backwire_client.py, set user environment variablesBACKWIRE_URL,BACKWIRE_TOKEN,BACKWIRE_NAME, andBACKWIRE_WORKDIR(never pass tokens in CLI args), then launch viadeploy/windows/run_hidden.vbs.Container: place
client/backwire_client.pyat/opt/backwire/backwire_client.py, inject theBACKWIRE_*environment variables, and rundeploy/container/profile-autostart.sh.
License
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Remote MCP server exposing your Node Command fleet (files, shell, processes, browser) to AI hosts.
Secure and manage MCP servers through the Speakeasy AI Control Plane from your agent.
An authenticated remote MCP server for user-owned devices and one-shot capability invocation.
Streamable HTTP MCP gateway for NV oOS fleets — one API key, namespaced tools, quotas and policy.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceTurns any Linux server into an AI-agent-accessible machine over HTTPS, allowing MCP clients like ChatGPT, Claude, and Grok to securely control files, run shell commands, inspect system state, query SQLite, and work with git behind a bearer token.110 npm5MIT
- AlicenseNot gradedqualityBmaintenanceEnables MCP clients such as ChatGPT and Claude to administer Linux or macOS hosts through authenticated Streamable HTTP, including running shell commands, reading and writing files within a workspace, listing directories, and retrieving system metrics.30 PyPIMIT
- FlicenseNot gradedqualityAmaintenanceEnables web-based AI chat clients to securely operate a local machine through one OAuth-gated MCP endpoint, exposing governed tools for file read/write/edit, whitelisted shell commands, search, Git, SQLite, browser automation, DevTools, background tasks, localhost fetches, clipboard, notifications, ports, and Postman. It lets users build and edit projects, inspect databases and local APIs, drive browser workflows, and manage long-running jobs from a browser or mobile device without granting unrestricted shell access.-
- AlicenseNot gradedqualityCmaintenanceEnables AI clients to reach tools running on any machine or existing MCP server, even behind NAT, using only outbound connections with no open ports, tunnels, or third-party services, while keeping oversized responses out of the model's context and enforcing per-token access policies.AGPL 3.0