mcpx
A Model Context Protocol server for complete shell and SSH mastery, enabling command execution, interactive sessions, file transfer, and port forwarding with auditing and policy controls.
README
Relay Shell
A highly reliable, maximally capable Model Context Protocol server for complete shell and SSH mastery.
relay-shell gives an MCP client (Claude, or any MCP-compatible agent) a robust,
auditable interface to operate a Linux host and a fleet of remote hosts over
SSH: one-shot command execution, long-lived interactive PTY sessions, scripted
runs, SFTP transfer, port forwarding, and host-inventory aware connectivity.
It is designed as operator infrastructure tooling for hosts you own and administer. The default operating posture is native, full access (no sandbox), matching the way real administration is performed, paired with the defensive controls a production operator actually needs: an append-only, output-hashed audit trail; a tiered-authority policy layer; secret redaction; strict resource and timeout bounds; and an optional OAuth 2.1 edge.
The architecture, security model, and deployment patterns are modeled on a mature production MCP gateway and on established operational best practices.
Why
Engineers SSH into hosts and run commands from memory, with no structured reasoning trail and no pre-execution review. A well-built MCP relay improves on that baseline: every action is captured with arguments, an output hash, an exit code, and a tier classification; limits and timeouts are enforced centrally; failure paths never crash the transport. The reasoning layer sits inside the loop and can assess blast radius before acting.
Capabilities
Local shell
| Tool | Purpose |
|---|---|
shell_exec |
Run a command. Timeout/output clamps, cwd, env overlay, stdin, exit code. |
shell_script |
Run a multi-line script (bash/sh/python), optional set -euo pipefail. |
shell_spawn |
Start a persistent PTY session (REPLs, TUIs, prompts, long jobs). |
SSH
| Tool | Purpose |
|---|---|
ssh_exec |
Run a command on a remote host (jump host, key/agent, known-hosts policy). |
ssh_spawn |
Interactive remote PTY session. |
ssh_upload / ssh_download |
SFTP transfer (recursive supported). |
ssh_forward |
Local (L), remote (R), or dynamic SOCKS (D) forwarding. |
ssh_forward_list / ssh_forward_close |
Manage active forwards. |
ssh_check |
Connectivity probe across the inventory or a host list. |
ssh_hosts |
Resolved host inventory (~/.ssh/config + inventory file). |
Sessions (local PTY and SSH PTY, unified)
| Tool | Purpose |
|---|---|
session_send |
Send input (optionally with Enter) to a session. |
session_recv |
Read buffered/new output, with a short wait. |
session_resize |
Resize the PTY (cols x rows). |
session_kill |
Signal / terminate a session. |
session_list |
List active sessions with metadata. |
Diagnostics
| Tool | Purpose |
|---|---|
server_info |
Server version, effective limits, policy mode, audit path. |
Full reference: docs/tools.md.
Quickstart
Requires Python 3.12+ (CPython, tested on Ubuntu 24.04).
git clone https://github.com/rmednitzer/relay-shell.git && cd relay-shell
python3 -m venv .venv && . .venv/bin/activate
pip install -e ".[dev]"
# stdio transport (local agent / Claude Desktop / MCP Inspector)
relay-shell
# HTTP transport (streamable-http on 127.0.0.1:8080)
RELAY_SHELL_TRANSPORT=http relay-shell
Register with an MCP client (stdio):
{ "mcpServers": { "relay-shell": { "command": "relay-shell" } } }
Configuration is environment-driven; see .env.example and
docs/deployment.md.
Security posture
relay-shell runs unsandboxed with the privileges of its service account by design
(see docs/adr/0002-no-sandbox-full-access.md):
sandboxing the process would defeat the very capability it exists to provide.
Safety is achieved with compensating controls, not by crippling the tool:
- Audit - every invocation appended as one JSON line with a SHA-256 hash of the output (never the output body), byte length, exit code, request and client id, and the assessed tier. Append-only on disk; rotation-safe handler.
- Tiered authority - every call is classified Tier 0..3
(
docs/adr/0003-tiered-authority.md).RELAY_SHELL_POLICY_MODEselectsopen(default),guarded, orreadonly. - Redaction - audited arguments are scrubbed for tokens, keys, and
Authorizationmaterial. - Bounds - timeout and output caps on every tool; bounded session count and buffers; idle/lifetime reaping.
- Optional OAuth 2.1 - DCR with single-client lockdown, PKCE, file-backed rotating tokens, lazy expiry (HTTP transport).
- Edge - parameterized Caddy config restricts the endpoint to known
CIDRs with security headers and automated TLS (ACME / Let's Encrypt)
installed via
deploy/install-edge.sh; systemd unit applies resource caps.
This server grants real administrative power. Run it only as a scoped service
account, only on hosts you are authorized to administer, behind the network
controls in docs/deployment.md. See
SECURITY.md for the threat model and reporting.
If your use case requires maximum model capability, relay-shell also supports
an explicit privileged posture (root/sudo workflows). Use that only on isolated
administrative hosts with strict network controls and full audit shipping.
Layout
src/relay_shell/ server, config, audit, policy, redaction, sessions,
shelltools, sshpool, inventory, errors, util, auth
deploy/ systemd unit + hardening drop-in, Caddyfile, logrotate, installers
docs/ architecture, tool reference, deployment, ADRs
tests/ unit + integration (in-process SSH server, no network)
Development
ruff check . && ruff format --check .
mypy
pytest
AI contributor guidance
AGENTS.md- repository-wide agent operating contractCLAUDE.md- Claude-focused development and review guidance
License
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。