这是一个高性能的Rust实现的模型上下文协议(MCP)服务器,用于无头终端ht。
brew tap memextech/tap
brew install ht-mcp
从发布页面下载:
# macOS Intel
curl -L https://github.com/memextech/ht-mcp/releases/latest/download/ht-mcp-x86_64-apple-darwin -o ht-mcp
# macOS Apple Silicon
curl -L https://github.com/memextech/ht-mcp/releases/latest/download/ht-mcp-aarch64-apple-darwin -o ht-mcp
# Linux
curl -L https://github.com/memextech/ht-mcp/releases/latest/download/ht-mcp-x86_64-unknown-linux-gnu -o ht-mcp
# Windows (PowerShell)
curl.exe -L https://github.com/memextech/ht-mcp/releases/latest/download/ht-mcp-x86_64-pc-windows-msvc -o ht-mcp.exe
# 设置可执行权限并安装
chmod +x ht-mcp && sudo mv ht-mcp /usr/local/bin/
# 从crates.io (稳定版)
cargo install ht-mcp
# 从git (最新版)
cargo install --git https://github.com/memextech/ht-mcp
git clone https://github.com/memextech/ht-mcp.git
cd ht-mcp
git submodule update --init --recursive
cargo install --path .
详细安装选项参见docs/INSTALLATION.md。
| 工具 | 描述 | 参数 |
|---|---|---|
ht_create_session | 创建新的终端会话 | command?, enableWebServer? |
ht_send_keys | 向会话发送按键 | sessionId, keys[] |
ht_take_snapshot | 捕获终端状态 | sessionId |
ht_execute_command | 执行命令并获取输出 | sessionId, command |
ht_list_sessions | 列出所有活动会话 | None |
ht_close_session | 关闭终端会话 | sessionId |
注意: 参数使用驼峰命名法(例如,
sessionId,enableWebServer)以兼容MCP。
添加到您的MCP客户端配置中:
{
"mcpServers": {
"ht-mcp": {
"command": "ht-mcp",
"args": ["--debug"]
}
}
}
对于自定义安装路径:
{
"mcpServers": {
"ht-mcp": {
"command": "/path/to/ht-mcp",
"args": []
}
}
}
# 启动MCP服务器
ht-mcp
# 启用调试日志
ht-mcp --debug
一旦在您的MCP客户端中配置好:
ht_create_session → 返回会话IDht_execute_command 使用会话ID和命令ht_send_keys 进行多步骤交互ht_take_snapshot 查看当前终端ht_close_session 结束时关闭此服务器返回人类可读的文本响应(非JSON),设计用于自然语言交互:
# 创建会话响应
HT会话创建成功!
会话ID: abc123-def456-789...
🌐 网络服务器已启用!查看实时终端:http://127.0.0.1:3618
# 终端快照响应
终端快照(会话:abc123...)
bash-3.2$ ls -la
total 16
drwxr-xr-x 4 user staff 128 Jun 13 10:30 .
-rw-r--r-- 1 user staff 45 Jun 13 10:30 file.txt
bash-3.2$
# 克隆子模块
git clone --recursive https://github.com/memextech/ht-mcp.git
cd ht-mcp
# 构建
cargo build
# 运行
cargo run
# 测试
cargo test
安装问题:
~/.cargo/bin是否在PATH中运行问题:
ht-mcp --debug进行详细日志记录which ht-mcp与原始TypeScript实现相比:
Apache 2.0许可
版权所有 © 2025 Atlas Futures Inc.
详情参见LICENSE。
欢迎贡献!请阅读CONTRIBUTING.md了解指南。
由Memex构建✨