
用于安全执行预批准命令的模型上下文协议服务器
概览
一个用于安全执行预先批准命令的模型上下文协议服务器。 https://github.com/user-attachments/assets/ed763a12-b685-4e0b-b9a5-bc948a590f51 - 安全命令执行,预先批准的命令列表 - 通过环境变量配置允许命令 - 使用 TypeScript 和 MCP SDK 构建 - 通过 stdio 通信实现无缝集成 - 错误处理和安全验证 - 实时命令输出流 默认情况下,允许以下命令:- git - ls - mkdir - cd - npm - npx - python 你可以通过设置ALLOWED_COMMANDS环境变量来自定义允许的命令: 要配合Claude Desktop使用,添加服务器配置: 命令执行服务器实现了若干安全措施: 1. 预批准命令列表 - 仅允许执行明确允许的命令 - 默认列表限制性且注重安全 - 命令通过前缀验证以防止注入
概述(AI 翻译)
一个用于安全执行预先批准命令的模型上下文协议服务器。
🎥 演示
https://github.com/user-attachments/assets/ed763a12-b685-4e0b-b9a5-bc948a590f51
✨ 特色
- 通过预批准的命令列表安全执行命令
- 通过环境变量可配置允许的命令
- 使用 TypeScript 和 MCP SDK 构建
- 通过stdio实现无缝集成
- 错误处理和安全验证
- 实时命令输出流
🚀 安装
安装依赖:
搭建服务器:
关于自动重建的开发:
⚙️ 配置
🔒 允许的指令
默认情况下,允许以下命令:
- git
- ls
- mkdir
- CD
- NPM
- NPX
- 蟒蛇
你可以通过设置 ALLOWED_COMMANDS 环境变量来自定义允许的命令:
🔌 Claude桌面集成
要配合Claude Desktop使用,添加服务器配置:
在MacOS上:
在Windows上:
配置示例:
🛡️ 安全考量
命令执行服务器实现了若干安全措施:
- 预先批准的指挥名单
- 只能执行明确允许的命令
- 默认列表具有限制性且注重安全
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
A Model Context Protocol server for executing pre-approved commands securely.
🎥 Demo
https://github.com/user-attachments/assets/ed763a12-b685-4e0b-b9a5-bc948a590f51
✨ Features
- Secure command execution with pre-approved command list
- Configurable allowed commands through environment variables
- Built with TypeScript and MCP SDK
- Communication via stdio for seamless integration
- Error handling and security validations
- Real-time command output streaming
🚀 Installation
Install dependencies:
npm install
Build the server:
npm run build
For development with auto-rebuild:
npm run watch
⚙️ Configuration
🔒 Allowed Commands
By default, the following commands are allowed:
- git
- ls
- mkdir
- cd
- npm
- npx
- python
You can customize the allowed commands by setting the ALLOWED_COMMANDS environment variable:
export ALLOWED_COMMANDS=git,ls,mkdir,python
🔌 Claude Desktop Integration
To use with Claude Desktop, add the server config:
On MacOS:
~/Library/Application Support/Claude/claude_desktop_config.json
On Windows:
%APPDATA%/Claude/claude_desktop_config.json
Configuration example:
{
"mcpServers": {
"command-executor": {
"command": "/path/to/command-executor/build/index.js"
}
}
}
🛡️ Security Considerations
The command-executor server implements several security measures:
-
Pre-approved Command List
- Only explicitly allowed commands can be executed
- Default list is restrictive and security-focused
- Commands are validated by prefix to prevent injection
-
Command Validation
- Command prefix validation prevents command injection
- No shell execution for improved security
- Environment variables are properly sanitized
-
Error Handling
- Comprehensive error handling for unauthorized commands
- Clear error messages for debugging
- Failed commands don’t crash the server
-
Environment Isolation
- Server runs in its own environment
- Environment variables can be controlled
- Limited system access
💻 Development
📁 Project Structure
command-executor/
├─ src/
│ └─ index.ts # Main server implementation
├─ build/
│ └─ index.js # Compiled JavaScript
├─ assets/
│ └─ header.svg # Project header image
└─ package.json # Project configuration
🐛 Debugging
安装
This server does not publish a one-line install command.
Open the repository installation guide 新手?先看 mcpskill.org 教程 →配置
{
"mcpServers": {
"command-executor": {
"command": "/path/to/command-executor/build/index.js"
}
}
}