S

Shell MCP安全工具

一个安全的MCP服务器,用于执行列入白名单的shell命令,并具有资源和超时控制,专为与克劳德和其他与MCP兼容的大型语言模型集成而设计。

os-automationsecurity-and-iam

812 查看 · 2026-07-07 更新

简介

一个安全的MCP服务器,用于执行列入白名单的shell命令,并具有资源和超时控制,专为与克劳德和其他与MCP兼容的大型语言模型集成而设计。

简介

一个安全的MCP服务器,用于执行列入白名单的shell命令,并具有资源和超时控制,专为与克劳德和其他与MCP兼容的大型语言模型集成而设计。

shell-mcp

Shell 命令执行 MCP 服务器

Version License

一个为 LLMs 提供安全的 shell 命令执行能力的 MCP 服务器实现。

功能

  • 安全执行:仅允许白名单中的命令和参数
  • 资源控制:内存和 CPU 使用监控
  • 超时控制:自动终止长时间运行的命令
  • 大小限制:为了安全起见,限制输出大小
  • MCP 集成:与 Claude 和其他兼容 MCP 的 LLMs 一起工作

安装

npm install @kevinwatt/shell-mcp

Dive Desktop 配置

  1. 在 Dive Desktop 中点击 "+ 添加 MCP 服务器"
  2. 复制并粘贴此配置:
{ "mcpServers": { "shell": { "command": "npx", "args": [ "-y", "@kevinwatt/shell-mcp" ] } } }

工具文档

  • shell_ls, shell_pwd, shell_df 等
    • 执行白名单中的 shell 命令
    • 输入:
      • command (字符串,必填): 要执行的命令
      • args (数组,可选): 命令参数
      • timeout (数字,可选): 执行超时时间(毫秒)

使用示例

让您的 LLM 执行:

"Show current directory using shell_pwd" "List files using shell_ls with -l argument" "Check disk usage using shell_df with -h argument"

手动启动

如果需要,可以手动启动服务器:

npx @kevinwatt/shell-mcp

要求

  • Node.js 18+
  • 兼容 MCP 的 LLM 服务

开发

# Install dependencies npm install # Watch mode npm run watch # Run tests npm test # Lint npm run lint

许可证

MIT © Dewei Yen

关键词

  • mcp
  • shell
  • 命令
  • claude
  • llm
  • 自动化

可用命令

以下 shell 命令可用:

命令描述允许的参数
ls列出目录内容-l, -a, -h, -R, --help, *
cat连接并显示文件内容-n, -b, --help, *
pwd显示当前工作目录None
df显示磁盘使用情况-h, -T, --help
echo显示文本任意文本
ps显示进程状态-e, -f, -u, --help
free显示内存使用情况-h, -m, -g, --help
uptime显示系统运行时间None
date显示系统日期和时间+%Y-%m-%d, +%H:%M:%S, --help
grep在文件中搜索文本模式-i, -v, -n, -r, -l, --color, *
w显示登录用户及其正在做什么-h, -s, --no-header, --help
whois查询WHOIS域名注册信息-H, *
find在目录层次结构中查找文件-name, -type, -size, -mtime, *
netstat网络连接信息-a, -n, -t, -u, -l, -p, --help
lspci列出PCI设备-v, -k, -mm, -nn, --help
lsusb列出USB设备-v, -t, -d, -s, --help
digDNS查询工具+short, +trace, +dnssec, @*, *
nslookup查询DNS记录-type=, -query=, *
ip显示网络设备和接口addr, link, route, neigh, -br, *
whereis定位二进制、源代码和手册文件-b, -m, -s, *

工具列表

  • shell_ls: List directory contents

  • shell_cat: Concatenate and display file contents

  • shell_pwd: Show current working directory

  • shell_df: Show disk usage

  • shell_echo: Display text

  • shell_ps: Show process status

  • shell_free: Show memory usage

  • shell_uptime: Show system uptime

  • shell_date: Show system date and time

  • shell_grep: Search text patterns in files

  • shell_w: Show who is logged on and what they are doing

  • shell_whois: Query WHOIS domain registration information

  • shell_find: Search for files in a directory hierarchy

  • shell_netstat: Network connection information

  • shell_lspci: List PCI devices

  • shell_lsusb: List USB devices

  • shell_dig: DNS lookup utility

  • shell_nslookup: Query DNS records

  • shell_ip: Show / manipulate routing, network devices, interfaces and tunnels

  • shell_whereis: Locate the binary, source, and manual page files for a command

服务配置

[{'mcpServers': {'shell': {'args': ['-y', '@kevinwatt/shell-mcp'], 'command': 'npx'}}}]

来源