local-only server
The server can only run on the client’s local machine because it depends on local resources.
Integrations
Implemented as a Node.js application that follows the Model Context Protocol, offering command validation and secure shell command execution.
Provides secure execution of shell commands with protective measures against dangerous operations including file system destruction, permission changes, and privilege escalation.
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 工具。
安全功能
该服务器实施了多项安全措施:
- 命令黑名单
- 防止执行危险的系统命令
- 阻止访问关键系统修改
- 防止文件系统被破坏
- 防止权限提升
- 命令验证
- 执行前验证命令是否存在
- 验证黑名单
- 返回无效命令的明确错误消息
可用工具
服务器提供了一个工具:
运行命令
执行 shell 命令并返回其输出。
输入模式:
回复:
- 成功:命令以纯文本形式输出
- 错误:错误消息为纯文本
黑名单命令
出于安全考虑,以下命令类别被阻止:
- 文件系统销毁命令(rm、rmdir、del)
- 磁盘/文件系统命令(format、mkfs、dd)
- 权限/所有权命令(chmod、chown)
- 权限提升命令(sudo、su)
- 代码执行命令(exec、eval)
- 系统通信命令(写入、墙)
- 系统控制命令(关机、重启、初始化)
错误处理
该服务器包括全面的错误处理:
- 未找到命令错误
- 列入黑名单的命令错误
- 执行错误
- MCP 协议错误
- SIGINT 信号正常关闭
实现细节
该服务器使用以下方式构建:
- 模型上下文协议 SDK
- StdioServerTransport 用于通信
- execa 用于命令执行
- command-exists 用于命令验证
发展
要修改安全设置,您可以:
- 编辑
BLACKLISTED_COMMANDS
设置以调整被阻止的命令 - 修改
validateCommand
函数以添加其他验证规则 - 增强
CallToolRequestSchema
处理程序中的命令解析逻辑
You must be authenticated.
Tools
模型上下文协议的 Node.js 实现提供了安全的 shell 命令执行功能,允许像 Claude 这样的 AI 模型在具有内置安全措施的受控环境中运行 shell 命令。
- Features
- Installation
- Security Features
- Available Tools
- Blacklisted Commands
- Error Handling
- Implementation Details
- Development
Related Resources
Appeared in Searches
- Using MySQL STDiO with Node.js or Python to Implement an MCP Server
- Information about penetration testing (pentest)
- How to clone a Git repository, create a Gradle 8 project with Java 21 and Spring Boot REST API, compile it, and upload to Git
- Information about Gmail MCP Node
- Transferring a Dockerized Website from Local to Remote Server Using Cursor AI