What xshell-agent-bridge does
xshell-agent-bridge links MCP-compatible agents with selected Xshell 8 terminal tabs on Windows. An attached tab reports its visible text and session state through a local bridge, allowing an agent to inspect the current host and propose the next operation. The bridge can send exact text, Enter, or Ctrl+C only after the user approves the action in an Xshell dialog.
It also provides guarded single-file transfers. Downloads use Windows OpenSSH and place data in the local downloads/ directory; uploads take one file from that directory and create a new remote .part file. Transfers support confirmation steps, manual authentication, and SHA-256 verification where applicable.
How it works
The MCP entry point runs over stdio and starts a local Node.js daemon. The daemon and the Xshell Python script exchange requests and status through atomic JSON files under data/ipc/. Each Xshell tab that should be available to an agent must run xshell_agent_bridge.py separately.
Before terminal input is delivered, the script shows the target host, explanation, risk level, expected result, and complete text in a local confirmation window. Rejected requests are not sent. Write requests carry an idempotency key, while queued writes for a tab are serialized so multiple agents do not type concurrently.
For downloads, the user reviews a desktop transfer prompt, authenticates in a separate PowerShell/OpenSSH window, and reviews the completed temporary file before its final rename. Passwords and other credentials remain outside the MCP request and agent process.
Setup and configuration
Use Node.js 20 or newer, Xshell 8, and a Windows OpenSSH client. The project has no npm dependencies, so npm install is not needed. Start the bundled configuration for Codex, Claude Code, or another stdio-capable client, or launch the server directly with:
node C:\absolute\path\src\mcp-stdio.mjs
On first start, the bridge creates config/local.json with a machine-specific authentication token. Keep this file local and do not share it. Set XSHELL_AGENT_ID when audit records should distinguish one calling agent from another.
In each target Xshell tab, run xshell\xshell_agent_bridge.py from Xshell's Tools, Script, Run menu. The daemon must be running and at least one attached tab must be online before terminal operations can proceed. npm run demo:bridge can exercise the local flow without Xshell.
Tools and capabilities
xshell_health checks daemon state and online-session count.
xshell_list_sessions lists attached tabs and their session identifiers.
xshell_read_screen returns the currently visible terminal text.
xshell_send proposes confirmed text input.
xshell_interrupt proposes a confirmed Ctrl+C interrupt.
xshell_wait_for waits for specified text to appear on screen.
sftp_download transfers one remote regular file into downloads/ with confirmation and optional hash checking.
sftp_upload uploads one local download file to a new remote .part path without overwriting an existing file.
sftp_transfer_status reports transfer state, size, hash, and errors.
Limitations and notes
The bridge reads only the currently visible Xshell text area, not a complete scrollback history or an image. Fast or long-running commands can therefore require logs, tail, grep, process checks, port checks, or health endpoints for reliable verification.
Agent requests cannot provide passwords, tokens, passphrases, or similar credentials. The bridge blocks common credential-in-command patterns and refuses input when the terminal shows a credential prompt. Destructive operations such as deletion, database clearing, formatting, package removal, shutdown, and reboot are blocked for Agent-originated requests; the user must type such commands directly in Xshell if genuinely required. Script-interpreter execution patterns, including piping downloaded or generated content into shells, are also rejected.
Only attached tabs are controllable, and their remote permissions remain in force. The daemon listens on 127.0.0.1 rather than exposing an HTTP service. Downloads support one ordinary file at a time, require absolute remote paths, do not overwrite existing local files, and do not automatically retry or remove failed .part files. User approval means input was accepted by Xshell, not that the remote command succeeded; read the resulting screen or wait for a verifiable marker.