Fire in da houseTop Tip:Paying $100+ per month for Perplexity, MidJourney, Runway, ChatGPT and other tools is crazy - get all your AI tools in one site starting at $15 per month with Galaxy AI Fire in da houseCheck it out free

dynamic-shell-server

MCP.Pizza Chef: codelion

The dynamic-shell-server is an MCP server that enables secure execution of shell commands with a dynamic approval system. It supports running arbitrary commands while ensuring security through user approval, persistent storage of approved commands, comprehensive audit logging, command timeout protection, and command revocation capabilities. This server is ideal for controlled environments where command execution must be monitored and authorized.

Use This MCP server To

Run shell commands with user approval in real-time Maintain audit logs of all executed shell commands Store and manage approved shell commands persistently Enforce command execution timeouts to prevent hangs Revoke previously approved commands dynamically Integrate with desktop clients like Claude for command control

README

Dynamic Shell Command MCP Server

A Model Context Protocol (MCP) server that enables secure execution of shell commands with a dynamic approval system. This server allows running arbitrary commands while maintaining security through user approval and audit logging.

Features

  • 🔐 Dynamic command approval system
  • 📝 Persistent storage of approved commands
  • 📊 Comprehensive audit logging
  • ⏱️ Command timeout protection
  • 🔄 Command revocation capability

Installation

  1. Clone this repository:
git clone <repository-url>
cd dynamic-shell-server
  1. Create a virtual environment and activate it:
python -m venv venv
source venv/bin/activate  # On Windows use: venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt

Usage

Standalone Mode

Run the server directly:

python dynamic_shell_server.py

Claude Desktop Integration

  1. Open your Claude Desktop configuration:

    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Windows: %APPDATA%\Claude\claude_desktop_config.json
  2. Add the server configuration:

{
    "mcpServers": {
        "shell": {
            "command": "/absolute/path/to/.venv/bin/python",
            "args": ["/absolute/path/to/dynamic_shell_server.py"]
        }
    }
}
  1. Restart Claude Desktop

Command Approval Process

When running a command for the first time, you'll be prompted with:

Command Approval Required

Command: <command>
Arguments: <args>

This command has not been previously approved. Do you want to:
1. Allow this command once
2. Allow this command and remember for future use
3. Deny execution

Please choose an option (1-3):

Available Tools

  1. execute_command: Execute a shell command

    • Parameters:
      • command: The command to execute
      • args: Optional list of command arguments
  2. revoke_command_approval: Revoke approval for a previously approved command

    • Parameters:
      • command: The command to revoke approval for

Available Resources

  1. commands://approved: Lists all approved commands with their approval dates

Data Storage

The server stores its data in ~/.config/mcp-shell-server/:

  • approved_commands.json: List of approved commands and their approval dates
  • audit.log: Detailed execution history of all commands

Security Features

  • User approval required for first-time command execution
  • Persistent storage of approved commands
  • Comprehensive audit logging
  • 5-minute command timeout
  • No shell execution (prevents injection attacks)
  • Command revocation capability

Example Usage

Through Claude Desktop:

Human: Run 'npm install' in my project directory
Assistant: I'll help you run that command. Since this is the first time running 'npm install', you'll need to approve it.
[Command approval prompt appears]

dynamic-shell-server FAQ

How does the dynamic approval system work?
It requires user approval before executing any shell command, ensuring security and control.
Can I revoke an approved command?
Yes, the server supports dynamic revocation of previously approved commands.
How is audit logging handled?
All executed commands and approvals are logged comprehensively for auditing purposes.
Does the server support command timeout?
Yes, it enforces command timeout protection to avoid long-running or stuck processes.
How do I install the dynamic-shell-server?
Clone the repository, create a virtual environment, activate it, and install dependencies via pip.
Can this server integrate with other MCP clients?
Yes, it can integrate with clients like Claude Desktop for enhanced command management.
Is it safe to run arbitrary shell commands?
The server mitigates risks by requiring approval and logging all commands, enhancing security.
What platforms does the server support?
It runs on any platform supporting Python and virtual environments, including Windows, macOS, and Linux.