DEV Community

Zw-awa
Zw-awa

Posted on

I Got Tired of Splitting My Brain Between Local AI and Remote SSH, So I Built ssh-session-mcp

I spend a lot of time in environments where the real work does not happen on my laptop.

The code editor is local. The AI assistant is local. But the target machine is often a remote Linux box, a board, a test host, or a GPU server.

That creates a very annoying workflow gap.

My AI assistant can edit files, reason about code, and suggest the exact fix. But the moment the next step involves SSH, I am back to doing manual relay work:

  1. switch to another terminal
  2. connect to the remote host
  3. run the command myself
  4. inspect the output
  5. paste the result back into the AI chat

At that point, the AI is not really participating in the remote workflow. It is just advising from the sidelines.

That is why I built and open sourced ssh-session-mcp.

Main Image

The Problem Is Not "SSH Is Hard"

SSH itself is mature. The real problem is that most AI coding workflows still treat remote terminals as an external, human-only space.

In practice, that causes several recurring issues.

1. Local AI and remote execution live in different worlds

Your model can understand the repository and modify local files, but it cannot naturally step into the remote terminal where the service actually runs.

So even when the AI knows exactly what should happen next, you still become the manual transport layer.

2. A terminal is stateful, but many integrations treat it like stateless RPC

A remote shell is not just "run command, get output."

It may currently be in:

  1. a normal shell prompt
  2. a password prompt
  3. a pager like less
  4. an editor
  5. a long-running command
  6. a streaming session

If the tool does not understand terminal state, it can easily make the wrong move.

3. Human and AI collaboration on the same remote session is awkward

Real development is not fully manual or fully automated.

Usually it looks more like this:

  1. let the AI inspect the environment
  2. take over manually for one or two commands
  3. hand control back to the AI

Without explicit coordination, that turns into input collisions and confusing terminal history.

4. Multi-host work is easy to get wrong

One local repo can map to several remote targets:

  1. board A
  2. board B
  3. a staging VM
  4. a shared Linux server

In those cases, "the command succeeded" is not enough. You also need confidence that it ran on the correct target.

What I Built

ssh-session-mcp is a persistent SSH PTY session manager for MCP clients.

The short version:

  1. it manages a real SSH PTY session
  2. an AI agent can operate it through MCP tools
  3. the user can observe and type into the same session from a browser terminal
  4. both sides share one actual terminal context

This is the key design choice: not parallel lookalike sessions, but one shared PTY.

That matters because state is the whole point. If the user and the AI are not looking at the same terminal state, they are not really collaborating.

Toolbar

What ssh-session-mcp Does Right Now

I have kept the scope intentionally narrow. This project focuses on the SSH transport/runtime layer, not on project-specific business logic.

Current capabilities include:

Shared SSH terminal

The user and the AI share one PTY, so they see the same shell state.

Browser terminal

There is a local browser-based terminal for observation and manual takeover.

Input locking

You can switch between common, user, and claude/codex modes to avoid input conflicts.

Safe vs full mode

Safe mode blocks obviously dangerous commands, interactive programs, and commands that do not naturally terminate.

Intelligent command completion

ssh-run does not rely on a naive fixed timeout. It combines prompt detection, idle timeout, and sentinel markers.

Async command tracking

Long-running commands can automatically transition to async mode and be polled later.

Diagnostics and line-based history

I did not want this to become a black box, so the project includes session diagnostics and line-numbered history recall.

Multi-device profiles

You can manage multiple targets and named connections through configuration instead of constantly rewriting host/user settings.

The Workflow I Wanted

This is the kind of loop I wanted AI tools to support cleanly:

ssh-quick-connect -> ssh-run -> inspect output -> decide -> ssh-run
Enter fullscreen mode Exit fullscreen mode

Home

If the command is long-running:

ssh-run({ command: "apt update" })
-> async commandId

ssh-command-status({ commandId: "..." })
Enter fullscreen mode Exit fullscreen mode

And if I want to intervene manually, I should be able to type into the same terminal without rebuilding the whole session from scratch.

That sounds simple, but it changes the experience a lot. The remote environment stops being a blind spot in the AI workflow.

Why I Did Not Build "Yet Another AI Platform"

I think infrastructure projects get messy when they try to absorb too much.

So I keep ssh-session-mcp focused on:

  1. sessions
  2. viewers
  3. targeting
  4. locks
  5. logging
  6. tool contracts

I am explicitly not trying to bake in:

  1. ROS workflows
  2. board-specific business logic
  3. domain prompts
  4. training pipelines
  5. project orchestration logic

Those things belong outside this repo.

I would rather have a small, reliable runtime layer than a bloated project that mixes transport, policy, and product-specific automation.

Who This Is For

I think this project is most useful if you work in one of these setups:

  1. embedded or board development
  2. remote Linux development
  3. GPU or VM-based development environments
  4. AI-assisted workflows where manual takeover still matters

If all your work happens locally, this may not be very interesting.

But if you keep feeling the gap between "AI can edit my code" and "I still have to manually drive the remote machine," then this is exactly the gap I am trying to close.

Quick Start

Install it:

npm install -g ssh-session-mcp
Enter fullscreen mode Exit fullscreen mode

Or build from source:

git clone https://github.com/Zw-awa/ssh-session-mcp.git
cd ssh-session-mcp
npm install
npm run build
Enter fullscreen mode Exit fullscreen mode

Then configure .env or ssh-session-mcp.config.json, launch the runtime, and register it as an MCP server for your AI client.

Final Thought

I do not think the future of AI-assisted development is "the model does everything."

I think the more realistic future is this:

the model and the developer share better infrastructure.

For remote development, that means SSH can no longer remain a manual side channel outside the workflow.

That is what ssh-session-mcp is trying to fix.

Repo:

https://github.com/Zw-awa/ssh-session-mcp

If you work on remote machines and have strong opinions about shared terminals, safety modes, session targeting, or human/AI handoff, I would genuinely like to hear them.

Top comments (0)