Skip to main content
Glama

Remote Demo MCP

本地 MCP 服务器,使用 rsync 将预构建的静态目录部署到远程主机。

功能说明

  • 使用 MCP 配置中固定的 deployUser

  • localDir 的基本名称派生 project

  • localDir 内容上传至:

    • /var/www/html/demo-remote/{user}/{project}/

  • 使用本地 rsync 命令

  • 通过将 rsync 会话附加到 /dev/tty 来支持 OTP/交互式 SSH 流程

  • 失败时,询问是否重试,直到用户取消

Related MCP server: nomad

安装

npm install
npm run build

配置

默认配置文件路径:

  • ~/.config/remote-demo-mcp/config.json

通过以下方式覆盖路径:

  • REMOTE_DEMO_MCP_CONFIG=/abs/path/config.json

示例:

{
  "deployUser": "demo_user-01",
  "publicBaseUrl": "https://example.com",
  "sessionLog": {
    "enabled": false,
    "path": "/tmp/remote-demo-mcp-session.log",
    "logInputValue": false
  },
  "ssh": {
    "host": "xxx.xxx.xxx.xxx",
    "port": 2222,
    "username": "alice123#ec2-user#52.76.147.44",
    "interactiveAuth": true,
    "password": "",
    "hostKeyPolicy": "accept-new",
    "autoFillPassword": true
  },
  "rsyncOptions": ["-az", "--delete"]
}

服务器通过添加以下参数自动启用断点续传:

  • --partial

  • --checksum

  • --progress(除非 rsyncOptions 已包含 --progress--info=...

兼容性说明:

  • 交互式会话模式使用 node-pty。如果您在 macOS/Linux 上看到 posix_spawnp failed,通常是因为 node-pty 辅助程序(.../node-pty/prebuilds/*/spawn-helper)没有可执行权限。本服务器现在会在会话启动时检查并自动修复辅助程序的执行权限。

远程目标基础路径是硬编码的,无法覆盖:

  • /var/www/html/demo-remote

工具

deploy_static

关键词:

  • EN: deploy to remote, deploy demo, publish demo, upload static site

  • 中文: 部署到远程, 部署demo, 部署 demo, 发布demo, 上传静态网页

user 规则:

  • deployUser 是远程路径的应用用户 ID,而非 SSH username

  • 允许字符:A-Z a-z 0-9 _ -

  • 不允许:., .., 空格, /, \ 以及其他特殊字符

输入:

{
  "localDir": "/abs/path/to/dist",
  "clientCwd": "/abs/path/on-mcp-client",
  "dryRun": false
}

localDir 路径解析:

  • 绝对路径:直接使用

  • 相对路径:如果提供了 clientCwd,则相对于 clientCwd 解析

  • 相对路径回退:如果设置了 CODEX_START_DIR 则使用该路径,否则使用 process.cwd()(服务器启动目录)

项目名称解析:

  • 如果提供了 clientCwd,项目名称使用 clientCwd 的最后一段路径

  • 否则,项目名称使用已解析 localDir 的最后一段路径

行为说明:

  • 如果 ssh.interactiveAuth=truedryRun=falsedeploy_static 将按设计快速失败。

  • 对于 OTP/密码交互式部署,请使用:

    1. start_deploy_session

    2. poll_deploy_session

    3. nextAction=submit_input 时调用 submit_deploy_input

  • 主机密钥确认 (yes/no) 和密码提示在会话模式下会自动处理。

  • OTP 仍需手动操作:当 nextAction=submit_input 时调用 submit_deploy_input

输出 (structuredContent):

{
  "ok": true,
  "attempts": 1,
  "user": "alice",
  "project": "my-site",
  "remotePath": "/var/www/html/demo-remote/alice/my-site/",
  "publicUrl": "https://example.com/alice/my-site/index.html",
  "message": "Deploy succeeded after 1 attempt(s)."
}

verify_deploy

输入:

{
  "url": "https://example.com/alice/my-site/index.html",
  "timeoutMs": 8000
}

交互式 OTP 会话工具

当在非 TTY 主机中部署期间必须输入 OTP/密码时,请使用这些工具:

  1. start_deploy_session

  2. poll_deploy_session(读取输出和进度;如果 state=waiting_input,则提交代码)

  3. submit_deploy_input(发送 OTP/密码)

  4. 重复第 2 步,直到 statesucceededfailed

  5. 可选的 cancel_deploy_session

poll_deploy_session 通过 cursor 支持增量输出,并返回 nextCursor

会话工具返回 nextAction 以使编排具有确定性:

  • submit_input: 调用 submit_deploy_input

  • poll: 调用 poll_deploy_session

  • done: 工作流结束 (succeeded / failed / cancelled)

会话日志:

  • 在 MCP 配置文件中的 sessionLog 下配置。

  • sessionLog.enabled 默认为 false

  • sessionLog.path 默认为 /tmp/remote-demo-mcp-session.log

  • sessionLog.logInputValue 默认为 false(仅记录输入长度)。

  • 交互式会话工具在 PTY 中运行 rsync,因此可以通过 poll_deploy_session 检测到密码/OTP 提示。

SSH 主机密钥策略:

  • accept-new(默认):首次使用的主机密钥自动接受;已更改的密钥被拒绝。

  • strict: 从不自动接受未知主机密钥。

  • insecure: 禁用主机密钥验证(高风险;仅供临时/调试使用)。

Codex CLI 交互流程:

  1. 调用 start_deploy_session

  2. 循环调用 poll_deploy_session

  3. 如果 needsInput=truenextAction=submit_input,使用 OTP/密码调用 submit_deploy_input。向用户显示的提示为 "Please Enter MFA Code." 或 "Please Enter Password."

  4. 继续轮询直到 nextAction=done

代理协议契约(适用于 Codex 等 MCP 客户端):

  1. 调用一次 start_deploy_session

  2. 从响应中读取 nextAction

  3. 如果 nextAction=submit_input,调用 submit_deploy_input

  4. 如果 nextAction=poll,调用 poll_deploy_session

  5. 重复步骤 2-4 直到 nextAction=done

  6. 切勿在 OTP 流程中调用 deploy_static;仅使用会话工具。

  7. 轮询时,持续将传输进度从 output 中继给最终用户。

输出 (structuredContent):

{
  "ok": true,
  "url": "https://example.com/alice/my-site/index.html",
  "status": 200,
  "statusText": "OK",
  "responseTimeMs": 123,
  "message": "URL is reachable: HTTP 200 in 123ms"
}

运行

npm run dev
# or
npm run build && npm start

初始化配置文件:

remote-demo-mcp init

它会创建:

  • ~/.config/remote-demo-mcp/config.json

  • 交互模式显示每个当前字段值以供编辑。

  • 不输入内容直接按回车键可保持当前值不变。

  • 如果配置已存在,init 会询问是否修改,并在覆盖前要求最终确认。

codex 使用

安裝 npm 包

npm install -g    @jake.e-com365/remote-demo-mcp

codex 添加 mcp

codex mcp add remote-demo-mcp remote-demo-mcp  

remote-demo-mcp 的配置

remote-demo-mcp init
vi ~/.config/remote-demo-mcp/config.json
{
  "deployUser": "jake",
  "publicBaseUrl": "https://demo-remote.e-com365.com/",
  "ssh": {
    "host": "xxx.xxx.xxx.xxx",
    "username": "alice123#ec2-user#18.140.183.126",
    "interactiveAuth": true,
    "port": 2222,
    "password": "xxx",
    "hostKeyPolicy": "accept-new",
    "autoFillPassword": true
  },
  "rsyncOptions": ["-az", "--delete"]
}

Related MCP Connectors

Related MCP Servers

  • A
    license
    B
    quality
    B
    maintenance
    A local MCP server for agentic remote development that enables code sync via rsync, SSH command execution, and long-running task management in remote tmux sessions.
    15
    2
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    SSH-based MCP server that enables remote execution of SSH commands, file transfers, and secure server management via the MCP protocol.
    ISC