command-executor
Model Context Protocol Server for Safely Executing Pre-approved Commands
claude mcp add --transport stdio sunwood-ai-labs-command-executor-mcp-server node /path/to/command-executor/build/index.js
How to use
The command-executor MCP server provides a secure, MCP-driven interface for executing pre-approved shell commands. It enforces a configurable allowlist of commands and validates each request to prevent injection or unauthorized actions. Clients interact with the server via the MCP tool API, sending an execute_command request with a selected pre-approved command. The server streams output back to the client in real time, enabling you to monitor progress and results without opening a separate terminal. This makes it suitable for automation pipelines and integrated tooling where command execution must be tightly controlled.
With the built-in tool API, you can perform actions such as running git status, listing directory contents, or invoking npm scripts, provided those commands are included in the ALLOWED_COMMANDS list. You can customize the allowed commands through the ALLOWED_COMMANDS environment variable to tailor the capabilities to your security and workflow requirements. The server runs in its own isolated environment and sanitizes environment variables to minimize risk. For debugging, you can use the MCP Inspector tool to connect to the MCP server and inspect requests and responses in your browser.
How to install
Prerequisites:
- Node.js (preferably LTS) and npm installed on your system
- Basic familiarity with MCP workflow and environment variables
Step-by-step installation:
-
Install dependencies npm install
-
Build the server (TypeScript to JavaScript) npm run build
-
(Optional) Run in development with auto-rebuild npm run watch
-
(Optional) Start the server directly for testing node /path/to/command-executor/build/index.js
-
Set up environment variables (example) export ALLOWED_COMMANDS=git,ls,mkdir,python
Optionally configure integration with Claude Desktop or other MCP clients
-
Verify the MCP configuration by connecting through an MCP client and issuing an execute_command request with an allowed command.
Additional notes
Tips and notes:
- The server uses an allowlist approach for security. Update ALLOWED_COMMANDS to enable/disable commands as needed.
- Commands are validated by prefix and run without invoking a shell to reduce injection risk.
- Output is streamed in real time, but failed commands return structured error messages for easier debugging.
- For Claude Desktop integration, place the generated mcpServers configuration in the Claude config path (MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json; Windows: %APPDATA%/Claude/claude_desktop_config.json).
- If you modify the allowed commands or security settings, restart the MCP server to ensure changes take effect.
- When debugging, use the MCP Inspector to monitor requests and responses and surface logs in the browser.
Related MCP Servers
zen
Selfhosted notes app. Single golang binary, notes stored as markdown within SQLite, full-text search, very low resource usage
MCP -Deepseek_R1
A Model Context Protocol (MCP) server implementation connecting Claude Desktop with DeepSeek's language models (R1/V3)
mcp-fhir
A Model Context Protocol implementation for FHIR
mcp
Inkdrop Model Context Protocol Server
mcp-appium-gestures
This is a Model Context Protocol (MCP) server providing resources and tools for Appium mobile gestures using Actions API..
dubco -npm
The (Unofficial) dubco-mcp-server enables AI assistants to manage Dub.co short links via the Model Context Protocol. It provides three MCP tools: create_link for generating new short URLs, update_link for modifying existing links, and delete_link for removing short links.