Secure Command Executor MCP Server

by HappyAny

251 downloads Not rated yet MIT
GitHub

About

A robust command execution service with daily log rotation, designed to securely manage and execute system commands with safety checks and logging.

Details

License
MIT

Explore

- Command Execution: Execute system commands with optional arguments.
- Safety Checks: Warns and requires confirmation for dangerous commands.
- Command Management: Add, update, remove, enable, or disable commands.
- Logging: Daily log rotation with detailed action tracking.
- Query Tools: Query available commands and logs with filters.

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name Secure Command Executor MCP Server
    Command (node, npx, python, etc.)

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

1. Clone the repository:

   git clone https://github.com/HappyAny/secure-command-executor-mcp-server.git
cd secure-command-executor-mcp-server

2. Install dependencies:

   npm install minimist
npm install @modelcontextprotocol/sdk
npm install zod

3. Configure the service:
- Modify commands.json to define available commands.
- Set environment variables (optional).

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "secure command executor mcp server": {
            "secure-command-executor-mcp-server": {
                "command": "node",
                "args": [
                    "index.js",
                    "--file",
                    "commands.json",
                    "--logs",
                    "logs",
                    "--port",
                    "3000"
                ]
            }
        }
    }
}

McpServers

{
    "secure-command-executor-mcp-server": {
        "command": "node",
        "args": [
            "index.js",
            "--file",
            "commands.json",
            "--logs",
            "logs",
            "--port",
            "3000"
        ]
    }
}

A robust command execution MCP service with daily log rotation, designed to securely manage and execute system commands with safety checks and logging. And this README.md is written by DeepSeek V3.

Features

- Command Execution: Execute system commands with optional arguments.
- Safety Checks: Warns and requires confirmation for dangerous commands.
- Command Management: Add, update, remove, enable, or disable commands.
- Logging: Daily log rotation with detailed action tracking.
- Query Tools: Query available commands and logs with filters.

Installation

1. Clone the repository:

   git clone https://github.com/HappyAny/secure-command-executor-mcp-server.git
cd secure-command-executor-mcp-server

2. Install dependencies:

   npm install minimist
npm install @modelcontextprotocol/sdk
npm install zod

3. Configure the service:
- Modify commands.json to define available commands.
- Set environment variables (optional).

Usage

Starting the Service

node index.js --file commands.json --logs logs --port 3000

MCP Setting

{
    "mcpServers": {
        "cmd-exec": {
          "command": "node",
          "args": [
            "path_to_file/index.js",
            "--file",
            "path_to_file/commands.json",
            "--logs",
            "path_to_dict/logs"
          ]
        }
    }
}

Commands File

The commands.json file defines the available commands. Example:
[
  {
    "name": "dir",
    "description": "List directory contents",
    "example": "dir /w",
    "dangerous": false,
    "enabled": true,
    "confirmationPrompt": "",
    "consequences": ""
  },
  {
    "name": "format",
    "description": "Format disk drive",
    "example": "format C:",
    "dangerous": true,
    "enabled": false,
    "confirmationPrompt": "This will PERMANENTLY erase all data. Confirm?",
    "consequences": "Permanent data loss"
  }
]

API Endpoints

Execute a Command
curl -X POST http://localhost:3000/execute -H "Content-Type: application/json" -d '{"command": "dir", "args": "/w"}'
Query Commands
curl -X GET http://localhost:3000/queryCommands?filter=enabled&detailed=true
Manage Commands
curl -X POST http://localhost:3000/manageCommand -H "Content-Type: application/json" -d '{"action": "add", "name": "ping", "description": "Test network connection", "example": "ping example.com"}'
Query Logs
curl -X GET http://localhost:3000/queryLogs?limit=50&filter=failed

Configuration

- Environment Variables:
- NODE_ENV: Set to production for production mode.
- PORT: Override the default port (3000).

- Command-Line Arguments:
- --file: Path to the commands file (default: commands.json).
- --logs: Path to the logs directory (default: logs).
- --port: Port to run the service (default: 3000).

Logging

Logs are stored in the specified directory with daily rotation. Each log file is named YYYY-MM-DD.json.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.