Skip to main content
Glama

MCP Shell Server

MCP Shell 服务器

用于执行实现模型上下文协议 (MCP) 的 shell 命令的安全服务器。该服务器允许远程执行授权的 shell 命令,并支持通过 stdin 输入。

特征

  • 安全命令执行:只有授权的命令才能执行
  • 标准输入支持:通过 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" } }, } }
安装
pip install mcp-shell-server

使用

启动服务器

ALLOW_COMMANDS="ls,cat,echo" uvx mcp-shell-server # Ou usando o alias ALLOWED_COMMANDS="ls,cat,echo" uvx mcp-shell-server

ALLOW_COMMANDS环境变量(或其别名ALLOWED_COMMANDS )指定可以执行哪些命令。命令可以用逗号分隔,周围可以有空格。

ALLOW_COMMANDS 或 ALLOWED_COMMANDS 的有效格式:

ALLOW_COMMANDS="ls,cat,echo" # Formato básico ALLOWED_COMMANDS="ls ,echo, cat" # Com espaços (usando alias) ALLOW_COMMANDS="ls, cat , echo" # Múltiplos espaços

请求格式

# Execução básica de comando { "command": ["ls", "-l", "/tmp"] } # Comando com entrada stdin { "command": ["cat"], "stdin": "Hello, World!" } # Comando com timeout { "command": ["long-running-process"], "timeout": 30 # Tempo máximo de execução em segundos } # Comando com diretório de trabalho e timeout { "command": ["grep", "-r", "pattern"], "directory": "/path/to/search", "timeout": 60 }

响应格式

成功响应:

{ "stdout": "saída do comando", "stderr": "", "status": 0, "execution_time": 0.123 }

错误响应:

{ "error": "Comando não permitido: rm", "status": 1, "stdout": "", "stderr": "Comando não permitido: 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 许可证 - 详情请参阅许可证文件

Install Server
A
security – no known vulnerabilities
F
license - not found
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) 的安全服务器,可通过 stdin 支持控制授权 shell 命令的执行。

  1. 特征
    1. 在 Claude.app 中配置 MCP 客户端
      1. 已发布版本
      2. 本地版本
    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 shell command execution server implementing the Model Context Protocol (MCP). This server allows remote execution of whitelisted shell commands with support for stdin input.
            Last updated 3 months ago
            1
            116
            Python
            MIT License
            • Apple
          • 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 a month ago
            9
            731
            228
            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 6 months ago
            1
            418
            6
            JavaScript
            MIT License
            • Apple
          • A
            security
            A
            license
            A
            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 24 days ago
            9
            346
            6
            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/diegofornalha/mcp-shell-server'

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