Command Executor MCP Server
local-only server
The server can only run on the clientโs local machine because it depends on local resources.
command-executor MCP Server
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:
Build the server:
For development with auto-rebuild:
โ๏ธ 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:
๐ Claude Desktop Integration
To use with Claude Desktop, add the server config:
On MacOS:
On Windows:
Configuration example:
๐ก๏ธ 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
๐ Debugging
Since MCP servers communicate over stdio, debugging can be challenging. We recommend using the MCP Inspector:
The Inspector will provide a URL to access debugging tools in your browser.
๐ ๏ธ Tool API
The server provides a single tool:
execute_command
Executes a pre-approved command.
Parameters:
command
(string, required): The command to execute
Example Request:
Example Response:
Error Response:
โ Error Handling
The server provides detailed error messages for various scenarios:
- Unauthorized CommandsCopy
- Execution FailuresCopy
๐ค Contributing
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a new Pull Request
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
You must be authenticated.
A Model Context Protocol server that allows secure execution of pre-approved commands, enabling AI assistants to safely interact with the user's system.
- ๐ฅ Demo
- โจ Features
- ๐ Installation
- โ๏ธ Configuration
- ๐ก๏ธ Security Considerations
- ๐ป Development
- ๐ ๏ธ Tool API
- โ Error Handling
- ๐ค Contributing
- ๐ License