Skip to main content
Glama

mcp-shell-server

by tumf

MCP Shell 服务器

一个实现了模型上下文协议 (MCP) 的安全 Shell 命令执行服务器。此服务器允许远程执行白名单 Shell 命令,并支持标准输入。

特征

  • 安全命令执行:只能执行白名单命令
  • 标准输入支持:通过 stdin 将输入传递给命令
  • 综合输出:返回 stdout、stderr、退出状态和执行时间
  • Shell 运算符安全:验证 Shell 运算符(;、&&、||、|)后的命令
  • 超时控制:设置命令的最大执行时间

Claude.app 中的 MCP 客户端设置

已发布版本

code ~/Library/Application\ Support/Claude/claude_desktop_config.json
{ "mcpServers": { "shell": { "command": "uvx", "args": [ "mcp-shell-server" ], "env": { "ALLOW_COMMANDS": "ls,cat,pwd,grep,wc,touch,find" } }, } }

本地版本

配置
code ~/Library/Application\ Support/Claude/claude_desktop_config.json
{ "mcpServers": { "shell": { "command": "uv", "args": [ "--directory", ".", "run", "mcp-shell-server" ], "env": { "ALLOW_COMMANDS": "ls,cat,pwd,grep,wc,touch,find" } }, } }
安装

通过 Smithery 安装

要通过Smithery自动为 Claude Desktop 安装 Shell 服务器:

npx -y @smithery/cli install mcp-shell-server --client claude

手动安装

pip install mcp-shell-server

通过 Smithery 安装

要通过Smithery自动为 Claude Desktop 安装 Shell 服务器:

npx -y @smithery/cli install mcp-shell-server --client claude

用法

启动服务器

ALLOW_COMMANDS="ls,cat,echo" uvx mcp-shell-server # Or using the alias ALLOWED_COMMANDS="ls,cat,echo" uvx mcp-shell-server

ALLOW_COMMANDS (或其别名ALLOWED_COMMANDS )环境变量指定允许执行哪些命令。命令之间可以用逗号分隔,逗号两侧可以加空格。

ALLOW_COMMANDS 或 ALLOWED_COMMANDS 的有效格式:

ALLOW_COMMANDS="ls,cat,echo" # Basic format ALLOWED_COMMANDS="ls ,echo, cat" # With spaces (using alias) ALLOW_COMMANDS="ls, cat , echo" # Multiple spaces

请求格式

# Basic command execution { "command": ["ls", "-l", "/tmp"] } # Command with stdin input { "command": ["cat"], "stdin": "Hello, World!" } # Command with timeout { "command": ["long-running-process"], "timeout": 30 # Maximum execution time in seconds } # Command with working directory and timeout { "command": ["grep", "-r", "pattern"], "directory": "/path/to/search", "timeout": 60 }

响应格式

成功响应:

{ "stdout": "command output", "stderr": "", "status": 0, "execution_time": 0.123 }

错误响应:

{ "error": "Command not allowed: rm", "status": 1, "stdout": "", "stderr": "Command not allowed: rm", "execution_time": 0 }

安全

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

  1. 命令白名单:只有明确允许的命令才能执行
  2. Shell 运算符验证:shell 运算符(;、&&、||、|)后的命令也会根据白名单进行验证
  3. 无 Shell 注入:命令直接执行,无需 Shell 解释

发展

设置开发环境

  1. 克隆存储库
git clone https://github.com/yourusername/mcp-shell-server.git cd mcp-shell-server
  1. 安装依赖项,包括测试要求
pip install -e ".[test]"

运行测试

pytest

API 参考

请求参数

场地类型必需的描述
命令细绳[]是的命令及其参数作为数组元素
标准输入细绳传递给命令的输入
目录细绳命令执行的工作目录
暂停整数最大执行时间(秒)

响应字段

场地类型描述
标准输出细绳命令的标准输出
标准错误细绳命令的标准错误输出
地位整数退出状态代码
执行时间漂浮执行所需的时间(以秒为单位)
错误细绳错误消息(仅在失败时出现)

要求

  • Python 3.11 或更高版本
  • mcp>=1.1.0

执照

MIT 许可证 - 详情请参阅许可证文件

You must be authenticated.

A
security – no known vulnerabilities
A
license - permissive license
A
quality - confirmed to work

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

一个实现了模型上下文协议 (MCP) 的安全 Shell 命令执行服务器。此服务器允许远程执行白名单 Shell 命令,并支持标准输入。

  1. 特征
    1. Claude.app 中的 MCP 客户端设置
      1. 已发布版本
      2. 本地版本
      3. 通过 Smithery 安装
      4. 手动安装
      5. 通过 Smithery 安装
    2. 用法
      1. 启动服务器
      2. 请求格式
      3. 响应格式
    3. 安全
      1. 发展
        1. 设置开发环境
        2. 运行测试
      2. API 参考
        1. 请求参数
        2. 响应字段
      3. 要求
        1. 执照

          Related MCP Servers

          • A
            security
            A
            license
            A
            quality
            A secure MCP server for executing whitelisted shell commands with resource and timeout controls, designed for integration with Claude and other MCP-compatible LLMs.
            Last updated -
            20
            143
            2
            TypeScript
            MIT License
          • A
            security
            A
            license
            A
            quality
            A Model Context Protocol server that provides secure command-line access to Windows systems, allowing MCP clients like Claude Desktop to safely execute commands in PowerShell, CMD, and Git Bash shells with configurable security controls.
            Last updated -
            9
            350
            105
            JavaScript
            MIT License
          • A
            security
            A
            license
            A
            quality
            A secure terminal execution server that enables controlled command execution with security features and resource limits via the Model Context Protocol (MCP).
            Last updated -
            1
            12
            1
            JavaScript
            MIT License
            • Apple
          • -
            security
            A
            license
            -
            quality
            An MCP server that enables secure execution of shell commands across Windows, macOS, and Linux with built-in whitelisting and approval mechanisms for enhanced security.
            Last updated -
            13
            JavaScript
            MIT License
            • Linux
            • Apple

          View all related MCP servers

          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/tumf/mcp-shell-server'

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