MCP Remote Code

MCP Remote Code

Enables agent-style remote development over SSH with file operations and command execution, exposing native tools for searching, editing, and transferring files on remote machines.

Category
访问服务器

README

🌐 MCP Remote Code

🌏 中文

MCP Remote Code is a standalone Model Context Protocol server for working with remote machines over SSH. Its main focus is agent-style remote development, not only remote server administration.

The core tools are the ones coding agents normally rely on when working in a local repository:

  • remote_glob
  • remote_grep
  • remote_read
  • remote_write
  • remote_edit
  • remote_patch

Many existing SSH MCP servers expose a remote shell, and sometimes file download/upload helpers. That is useful for operations work, but it forces agents to manipulate source files through ad-hoc shell pipelines. MCP Remote Code instead exposes native agent-style file tools, modeled after OpenCode's built-in glob, grep, read, write, edit, and patch tools, so editing a remote project feels much closer to editing a local one.

The remote host stays clean: it only needs an SSH daemon. The MCP server runs locally, maintains persistent SSH/SFTP connections with ssh2, and exposes remote operations as namespaced MCP tools.

💡 Motivation

The primary motivation is the same as the original OpenCode remote plugin: some important development machines are old, locked down, or specialized enough that installing an agent runtime is not realistic.

This is common on remote VMs, lab machines, EDA workstations, embedded Linux targets, and legacy servers. They may not have a modern Node.js, may not permit long-running agent processes, and may not be suitable for extra language server or indexing daemons. Agents still need stable ways to run commands, search code, inspect files, edit files, apply patches, and move artifacts.

The OpenCode plugin proved the remote-development workflow, but it is bound to the OpenCode ecosystem and deliberately masquerades the remote machine as the agent's local workspace. In that model, the runtime environment is fully remote: the agent cannot naturally see or use local directories.

The MCP server has two different goals:

  • detach the SSH remote-development tools from a single client ecosystem; and
  • support workflows where local and remote work need to cooperate.

For example, an analog IC engineer might keep design notes locally, query local gm/ID lookup tables, and iterate sizing scripts on the local workstation, while asking the agent to run Spectre verification and simulation iterations on a remote EDA machine. A pure "remote shell only" MCP server is too low-level for that workflow, and a fully remote-masquerading plugin cannot naturally use the local workspace. This project is designed for that middle ground.

✨ Features

  • Multi-machine connection manager.
  • Saved machine templates in ~/.opencode/mcp-remote-code-configs.json.
  • On-demand SSH connections with remote_connect.
  • Startup auto-connect from CLI flags or environment variables.
  • Persistent SSH command and SFTP connection pools.
  • Remote command execution, glob, grep, read, write, edit, and patch tools.
  • Explicit absolute-path file transfer tools:
    • remote_pull: remote file/directory to local absolute path.
    • remote_push: local file/directory to remote absolute path.
  • Large-transfer preflight warnings with second-call force confirmation.
  • Streamable HTTP transport for current MCP clients.
  • Legacy HTTP+SSE compatibility for older MCP clients.

📋 Requirements

  • Node.js >= 20.
  • A reachable SSH server on each remote machine.
  • A POSIX-like remote shell for file tools.

The remote machine does not need Node.js, MCP software, an agent, rsync, or sshpass.

🚀 Install

From a checkout:

npm install
npm run build
npm install -g .

When installed globally, the command is:

mcp-remote-code

▶️ Start The Server

Default local daemon:

mcp-remote-code

Custom bind address:

mcp-remote-code --port 3000 --host 127.0.0.1

Security note: this server has no built-in authentication. Keep the default 127.0.0.1 binding unless you place it behind your own trusted network boundary. Do not expose it directly to the internet.

🔌 MCP Endpoints

Endpoint Purpose
http://127.0.0.1:3000/sse Compatible endpoint. Accepts Streamable HTTP POST/GET/DELETE and legacy SSE GET.
http://127.0.0.1:3000/mcp Streamable HTTP endpoint for current MCP clients.
http://127.0.0.1:3000/message Legacy HTTP+SSE message endpoint.
http://127.0.0.1:3000/health Health and status JSON.

Most MCP clients can use:

{
  "mcpServers": {
    "remote-code": {
      "url": "http://127.0.0.1:3000/sse"
    }
  }
}

🖥️ Machine Configs

Saved machine templates live at:

~/.opencode/mcp-remote-code-configs.json

Add a machine from an MCP client:

remote_add_config(
  name: "dev",
  ssh: "ssh -oHostKeyAlgorithms=+ssh-rsa user@host",
  workdir: "/home/project",
  password: "optional-password"
)

Connect later:

remote_connect(machine: "dev")

Passwords in saved templates are stored in the local JSON config file. Use file-system permissions appropriate for your machine.

⚡ Startup Auto-Connect

You can connect a machine as the daemon starts. Startup connections are not saved as templates.

mcp-remote-code \
  --remote "ssh -i ~/.ssh/id_rsa user@host" \
  --workdir /home/project \
  --name dev

Environment variable form:

export REMOTE_SSH='ssh user@host'
export REMOTE_WORKDIR='/home/project'
export REMOTE_NAME='dev'
mcp-remote-code

Supported startup variables:

Variable Meaning
REMOTE_SSH SSH command string.
REMOTE_WORKDIR Remote working directory.
REMOTE_NAME Connection name, default default.
REMOTE_PASSWORD SSH password.
REMOTE_SUDO_PASSWORD Password used for sudo commands.

🔑 SSH Command Support

The SSH command string must start with ssh. Common OpenSSH-style options are parsed:

  • -p <port> or -p<port>
  • -i <identity_file> or -i<identity_file>
  • -l <user> or -l<user>
  • -o Key=Value

Recognized -o values include:

  • Port
  • User
  • IdentityFile
  • HostKeyAlgorithms
  • StrictHostKeyChecking=no

This server does not spawn the external ssh binary. Advanced OpenSSH client features such as ProxyJump, ProxyCommand, and custom ssh_config files are not implemented by this package.

🧰 Tools

Connection and config tools:

  • remote_add_config
  • remote_remove_config
  • remote_list_configs
  • remote_connect
  • remote_disconnect
  • remote_list_machines

Remote operation tools:

  • remote_bash
  • remote_glob
  • remote_grep
  • remote_read
  • remote_write
  • remote_edit
  • remote_patch
  • remote_pull
  • remote_push

All remote operation tools accept an optional machine parameter. If omitted and exactly one machine is connected, that machine is used.

📦 File Transfer

remote_pull and remote_push require explicit absolute paths. The MCP server does not infer the agent workspace from its own startup directory.

Pull

Download a remote file or directory to a local absolute path:

remote_pull(
  machine: "dev",
  remotePath: "/home/project/logs",
  localPath: "/home/me/project/artifacts/logs"
)

Rules:

  • remotePath must be an absolute remote path.
  • localPath must be an absolute local path.
  • On Windows, use a fully qualified path such as C:\work\project\artifact.bin or a UNC path, not \artifact.bin.
  • Directories are copied recursively and preserve their internal tree.
  • Binary files are supported.
  • Same-path local files are overwritten.
  • Extra local files are not deleted.

Push

Upload a local file or directory to a remote absolute path:

remote_push(
  machine: "dev",
  localPath: "/home/me/project/artifacts/logs",
  remotePath: "/home/project/logs"
)

Rules:

  • localPath must be an absolute local path.
  • remotePath must be an absolute remote path.
  • Directories are uploaded recursively and preserve their internal tree.
  • Binary files are supported.
  • Symlinks and special local file types are skipped.
  • Same-path remote files are overwritten.
  • Extra remote files are not deleted.

Large Transfer Confirmation

Pull and push both use a two-step confirmation for large transfers.

Defaults:

  • Size threshold: 25 MB.
  • File-count threshold: 500 files.
  • Confirmation window: 10 minutes.

The first large-transfer call returns a plan with type, byte size, file count, directory count, and source/destination paths. It does not transfer data, even if force: true is already present. Repeat the same call with force: true within the confirmation window to proceed.

Environment overrides:

Direction Size threshold File threshold
Pull REMOTE_PULL_WARN_BYTES REMOTE_PULL_WARN_FILES
Push REMOTE_PUSH_WARN_BYTES REMOTE_PUSH_WARN_FILES

🛠️ Development

npm install
npm run lint
npm run build
npm pack --dry-run

The npm package includes build/, README.md, and README.zh-CN.md.

🗂️ Repository Layout

This MCP server is a standalone repository. It may live next to, or inside a checkout of, an OpenCode plugin during development, but its .git directory, package metadata, README files, and npm build artifacts are independent.

License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选