返回市场
ht-MCP

ht-MCP

作者:memextech192 星标更新:2025-11-10

项目介绍

ht-mcp

Rust License: Apache 2.0

这是一个高性能的Rust实现的模型上下文协议(MCP)服务器,用于无头终端ht

特性

  • 🚀 纯Rust: 单一可执行文件的MCP服务器,无需外部依赖
  • 🔗 直接集成: 嵌入优秀的ht无头终端库以获得最佳性能
  • 🖥️ 多会话: 并发终端会话管理
  • 🌐 Web界面: 可选实时终端预览

演示

ht-mcp在Memex

ht-mcp在Memex

ht-mcp在Claude Code

ht-mcp在Claude Code

安装

🍺 Homebrew(推荐)

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/

🦀 Cargo

# 从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

MCP工具

工具描述参数
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客户端中配置好:

  1. 创建会话: ht_create_session → 返回会话ID
  2. 运行命令: ht_execute_command 使用会话ID和命令
  3. 交互式输入: ht_send_keys 进行多步骤交互
  4. 检查状态: ht_take_snapshot 查看当前终端
  5. 清理: 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$

要求

  • Rust: 1.75+(通过rustup安装)
  • 支持的操作系统: Linux, macOS, Windows(实验性)

开发

# 克隆子模块
git clone --recursive https://github.com/memextech/ht-mcp.git
cd ht-mcp

# 构建
cargo build

# 运行
cargo run

# 测试
cargo test

故障排除

安装问题:

  • 确保已安装Rust 1.75+
  • 检查互联网连接以获取git子模块
  • 验证~/.cargo/bin是否在PATH中

运行问题:

  • 使用ht-mcp --debug进行详细日志记录
  • 检查MCP客户端配置语法
  • 验证二进制路径:which ht-mcp

性能

与原始TypeScript实现相比:

  • 启动速度快40倍(约50毫秒对约2秒)
  • 内存减少70%(约15MB对约50MB)
  • 单一可执行文件(4.7MB对约200MB Node.js)
  • 零子进程开销

许可

Apache 2.0许可

版权所有 © 2025 Atlas Futures Inc.

详情参见LICENSE

贡献

欢迎贡献!请阅读CONTRIBUTING.md了解指南。


Memex构建✨

固定子模块提交引用