mcpField
R
Remote Session Mcp

Remote Session Mcp

Local
github.com/kayoch1nCloud & Infra0Updated 35w ago

About Remote Session Mcp

Remote Session Mcp is an MCP server for AI assistants managing remote hosts through persistent SSH sessions. It preserves shell state between commands and reads connection settings from SSH config.

Key features

  1. 01Create and manage persistent SSH sessions
  2. 02Preserve directory and environment state
  3. 03Read hosts from ~/.ssh/config
  4. 04Upload and download remote files

Use cases

  1. 01Deploy applications through sequential remote commands
  2. 02Debug servers with stateful shell commands
  3. 03Manage and transfer remote files

MCP support

It exposes tools to MCP clients for listing hosts, managing sessions, executing commands, and transferring files.

Configuration

Local server config is the same for every client. Copy it into your client’s MCP config file.

No install method listed yet

We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.

Repository

Tools

No tool list yet

Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.

Details

From the project README

Remote Session MCP Server

A Model Context Protocol (MCP) server that enables AI assistants to manage persistent SSH sessions and execute commands on remote servers.

Key Advantages

Persistent Sessions with State

Unlike SSH tools that execute single commands in isolation, this server uses invoke_shell() to maintain interactive shell sessions where state persists across multiple commands:

CapabilityPersistent SessionsSingle-Command
Working directory (cd)PersistsLost after each command
Environment variables (export)PersistsLost after each command
Multi-step workflowsNatural flowRequires manual context passing
AI context awarenessTracks pwd automaticallyNo state tracking

Typical workflow:

create → execute("cd /app") → execute("export ENV=prod") → execute("./deploy.sh") → close

This is ideal for AI-driven deployment, debugging, and server management tasks where commands build on each other.

Automatic SSH Config Integration
  • Parses ~/.ssh/config automatically for connection parameters
  • Supports key-based authentication, custom ports, jump hosts, and all standard SSH options
  • No need to hardcode credentials or connection details

Installation

# Using uv (recommended)
uv pip install -e .

# Or using pip
pip install -e .

Usage

1. Configure SSH

Ensure your servers are configured in ~/.ssh/config:

Host production
    HostName 192.168.1.100
    User deploy
    IdentityFile ~/.ssh/id_rsa
2. Run the MCP Server
remote-session-mcp
# Or: python -m remote_session_mcp
3. Claude Code Integration

Create .claude/settings.json or mcp.json in your project:

{
  "mcpServers": {
    "remote-session": {
      "command": "uv",
      "args": ["run", "remote-session-mcp"],
      "cwd": "/path/to/sshmcp"
    }
  }
}
4. Available Tools
ToolDescription
hostsList all hosts from ~/.ssh/config
createCreate a persistent SSH session
executeExecute a command (state persists)
closeClose a session
sessionsList active sessions
uploadUpload a file to remote server
downloadDownload a file from remote server
Example: Deploy an Application
// 1. Create session
{"tool": "create", "arguments": {"host": "production"}}

// 2. Navigate and deploy (state persists)
{"tool": "execute", "arguments": {"session_id": "session_abc", "command": "cd /var/www/myapp"}}
{"tool": "execute", "arguments": {"session_id": "session_abc", "command": "git pull"}}
{"tool": "execute", "arguments": {"session_id": "session_abc", "command": "npm install"}}
{"tool": "execute", "arguments": {"session_id": "session_abc", "command": "sudo systemctl restart myapp"}}

// 3. Close session
{"tool": "close", "arguments": {"session_id": "session_abc"}}

Configuration (Optional)

Create ~/.remote-session/config.json for custom settings:

{
  "enable_raw_output": false,
  "ssh_config_path": "~/.ssh/config"
}
OptionDefaultDescription
enable_raw_outputfalseReturn raw output with only ANSI codes removed
ssh_config_path~/.ssh/configCustom path to SSH config file

Limitations

  • Linux/POSIX Only - Assumes POSIX-compatible shells and commands (pwd, echo $?)
  • Interactive Shell Required - Remote server must support interactive shell sessions
  • Session Timeout - Sessions auto-close after 1 hour of inactivity (configurable)

Comments

Markdown supported

New to MCP?

From what the protocol is to installing your first server, these answers cover most first questions.

An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.