Skip to main content
Glama

Shell MCP 服务器

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

特征

  • 符合 MCP 标准的服务器实现

  • 通过黑名单保护来确保命令执行的安全

  • 命令存在验证

  • 基于标准 I/O 的传输

  • 错误处理和正常关闭

安装

运行npx mcp-shell

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

启动(或重新启动) Claude Desktop ,您应该会看到登录页面上列出的 MCP 工具。

安全功能

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

  1. 命令黑名单

    • 防止执行危险的系统命令

    • 阻止访问关键系统修改

    • 防止文件系统被破坏

    • 防止权限提升

  2. 命令验证

    • 执行前验证命令是否存在

    • 验证黑名单

    • 返回无效命令的明确错误消息

可用工具

服务器提供了一个工具:

运行命令

执行 shell 命令并返回其输出。

输入模式:

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

回复:

  • 成功:命令以纯文本形式输出

  • 错误:错误消息为纯文本

黑名单命令

出于安全考虑,以下命令类别被阻止:

  • 文件系统销毁命令(rm、rmdir、del)

  • 磁盘/文件系统命令(format、mkfs、dd)

  • 权限/所有权命令(chmod、chown)

  • 权限提升命令(sudo、su)

  • 代码执行命令(exec、eval)

  • 系统通信命令(写入、墙)

  • 系统控制命令(关机、重启、初始化)

错误处理

该服务器包括全面的错误处理:

  • 未找到命令错误

  • 列入黑名单的命令错误

  • 执行错误

  • MCP 协议错误

  • SIGINT 信号正常关闭

实现细节

该服务器使用以下方式构建:

  • 模型上下文协议 SDK

  • StdioServerTransport 用于通信

  • execa 用于命令执行

  • command-exists 用于命令验证

发展

要修改安全设置,您可以:

  1. 编辑BLACKLISTED_COMMANDS设置以调整被阻止的命令

  2. 修改validateCommand函数以添加其他验证规则

  3. 增强CallToolRequestSchema处理程序中的命令解析逻辑

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

Related MCP Servers

  • A
    security
    F
    license
    A
    quality
    A Model Context Protocol server implementation that enables secure remote command execution via SSH, with features for managing and using SSH credentials.
    Last updated -
    5
    3
    9
  • -
    security
    -
    license
    -
    quality
    A TypeScript application that allows Claude to safely execute bash commands with security safeguards, providing a secure interface through the Model Context Protocol.
  • A
    security
    A
    license
    A
    quality
    A secure Model Context Protocol server that allows AI models to safely interact with Windows command-line functionality, enabling controlled execution of system commands, project creation, and system information retrieval.
    Last updated -
    8
    7
    MIT License
  • -
    security
    F
    license
    -
    quality
    A secure interface that enables language models to execute shell commands on the host operating system through the Model Context Protocol.
    Last updated -
    1

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

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