HM

hdresearch/mcp-shell

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

41 stars 8 forks 质量 61 趋势 0MIT

hdresearch/mcp-shell 是一个从 https://github.com/hdresearch/mcp-shell. 导入的 MCP 服务器候选。

概览

hdresearch/mcp-shell 是一个从 https://github.com/hdresearch/mcp-shell. 导入的 MCP 服务器候选。

概述(AI 翻译)

模型上下文协议(MCP)的Node.js实现,提供安全的壳级命令执行能力。该服务器允许AI模型在内置安全措施的受控环境中执行壳级命令。轻松集成Claude Desktop,将Claude与您的shell连接。

特色

  • 符合MCP标准的服务器实现
  • 带黑名单保护的安全命令执行
  • 命令存在验证
  • 基于I/O的标准传输
  • 错误处理和优雅关机

安装

运行npx mcp-shell。

要将其添加到 Claude 桌面,请运行 npx mcp-shell config。或者手动在配置中添加 npx -y mcp-shell。

启动(或重启)Claude Desktop,你应该会在登陆页看到MCP工具的列表。

安全特征

服务器实施了多项安全措施:

  1. 命令黑名单
  • 防止执行危险的系统命令
  • 阻止访问关键系统修改
  • 防止文件系统损坏
  • 防止权限升级
  1. 命令验证
  • 在执行前验证命令的存在
  • 对黑名单进行验证

本页由 AI 翻译,技术细节请以原文为准。

README

Shell MCP Server

A Node.js implementation of the Model Context Protocol (MCP) that provides secure shell command execution capabilities. This server allows AI models to execute shell commands in a controlled environment with built-in security measures. Easily integrates with Claude Desktop for connecting Claude with your shell.

Features

  • MCP-compliant server implementation
  • Secure command execution with blacklist protection
  • Command existence validation
  • Standard I/O based transport
  • Error handling and graceful shutdown

Installation

Run npx mcp-shell.

To add it to Claude Desktop, run npx mcp-shell config. Or add npx -y mcp-shell to your config manually.

Start (or restart) Claude Desktop and you should see the MCP tool listed on the landing page.

Security Features

The server implements several security measures:

  1. Command Blacklisting

    • Prevents execution of dangerous system commands
    • Blocks access to critical system modifications
    • Protects against file system destruction
    • Prevents privilege escalation
  2. Command Validation

    • Verifies command existence before execution
    • Validates against the blacklist
    • Returns clear error messages for invalid commands

Available Tools

The server provides one tool:

run_command

Executes a shell command and returns its output.

Input Schema:

{
  "type": "object",
  "properties": {
    "command": { "type": "string" }
  }
}

Response:

  • Success: Command output as plain text
  • Error: Error message as plain text

Blacklisted Commands

The following command categories are blocked for security:

  • File System Destruction Commands (rm, rmdir, del)
  • Disk/Filesystem Commands (format, mkfs, dd)
  • Permission/Ownership Commands (chmod, chown)
  • Privilege Escalation Commands (sudo, su)
  • Code Execution Commands (exec, eval)
  • System Communication Commands (write, wall)
  • System Control Commands (shutdown, reboot, init)

Error Handling

The server includes comprehensive error handling:

  • Command not found errors
  • Blacklisted command errors
  • Execution errors
  • MCP protocol errors
  • Graceful shutdown on SIGINT

Implementation Details

The server is built using:

  • Model Context Protocol SDK
  • StdioServerTransport for communication
  • execa for command execution
  • command-exists for command validation

Development

To modify the security settings, you can:

  1. Edit the BLACKLISTED_COMMANDS set to adjust blocked commands
  2. Modify the validateCommand function to add additional validation rules
  3. Enhance the command parsing logic in the CallToolRequestSchema handler
在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →