Back to MCP directory
publicPublicdnsLocal runtime

terminal-mcp-server

该项目是一个终端命令的模型上下文协议(MCP)服务器实现,允许通过Claude配置在指定目录中执行终端命令。

article

README

🚀 终端 MCP 服务器

本仓库实现了终端命令的模型上下文协议(MCP)服务器。借助该服务器,Claude 能够在指定目录中执行终端命令,为用户提供更便捷的操作体验。

🚀 快速开始

✨ 主要特性

  • 实现终端命令的模型上下文协议(MCP),支持Claude在指定目录执行终端命令。
  • 配置灵活,可根据需求指定Claude可访问的目录。

📦 安装指南

先决条件

  • Node.js (v16 或更高版本)
  • npm (v7 或更高版本)

本地安装

  1. 克隆仓库:
git clone https://github.com/algae514/terminal-mcp-server.git
cd terminal-mcp-server
  1. 安装依赖项:
npm install
  1. 构建项目:
npm run build
  1. 使启动脚本具有可执行性:
chmod +x start-server.sh

配置

要使用此服务器与Claude配合,您需要更新Claude的配置文件以包含终端MCP服务器。 更新Claude配置文件(通常位于 ~/.config/claude/claude_desktop_config.json 或类似位置),添加以下内容:

{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-filesystem",
        "/path/to/directory1",
        "/path/to/directory2",
        "/path/to/directory3"
      ]
    },
    "terminal": {
      "command": "/path/to/terminal-mcp-server/start-server.sh",
      "args": []
    }
  }
}
  • /path/to/directory1/path/to/directory2 等替换为您希望Claude可以访问的目录。
  • /path/to/terminal-mcp-server 替换为实际克隆仓库的位置。

💻 使用示例

基础用法

配置完成后,Claude 可以通过终端 MCP 服务器在指定目录中执行终端命令。

🔧 技术细节

本服务器基于Node.js和npm构建,通过配置Claude的配置文件,使其能够与Claude进行交互,实现终端命令的执行。

⚠️ 安全注意事项

  • 要允许终端在某个目录中运行命令,您需要在 maven-tool.json 文件中提供这些位置。示例 URL 已经提供。
  • 对于暴露给 Claude 的目录要格外小心,因为它将能够在此类位置中执行命令。
  • 考虑使用具有受限权限的专用用户来运行服务器。
  • 检查 Claude 执行的命令以确保它们安全且适当。

📄 许可证

本项目采用 MIT License

help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client