Token导航 LogoToken导航TokenDH.com
Host Terminal MCP logo
开发工具stdio官方级别未说明来源级核验

Host Terminal MCP

MCP Server

一个允许AI助手在本地机器上运行终端命令的服务,具有权限控制和多模式管理功能。

工具数

5

提示词数

0

GitHub Stars

0

资源数

0
PythonClaude命令行工具Claude DesktopClaude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

ankitaa186

提供方

ankitaa186

最后核验

2026/5/17 20:21

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

pip install host-terminal-mcp

详细介绍

主机终端MCP

![PyPI](https://pypi.org/project/host-terminal-mcp/) ![License](https://opensource.org/licenses/Apache-2.0)

主控程序 该服务器允许AI助手在您的机器上运行终端命令,并具有权限控制。专为 克劳德桌面/合作 以及任何MCP兼容客户端。

运作原理

You (in Co-work)                      Your Mac
─────────────────                     ─────────
"run git status"
      │
      ▼
Claude (cloud)
      │  MCP tool call:
      │  execute_command("git status")
      ▼
Claude Desktop (local)
      │  forwards via stdio pipe
      ▼
host-terminal-mcp                     ◄── this project
      │  1. permission check ✅
      │  2. /bin/bash -c "git status"
      ▼
Terminal output flows back up the chain

克劳德桌面生成 host-terminal-mcp 作为子进程,使用MCP协议通过stdin/stdout进行通信。不涉及网络服务器,它是一个本地管道。

协同工作设置

1.安装

uv tool install host-terminal-mcp

或者使用pip:

pip install host-terminal-mcp

2.配置克劳德桌面

将MCP服务器添加到Claude Desktop配置文件中:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json 窗户: %APPDATA%\Claude\claude_desktop_config.json

重要提示: Claude Desktop以最小的PATH运行(/usr/local/bin, /usr/bin, /bin, /usr/sbin, /sbin, /opt/homebrew/bin).如果您安装了 uv tool installpip install --user,二进制文件可能在 ~/.local/bin/ 在Claude Desktop的PATH中。使用 完全绝对路径 以避免“没有这样的文件或目录”错误。

找到您的二进制路径:

which host-terminal-mcp
# Example output: /Users/you/.local/bin/host-terminal-mcp

然后在配置中使用该路径:

{
  "mcpServers": {
    "host-terminal": {
      "command": "/Users/you/.local/bin/host-terminal-mcp"
    }
  }
}

开始于 ask 模式(推荐--在运行未列出的命令之前提示您):

{
  "mcpServers": {
    "host-terminal": {
      "command": "/Users/you/.local/bin/host-terminal-mcp",
      "args": ["--mode", "ask"]
    }
  }
}
提示: 如果全局安装到系统路径(例如。 /usr/local/bin/host-terminal-mcp),你可以使用 "command": "host-terminal-mcp" 没有完整的路径。

3.重新启动克劳德桌面

退出并重新打开Claude Desktop。它将自动生成 host-terminal-mcp 过程。您可以验证它是否正在运行:

ps aux | grep host-terminal-mcp

4.使用它

在Claude.ai中打开一个联合工作会话(或直接使用Claude Desktop),然后问:

  • “列出主目录中的文件”
  • “在~/projects/myapp中显示git状态”
  • “3000端口上运行的是什么?”
  • “运行此项目的测试”

为什么这个工具

带护栏的码头通道。 三种权限模式允许您选择正确的访问级别——只读命令的锁定分配列表、 ask 提示您使用实时审批的模式 MCP激发,或沙盒环境的无限制模式。

教人工智能如何使用终端的技能。 该插件随附 技能 --Claude在运行时阅读的结构化指南。A. 代码库浏览器 技能教授项目导航模式(目录结构、清单检测、依赖关系跟踪)。A. 终端工作流 该技能教授安全shell执行(命令链、错误处理、进程管理)。克劳德不仅获得了访问权限,还获得了专业知识。

权限模式

模式行为安全
allowlist (默认)仅运行预先批准的只读命令最安全
ask提示 用于批准未列出的命令建议高级用户使用
allow_all除被阻止的命令外,所有命令都会运行危险

如何 ask 模式工作

当Claude尝试运行不在允许列表中的命令时,服务器会使用 MCP激发 提示 (人类)直接在克劳德桌面UI中:

┌─────────────────────────────────────────────┐
│ The AI wants to run a command that is not   │
│ in the allow list:                          │
│                                             │
│   npm install                               │
│                                             │
│ Do you approve?                             │
│                                             │
│ [✓] Approve this command?                   │
│ [✓] Add to allowed list permanently?        │
│                                             │
│         [ Cancel ]  [ Submit ]              │
└─────────────────────────────────────────────┘
  • 批准 --运行此会话的命令
  • 永久添加到允许列表 --将命令保存到配置文件中,这样就不会再被询问
  • 取消/拒绝 --命令被阻止

这是一个真正的人在循环中:克劳德不能自己批准命令。

注: 激发需要MCP客户端支持。如果您的客户端不支持它,未列出的命令将被拒绝,并显示一条消息,告诉您将它们添加到配置文件中。

权限检查顺序: 阻塞 (总是赢)> 允许 > 会议已批准 > 模式选择

默认允许的命令

这些命令(及其参数)是开箱即用的:

文件列表和导航: ls, ll, la, pwd, tree, find, locate, which, whereis, file

文件查看: cat, head, tail, less, more, bat, wc

搜索: grep, rg, ag, ack, fzf

Git(只读): git status, git log, git diff, git show, git branch, git remote, git tag, git stash list, git rev-parse, git config --get, git config --list, git blame, git shortlog, git describe

系统信息: uname, hostname, whoami, id, date, uptime, df, du, free, top -l 1, ps

网络(只读): ping -c, curl -I, curl --head, dig, nslookup, host, ifconfig, ip addr, netstat, ss

包管理器(仅供参考): npm list, npm ls, npm view, npm show, npm outdated, pip list, pip show, pip freeze, brew list, brew info, apt list, dpkg -l

开发工具版本: python --version, python3 --version, node --version, npm --version, cargo --version, rustc --version, go version, java --version, javac --version, ruby --version, docker --version

Docker(只读): docker ps, docker images, docker logs

数据处理: jq, yq

其他: man, help, type, stat, md5sum, sha256sum, shasum

始终被阻止的命令

无论权限模式如何,这些都会被阻止:

模式原因
rm -rf /, rm -rf ~, rm -rf *递归删除
mkfs, dd格式化/覆盖磁盘
find ... -exec任意命令执行
:(){叉式炸弹
> /dev/sd*覆盖磁盘设备
chmod -R 777 /, chown -R危险的权限更改
sudo, su, doas特权升级
reboot, shutdown, halt, poweroff系统控制
kill, killall, pkill过程控制
nc -l, nmap网络攻击
*/.ssh/, */.aws/, */.gnupg/敏感凭证访问
/etc/shadow, /etc/passwd系统文件访问
history -c, shred历史记录/凭证擦除

配置

配置文件: ~/.config/host-terminal-mcp/config.yaml

# Generate a default config file
host-terminal-mcp --init-config

添加自定义允许的命令

allowed_commands:
  - pattern: "docker compose logs"
    description: "Docker Compose service logs"
  - pattern: "docker compose ps"
    description: "Docker Compose service status"
  - pattern: "npm install"
    description: "Install npm packages"

  # Use regex for flexible matching
  - pattern: "^kubectl get "
    description: "Kubernetes get resources"
    is_regex: true

其他选项

permission_mode: allowlist          # allowlist | ask | allow_all
timeout_seconds: 300                # Max command execution time
max_output_size: 100000             # Max output chars (truncated beyond this)
shell: /bin/bash                    # Shell to use
allowed_directories:                # Commands restricted to these dirs
  - /Users/me
environment_passthrough:            # Env vars passed to commands
  - PATH
  - HOME
  - USER
  - LANG
  - LC_ALL

HTTP传输

对于需要通过网络调用您的机器的外部服务(例如Docker中的聊天机器人):

# Install with HTTP extras
uv tool install 'host-terminal-mcp[http]'

# Start
host-terminal-mcp --http --port 8099

# Or in background
nohup host-terminal-mcp --http --port 8099 --mode ask > /tmp/host-terminal-mcp.log 2>&1 &

端点

端点方法目的
/healthGET健康检查
/executePOST运行命令
/cdPOST更改工作目录
/cwdGET获取当前目录
/permissionsGET获取权限配置

示例

curl -X POST http://localhost:8099/execute \
  -H "Content-Type: application/json" \
  -d '{"command": "docker compose ps", "working_directory": "/path/to/project"}'

建筑

src/host_terminal_mcp/
├── server.py        ← MCP stdio server, tool handlers, elicitation
├── http_server.py   ← Alternative HTTP/REST transport (FastAPI)
├── config.py        ← Permission rules, allowlist/blocklist, YAML config
└── executor.py      ← Runs commands via asyncio subprocess

暴露于AI的工具:

工具说明
execute_command运行shell命令(主工具)
change_directory更改工作目录
get_current_directory获取当前工作目录
get_permission_status检查当前权限
set_permission_mode更改权限模式

发展

git clone https://github.com/ankitaa186/host-terminal-mcp.git
cd host-terminal-mcp
make install        # Install all deps (venv auto-created)
make test           # Run tests
make lint           # Run linters
make format         # Format code
make run            # Run stdio server (foreground)
make run MODE=ask   # Run in ask mode
make inspect        # Test with MCP Inspector
make help           # Show all targets

来源:Claude Desktop

{
  "mcpServers": {
    "host-terminal": {
      "command": "uv",
      "args": ["run", "--directory", "/path/to/host-terminal-mcp", "host-terminal-mcp"]
    }
  }
}

免责声明

该软件根据AI模型的指示在您的计算机上执行shell命令。AI模型的行为可能不可预测。虽然提供了权限控制(允许列表、阻止列表、人在环审批),但它们是在尽最大努力的基础上提供的 不能保证安全特别是,人工智能模型可能会试图绕过权限控制,例如,通过调用工具API来自我批准命令,或者通过制作绕过允许列表的输入。这 ask 模式取决于MCP客户端正确地向人类呈现批准提示;并非所有客户都这样做,而且这个项目无法控制客户的行为。安装或使用此软件即表示您承认: (1) 您对系统上运行的每个命令负全部责任, (2) 作者和贡献者对因使用而产生的任何损害、数据丢失、安全漏洞或其他损害不承担任何责任, (3) 权限控制是一种尽力保护措施,而不是安全边界,以及 (4) 本软件按“原样”提供,不提供任何形式的保证,如 Apache 2.0许可证在不了解风险的情况下,不要在生产系统或包含敏感数据的系统上运行此工具。

许可证

Apache-2.0--参见 许可证 全文,包括保修免责声明和责任限制。

目录标签

目录标签

PythonClaude命令行工具终端控制本地部署AI助手集成权限管理本地执行

支持客户端

Claude DesktopClaude

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

部署方式(deploymentType,部署类型)

local-only

工具数量(toolCount,工具数)

5

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdiononelocal-only

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP