MCP ExplorerExplorer

Dynamic Shell Server

@codelionon 9 months ago
23 Apache-2.0
FreeCommunity
AI Systems
#anthropic#anthropic-claude#cli#command-line#mcp#mcp-client#mcp-host#mcp-server#mcp-tools#model-context-protocol#model-context-protocol-servers#shell#shell-server#shellserver
Dynamic Shell Command MCP Server

Overview

What is Dynamic Shell Server

Dynamic-shell-server is a Model Context Protocol (MCP) server designed for the secure execution of shell commands with a dynamic approval system, ensuring that commands are executed safely through user approval and audit logging.

Use cases

Use cases include executing administrative commands securely, automating deployment processes, and managing system configurations while maintaining a log of all executed commands for auditing purposes.

How to use

To use dynamic-shell-server, clone the repository, set up a virtual environment, install dependencies, and run the server. For integration with Claude Desktop, configure the server settings in the Claude Desktop configuration file and restart the application.

Key features

Key features include a dynamic command approval system, persistent storage of approved commands, comprehensive audit logging, command timeout protection, and the ability to revoke command approvals.

Where to use

Dynamic-shell-server can be used in environments where secure execution of shell commands is required, such as development, testing, and production environments, particularly in organizations with strict security policies.

Content

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]

Tools

No tools

Comments

Recommend MCP Servers

View All MCP Servers