Command Executor
STDIOA Model Context Protocol server for executing pre-approved commands securely.
A Model Context Protocol server for executing pre-approved commands securely.
A Model Context Protocol server for executing pre-approved commands securely.
https://github.com/user-attachments/assets/ed763a12-b685-4e0b-b9a5-bc948a590f51
Install dependencies:
npm install
Build the server:
npm run build
For development with auto-rebuild:
npm run watch
By default, the following commands are allowed:
You can customize the allowed commands by setting the ALLOWED_COMMANDS
environment variable:
export ALLOWED_COMMANDS=git,ls,mkdir,python
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" } } }
The command-executor server implements several security measures:
Pre-approved Command List
Command Validation
Error Handling
Environment Isolation
command-executor/
├─ src/
│ └─ index.ts # Main server implementation
├─ build/
│ └─ index.js # Compiled JavaScript
├─ assets/
│ └─ header.svg # Project header image
└─ package.json # Project configuration
Since MCP servers communicate over stdio, debugging can be challenging. We recommend using the MCP Inspector:
npm run inspector
The Inspector will provide a URL to access debugging tools in your browser.
The server provides a single tool:
Executes a pre-approved command.
Parameters:
command
(string, required): The command to executeExample Request:
{ "name": "execute_command", "arguments": { "command": "git status" } }
Example Response:
{ "content": [ { "type": "text", "text": "On branch main\nNothing to commit, working tree clean" } ] }
Error Response:
{ "content": [ { "type": "text", "text": "Command execution failed: Command not allowed" } ], "isError": true }
The server provides detailed error messages for various scenarios:
Unauthorized Commands
{ "code": "InvalidParams", "message": "Command not allowed: [command]. Allowed commands: git, ls, mkdir, cd, npm, npx, python" }
Execution Failures
{ "content": [ { "type": "text", "text": "Command execution failed: [error message]" } ], "isError": true }
This project is licensed under the MIT License - see the LICENSE file for details.