跳到正文
所有工具

run_terminal_command

诊断与系统 · macOS · Windows

效果: 执行. 状态: 受限可用.

“受限可用”表示工具可能取决于版本、平台、权限、账户或配置,并不表示它在所有安装中都已启用。

macOS

用途

在用户的 Mac 上运行 shell 命令并返回其输出。始终处于启用状态。当 LMCP 处于只读模式时禁用。有三类命令会被拒绝,因为它们无法撤销:格式化或覆盖磁盘(mkfs、newfs、fdisk、diskutil erase/partition、对磁盘设备的 dd 读写);递归删除系统文件夹、用户的主文件夹或其某个数据文件夹(Documents、Desktop、Downloads、Library、Pictures、Movies、Music)、删除其中直接包含的全部内容,或删除命令文本无法确定的目标或文件夹(变量、命令替换、子 shell 中的 cd);以及 fork 炸弹。以下命令不会被拒绝,但预览和结果会带有说明其作用的警告:指名凭据位置(钥匙串、~/.ssh 私钥、~/.aws、~/.config/gh、浏览器登录信息、其他用户的主目录)、写入之后会运行代码的文件(LaunchAgents、shell 启动文件、AI 客户端的文件夹)、用脚本驱动另一个应用、打开脚本或终端应用、控制系统服务或电源、将下载的脚本通过管道传入 shell、写入设备文件,或递归更改系统路径的权限。确认之前,请告诉用户它将读取或更改什么,除非他们要求的正是这个操作。这些警告只读取命令的文本,因此隐藏路径的命令不会得到任何警告。命令在 macOS 沙盒中运行,该沙盒只保护 Local MCP 本身:终端无法通过路径打开或更改 Local MCP 自己的文件(其设置和令牌、二进制文件、活动日志、消息和网页会话、启动项),无法与其套接字通信,也无法打开用户已关闭其 Read 或 Write 开关的账户的文件。任何设置都无法重新开放这些限制。由于该沙盒,除 ps 和 top 之外的 setuid 系统程序无法启动(sudo、su、crontab、at、traceroute):警告会在命令运行前说明这一点,且 `log` 命令不会运行。在沙盒内,SwiftPM 需要 --disable-sandbox。这是破坏性操作:会先预览命令——传入 confirm:true 才会实际运行。输出和运行时间均有上限。

必填输入

输入名称会严格保持工具要求的形式。下方可展开的架构中保留英文规范技术定义。

权限与确认

架构声明了明确的确认参数。请检查预览,并按此平台的契约授权实际操作。

英文规范技术架构 — macOS
{
  "properties": {
    "command": {
      "description": "The shell command to run (a single command line, executed with /bin/zsh -lc).",
      "type": "string"
    },
    "confirm": {
      "description": "Must be true to actually run. Without it, a preview of the command is returned.",
      "type": "boolean"
    },
    "timeout_seconds": {
      "description": "Max seconds to run before it is terminated (default 20, max 60).",
      "type": "integer"
    },
    "working_dir": {
      "description": "Optional absolute working directory. Defaults to the user's home directory.",
      "type": "string"
    }
  },
  "required": [
    "command"
  ],
  "type": "object"
}

文档示例

run_terminal_command 的文档示例。请勿执行此示例。所示参数属于虚构数据集;在实际调用前,请解析真实标识符并获得授权。

{
  "command": "echo Hello from LMCP",
  "confirm": false
}

Windows

用途

在用户的电脑上运行 shell 命令。一些系统级命令(sudo/提权、递归删除系统或主目录路径、格式化磁盘、关机/重启、将下载的脚本通过管道传入 shell、fork 炸弹)会被拒绝。这是破坏性操作:会先预览命令——传入 confirm:true 才会实际运行。输出和运行时间均有上限。在 Windows 上,命令通过 `cmd /c` 运行;在其他系统上通过 `sh -c` 运行。

必填输入

输入名称会严格保持工具要求的形式。下方可展开的架构中保留英文规范技术定义。

权限与确认

架构声明了明确的确认参数。请检查预览,并按此平台的契约授权实际操作。

英文规范技术架构 — Windows
{
  "properties": {
    "command": {
      "description": "The shell command to run (a single command line).",
      "type": "string"
    },
    "confirm": {
      "description": "Must be true to actually run. Without it, a preview of the command is returned.",
      "type": "boolean"
    },
    "timeout_seconds": {
      "description": "Max seconds to run before it is terminated (default 30, max 60).",
      "type": "integer"
    },
    "working_dir": {
      "description": "Optional absolute working directory. Defaults to the user's home directory.",
      "type": "string"
    }
  },
  "required": [
    "command"
  ],
  "type": "object"
}

文档示例

run_terminal_command 的文档示例。请勿执行此示例。所示参数属于虚构数据集;在实际调用前,请解析真实标识符并获得授权。

{
  "command": "echo Hello from LMCP",
  "confirm": false
}