File size: 6,639 Bytes
f1c4ce2
 
 
 
 
 
 
 
 
 
 
 
 
4945f68
 
 
 
 
 
 
 
24ad809
 
 
 
 
 
 
 
 
 
 
 
 
4945f68
 
 
 
 
 
 
24ad809
 
4945f68
24ad809
 
 
 
 
4945f68
 
 
24ad809
 
 
 
 
 
 
4945f68
 
 
 
 
 
 
24ad809
 
4945f68
 
 
 
 
 
 
 
 
 
 
24ad809
4945f68
 
24ad809
 
4945f68
 
 
 
24ad809
4945f68
 
24ad809
 
4945f68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24ad809
4945f68
24ad809
4945f68
 
24ad809
4945f68
 
 
 
24ad809
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4945f68
 
 
 
 
24ad809
 
 
 
 
 
4945f68
 
 
 
24ad809
 
 
4945f68
 
24ad809
4945f68
24ad809
 
 
 
 
 
 
 
 
 
4945f68
24ad809
 
 
 
4945f68
 
 
 
 
24ad809
4945f68
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
---
license: mit
tags:
  - mcp
  - claude
  - shell
  - ssh
  - windows
  - dotnet
language:
  - en
---

# Shell MCP Server

Terminal access for Claude with two security modes, plus SSH bridge for remote servers.

## Features

- **Local shell** with safe/dangerous command separation
- **SSH Bridge** - GUI app for secure remote server access
- **Lift Pen** - Pause Claude's command execution instantly
- **Sudo support** - Auto-send password for sudo commands (opt-in)
- **Full visibility** - See every command Claude runs in real-time
- **Background processes** - Spawn and manage long-running tasks
- **File operations** - Write files without shell escaping issues

## Quick Start (Pre-built Binaries)

Download from the `release/` folder:
- `shell-mcp.dll` - MCP server for Claude Desktop
- `ssh-bridge.exe` - GUI for SSH connections

No build required - just configure Claude Desktop (see below).

## Components

### 1. Shell MCP (`shell-mcp.dll`)
Local Windows terminal access with configurable command allowlists.

### 2. SSH Bridge (`ssh-bridge.exe`)
WinForms GUI that:
- You authenticate with password (held in memory only)
- Claude sends commands through it
- Real-time output display with syntax highlighting
- **Lift Pen** button to pause Claude instantly
- **Sudo** button to enable auto-password for sudo commands
- **Pin** button to keep window on top
- Right-click context menu: Copy, Copy All, Clear

## Installation

### Option 1: Use Pre-built Binaries
1. Download files from `release/` folder
2. Configure Claude Desktop (see below)

### Option 2: Build from Source

**Prerequisites:**
- .NET 8.0 SDK
- Windows 10/11

```bash
git clone https://github.com/FreeOnlineUser/shell-mcp.git
cd shell-mcp
dotnet restore
dotnet build ShellMcp.csproj -c Release
dotnet build SshBridge.csproj -c Release
```

### Configure Claude Desktop

Edit `%APPDATA%\Claude\claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "shell_safe": {
      "command": "dotnet",
      "args": ["C:\\path\\to\\release\\shell-mcp.dll"],
      "env": {
        "SHELL_MCP_MODE": "safe",
        "SHELL_MCP_START_DIR": "C:\\your\\workspace",
        "SSH_BRIDGE_PATH": "C:\\path\\to\\release\\ssh-bridge.exe"
      }
    },
    "shell_dangerous": {
      "command": "dotnet",
      "args": ["C:\\path\\to\\release\\shell-mcp.dll"],
      "env": {
        "SHELL_MCP_MODE": "dangerous",
        "SHELL_MCP_START_DIR": "C:\\your\\workspace",
        "SSH_BRIDGE_PATH": "C:\\path\\to\\release\\ssh-bridge.exe"
      }
    }
  }
}
```

**Approval settings:**
- `shell_safe` → "Allow always"
- `shell_dangerous` → "Allow once" (asks every time)

## Tools

### Local Shell
| Tool | Description |
|------|-------------|
| `Shell` | Execute a local command with optional timeout |
| `Pwd` | Get current working directory |
| `ShellInfo` | Show mode and list of allowed commands |
| `ShellBatch` | Run multiple commands in sequence |

### SSH Tools
| Tool | Description |
|------|-------------|
| `SshCommand` | Execute command on remote server |
| `SshStatus` | Check if SSH Bridge is connected |
| `SshPrefill` | Pre-fill connection details and optionally auto-connect |
| `SshPenStatus` | Check if user has paused execution (pen lifted) |
| `SshPenDown` | Request to resume execution |
| `SshAbort` | Send Ctrl+C to abort running command |
| `SshIsRunning` | Check if a command is currently executing |
| `SshSetTimeout` | Set timeout for next command (1-3600 seconds) |
| `SshTail` | Get last 50 lines of terminal output |
| `SshKillPort` | Kill process listening on a specific port |
| `SshSpawn` | Start a background process with a trackable name |
| `SshListSpawned` | List all tracked background processes |
| `SshKillSpawned` | Kill a background process by name |
| `SshWriteFile` | Write content to file without shell escaping |
| `SshAppendFile` | Append content to file without shell escaping |

## SSH Bridge Features

### Lift Pen (Pause Claude)
Click **Lift Pen** to immediately pause Claude's command execution. Any running command is aborted, and new commands are blocked until you click again to resume. Perfect for:
- Reviewing what Claude is doing
- Taking manual control temporarily
- Emergency stop

### Sudo Support
Click **Sudo** to enable auto-password entry for sudo commands. When enabled:
- Claude can run `sudo` commands without prompting
- Your password is sent automatically when sudo asks
- Password is only held in memory while connected

### Pin Window
Click **Pin** to keep the SSH Bridge window always on top.

### Interactive Command Blocking
The bridge automatically blocks interactive commands that would break the shell:
- **Editors:** vim, nano, emacs (use `echo` or `SshWriteFile` instead)
- **Pagers:** less, more (use `cat`, `head`, `tail` instead)
- **TUI apps:** htop, top (use `top -b -n 1` or `ps aux`)
- **Databases:** mysql, psql (use `-e` or `-c` flags for queries)
- **Multiplexers:** tmux, screen (not supported)

Each blocked command shows helpful alternatives.

## Security Model

### shell_safe (approve once)
Read-only and build commands:
- `dir`, `ls`, `type`, `cat`, `head`, `tail`, `find`, `grep`, `pwd`, `cd`, `tree`
- `echo`, `date`, `time`, `whoami`, `hostname`
- `git status`, `git log`, `git diff`, `git branch`, `git remote`, `git fetch`, `git show`
- `dotnet build`, `dotnet run`, `dotnet test`, `dotnet restore`
- `npm install`, `npm run`, `npm test`, `npm list`, `npm ci`
- `node --version`, `yarn install`, `yarn build`, `yarn test`

### shell_dangerous (approve each time)
Modifying commands:
- `del`, `rm`, `rmdir`, `move`, `copy`, `mkdir`
- `git push`, `git pull`, `git merge`, `git rebase`, `git reset`, `git commit`, `git add`
- `taskkill`, `shutdown`
- `npm install -g`, `npm uninstall`

### Always blocked
- `format`, `diskpart`, `reg`, `regedit`
- `net user`, `net localgroup`
- `powershell -enc`, `rm -rf /`, `del /s /q c:\`

### SSH Bridge Security
- Password held in memory only - never written to disk
- Lift Pen for instant pause
- Disconnect for instant revoke
- All commands visible in real-time
- Sudo disabled by default

## Output Handling

- Large outputs are automatically truncated (last 150 lines returned to Claude)
- Maximum 500KB per response
- Real-time streaming display in SSH Bridge window
- ANSI escape codes stripped for clean output

## Dependencies

- [ModelContextProtocol](https://www.nuget.org/packages/ModelContextProtocol) - MCP SDK for .NET
- [SSH.NET](https://www.nuget.org/packages/SSH.NET) - SSH client library
- [BouncyCastle](https://www.nuget.org/packages/BouncyCastle.Cryptography) - Cryptography (SSH.NET dependency)

## License

MIT