npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

mcp-ssh-sessions

v1.0.4

Published

Persistent SSH sessions as MCP tools for Claude Code, Codex, and other AI coding agents

Readme

mcp-ssh-sessions

Persistent SSH sessions as MCP tools for AI coding agents. Connect once, run commands across conversations.

Security Model

  • SSH keys, passwords, and session metadata stay on the local machine running the MCP server.
  • The server opens outbound SSH connections directly to your remote host. It does not proxy credentials through a third-party service.
  • Host key verification is enabled by default using your local OpenSSH configuration and known_hosts files.
  • Passwords are kept in memory only for the current process and are never written to the on-disk session store.

Quick Start

Claude Code

claude mcp add ssh -- npx -y mcp-ssh-sessions

Codex CLI (OpenAI)

codex mcp add ssh -- npx -y mcp-ssh-sessions

That's it. Both tools will auto-install and run the server on demand.

Features

  • Persistent sessions — SSH connections survive across tool calls; reconnectable configs are saved locally to disk
  • Strict host verification — resolves ~/.ssh/config with ssh -G and verifies remote host keys against local known_hosts
  • Two execution modesssh_exec for stateless commands, ssh_shell for stateful shell workflows
  • Stable shell framingssh_shell runs through a non-interactive persistent bash process to avoid prompt and MOTD corruption
  • SFTP file transferssh_upload and ssh_download transfer files over the active SSH session
  • Auto-reconnect — transparently reconnects dropped key-based sessions and live password-based sessions within the same process
  • Dual transport — stdio (default, per-process) or HTTP daemon (shared across terminals)
  • 9 toolsssh_connect, ssh_exec, ssh_shell, ssh_upload, ssh_download, ssh_sessions, ssh_reconnect, ssh_disconnect, ssh_set_default

Manual Configuration

Claude Code

In ~/.claude.json under mcpServers:

{
  "ssh": {
    "type": "stdio",
    "command": "npx",
    "args": ["-y", "mcp-ssh-sessions"]
  }
}

Codex CLI

In ~/.codex/config.toml:

[mcp_servers.ssh]
command = "npx"
args = ["-y", "mcp-ssh-sessions"]

HTTP Daemon Mode (shared sessions)

Run the daemon once so all terminals share the same SSH sessions:

npx mcp-ssh-sessions --http 7722

Then point your MCP client to SSE:

{
  "ssh": {
    "type": "sse",
    "url": "http://127.0.0.1:7722/mcp"
  }
}

Health check: curl http://127.0.0.1:7722/health

Tools

| Tool | Description | |------|-------------| | ssh_connect | Open a named SSH session. Resolves ~/.ssh/config with OpenSSH itself. | | ssh_exec | Run a command (fresh channel, no state). Returns stdout/stderr/exit code. | | ssh_shell | Run a command in a persistent non-interactive bash shell (keeps cwd/env state). | | ssh_upload | Upload a local file to the remote host over SFTP. | | ssh_download | Download a remote file to the local machine over SFTP. | | ssh_sessions | List all sessions (active, disconnected, saved). | | ssh_reconnect | Reconnect a dropped session from saved config. | | ssh_disconnect | Close a session. Pass forget=true to delete saved config. | | ssh_set_default | Set which session is used when no name is given. |

Usage Examples

Once the MCP server is running, your AI agent can use these tools:

ssh_connect(name: "myserver", host: "10.0.0.50")
ssh_exec(command: "docker ps")
ssh_upload(localPath: "./notes.txt", remotePath: "/tmp/notes.txt")
ssh_download(remotePath: "/var/log/syslog", localPath: "./syslog.txt")

# Stateful shell — cwd persists between calls
ssh_shell(command: "cd /var/log")
ssh_shell(command: "tail -20 syslog")

# Use an SSH config alias
ssh_connect(name: "plex", host: "plex")

# List all sessions
ssh_sessions()

Session Persistence

Connection configs are saved to ~/.ssh-mcp-sessions.json. This means:

  • Sessions appear in ssh_sessions even after restart.
  • ssh_reconnect can restore key-based sessions without re-entering credentials.
  • Passwords are never saved to disk.
  • Password-auth reconnect after process restart requires running ssh_connect again.

Testing

npm run check
npm run build

The test suite covers framed shell parsing, known_hosts verification including hashed entries, SSH config resolution, and reconnect decision behavior.

License

MIT