Skip to main content
Glama

MCP隧道

一个简单的 MCP(模型上下文协议)服务器,允许访问虚拟机的命令行。启动后,它还会将主机连接到 Web,以便可以通过 MCP 进行访问。

特征

  • 通过 MCP 在虚拟机上执行 shell 命令

  • 基于 Web 的虚拟机交互终端界面

  • 自动隧道使虚拟机可以从任何地方访问

  • 基于WebSocket的实时通信

Related MCP server: MCP SSH Agent

先决条件

  • Node.js(v18 或更高版本)

安装和使用

使用 npx 运行(无需安装)

npx mcp-cli

全局安装

npm install -g mcp-cli mcp-cli

本地开发

# Clone repository git clone [repository-url] cd mcp-cli # Install dependencies npm install

发展

运行开发服务器,对后端和前端进行热重载:

npm run dev

建筑

构建用于生产的前端和后端:

npm run build-all

用法

  1. 启动 MCP 服务器:

# Start with automatic tunneling npm start # Start without automatic tunneling npm start -- --no-tunnel

这将构建项目并启动服务器。默认情况下,将自动创建隧道。使用--no-tunnel标志可禁用自动隧道。

  1. 服务器将启动并在 stderr 上提供输出(以避免干扰 stdout 上的 MCP 通信)

  2. 使用 MCP 通过以下工具与服务器进行交互:

可用的 MCP 工具

  • execute_command :在虚拟机上运行shell命令

    • 参数: { "command": "your shell command" }

  • start_tunnel :创建 Web 隧道来访问 VM 界面

    • 参数: { "port": 8080, "subdomain": "optional-subdomain" }

Web 界面

启动隧道后,您可以通过隧道提供的 URL 访问基于 Web 的终端界面。此界面允许您执行以下操作:

  • 直接在虚拟机中执行命令

  • 实时查看命令输出

  • 通过任何具有 Web 访问权限的设备与虚拟机进行交互

环境变量

创建一个.env文件来配置服务器:

# Server configuration PORT=8080 # Localtunnel configuration LOCALTUNNEL_SUBDOMAIN=your-preferred-subdomain

安全注意事项

此工具可直接访问虚拟机的命令行。请考虑以下安全措施:

  • 在暴露隧道之前使用强大的身份验证机制

  • 通过适当的验证来限制可以执行的命令

  • 考虑在受限环境中运行

  • 不要通过隧道泄露敏感信息

-
security - not tested
F
license - not found
-
quality - not tested

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/leomercier/mcp-tunnel'

If you have feedback or need assistance with the MCP directory API, please join our Discord server