script_wrapper_mcp_server

ceyhunkoc/script_wrapper_mcp_server

3.2

If you are the rightful owner of script_wrapper_mcp_server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

The MCP Script Runner is a server that allows AI agents to execute predefined bash scripts within a Dockerized environment, providing a flexible and secure interface for script execution.

Tools
  1. run_script

    Execute a configured script

  2. list_scripts

    List all available scripts

  3. get_script_info

    Get script details

  4. get_working_directory

    Get current working directory

  5. set_working_directory

    Set working directory

  6. reload_config

    Reload configuration file

MCP Script Runner

A Model Context Protocol (MCP) server that provides coding agents with a generic interface to execute developer-defined bash scripts within a Dockerized environment.

๐Ÿš€ Quick Start

Option 1: Docker (Recommended)

# Clone and run with Docker
git clone <repository-url>
cd devmcp
docker compose up --build -d

# Check logs
docker compose logs -f

Option 2: Local Installation

# Clone repository
git clone <repository-url>
cd devmcp

# Install dependencies
pip install -r requirements.txt

# Run the server
python -m mcp_script_runner.server

๐Ÿ“‹ Overview

The MCP Script Runner Server enables AI agents to:

  • Execute predefined bash scripts with configurable arguments
  • Manage working directories for different project contexts
  • Get script information including descriptions and available arguments
  • List available scripts dynamically
  • Handle script timeouts and error conditions gracefully

๐Ÿณ Docker Support

The project includes full Docker support for containerized execution:

  • ๐Ÿ”ง Ready-to-use containers with all dependencies
  • ๐Ÿ›ก๏ธ Isolated execution environment
  • ๐Ÿ“ฆ Easy deployment with Docker Compose
  • ๐Ÿ” Debug capabilities with interactive shell access

See for complete Docker usage guide.

Quick Docker Commands

# Start the MCP server
docker compose up --build -d

# Interactive development shell
docker compose --profile debug up shell

# Test script execution
docker compose exec mcp-script-runner bash scripts/hello.sh

๐Ÿ› ๏ธ Installation

Prerequisites

  • Python 3.11+
  • Docker (for containerized execution)
  • Bash-compatible shell

Local Setup

# Install Python dependencies
pip install -r requirements.txt

# Verify installation
python -c "from src.mcp_script_runner.server import main; print('โœ… Installation OK')"

Docker Setup

# Build container
docker build -t mcp-script-runner .

# Or use Docker Compose
docker compose up --build

โš™๏ธ Configuration

Configuration File: .mcp-config.json

{
  "working_directory": ".",
  "scripts": {
    "hello": {
      "path": "scripts/hello.sh",
      "description": "Simple hello world script",
      "arguments": [],
      "timeout": 30
    },
    "list_files": {
      "path": "scripts/list_files.sh",
      "description": "List files in directory with options",
      "arguments": ["directory", "options"],
      "timeout": 10
    }
  }
}

Script Directory Structure

project/
โ”œโ”€โ”€ .mcp-config.json
โ”œโ”€โ”€ scripts/
โ”‚   โ”œโ”€โ”€ hello.sh
โ”‚   โ”œโ”€โ”€ list_files.sh
โ”‚   โ””โ”€โ”€ system_info.sh
โ””โ”€โ”€ src/
    โ””โ”€โ”€ mcp_script_runner/

๐Ÿ”ง Available MCP Tools

ToolDescriptionArguments
run_scriptExecute a configured scriptscript_name, arguments[]
list_scriptsList all available scriptsNone
get_script_infoGet script detailsscript_name
get_working_directoryGet current working directoryNone
set_working_directorySet working directorypath
reload_configReload configuration fileNone

Example Tool Usage

{
  "tool": "run_script",
  "arguments": {
    "script_name": "hello",
    "arguments": []
  }
}

๐Ÿƒโ€โ™‚๏ธ Running the Server

Local Execution

# Start MCP server (listens on stdio)
python -m mcp_script_runner.server

# Or with explicit path
PYTHONPATH=src python -m mcp_script_runner.server

Docker Execution

# Background service
docker compose up -d

# Interactive mode
docker compose run --rm mcp-script-runner

# Debug shell
docker compose --profile debug up shell

๐Ÿ“ Example Scripts

Basic Hello Script (scripts/hello.sh)

#!/bin/bash
echo "Hello from MCP Script Runner!"
echo "Current directory: $(pwd)"
echo "Script arguments: $@"
echo "Date: $(date)"

File Listing Script (scripts/list_files.sh)

#!/bin/bash
DIRECTORY=${1:-.}
OPTIONS=${2:-"-la"}
echo "Listing files in: $DIRECTORY"
ls $OPTIONS "$DIRECTORY"

System Info Script (scripts/system_info.sh)

#!/bin/bash
echo "=== System Information ==="
echo "OS: $(uname -s)"
echo "Kernel: $(uname -r)"
echo "Architecture: $(uname -m)"
echo "Uptime: $(uptime)"
echo "Disk Usage:"
df -h

๐Ÿงช Testing

Unit Tests

# Run tests locally
python -m pytest tests/

# Run tests in Docker
docker compose run --rm mcp-script-runner python -m pytest tests/

Manual Testing

# Test script execution
python -c "
import asyncio
from src.mcp_script_runner.executor import ScriptExecutor
from src.mcp_script_runner.config import ConfigManager

async def test():
    cm = ConfigManager()
    ex = ScriptExecutor(cm)
    result = await ex.execute_script('hello')
    print(f'Exit code: {result.exit_code}')
    print(result.stdout)

asyncio.run(test())
"

๐Ÿ” Security Considerations

  • ๐Ÿ›ก๏ธ Containerized execution isolates script execution
  • ๐Ÿ‘ค Non-root user inside containers (mcpuser)
  • ๐Ÿ“ Limited file access through volume mounts
  • โฑ๏ธ Script timeouts prevent runaway processes
  • ๐Ÿšซ No shell injection - arguments passed safely

๐ŸŽฏ Use Cases

Development Automation

  • Build and test commands
  • Code generation scripts
  • Development environment setup

System Administration

  • System monitoring scripts
  • Backup and maintenance tasks
  • Configuration management

CI/CD Integration

  • Deployment scripts
  • Environment validation
  • Automated testing workflows

Project Management

  • Task automation
  • Report generation
  • Resource management

๐Ÿ› Troubleshooting

Common Issues

MCP Server Won't Start

# Check Python path
export PYTHONPATH=src

# Verify dependencies
pip install -r requirements.txt

# Check configuration
python -c "from src.mcp_script_runner.config import ConfigManager; cm = ConfigManager(); print('Config OK')"

Script Execution Fails

# Check script permissions
chmod +x scripts/*.sh

# Test script directly
bash scripts/hello.sh

# Check Docker logs
docker compose logs mcp-script-runner

Docker Issues

# Rebuild container
docker compose up --build

# Check container status
docker compose ps

# Interactive debugging
docker compose run --rm mcp-script-runner bash

Debug Mode

# Local debug
PYTHONPATH=src python -c "
import logging
logging.basicConfig(level=logging.DEBUG)
from mcp_script_runner.server import main
import asyncio
asyncio.run(main())
"

# Docker debug
docker compose --profile debug up shell

๐Ÿ“š Development

Project Structure

devmcp/
โ”œโ”€โ”€ ๐Ÿ“„ README.md              # This file
โ”œโ”€โ”€ ๐Ÿณ DOCKER.md              # Docker usage guide
โ”œโ”€โ”€ ๐Ÿ“‹ TASKS.md               # Development tasks
โ”œโ”€โ”€ โš™๏ธ .mcp-config.json       # Configuration
โ”œโ”€โ”€ ๐Ÿณ Dockerfile             # Container definition
โ”œโ”€โ”€ ๐Ÿณ docker-compose.yml     # Container orchestration
โ”œโ”€โ”€ ๐Ÿ“ฆ requirements.txt       # Python dependencies
โ”œโ”€โ”€ ๐Ÿ“ฆ pyproject.toml         # Python project config
โ”œโ”€โ”€ ๐Ÿ”ง scripts/               # Example scripts
โ”œโ”€โ”€ ๐Ÿ src/mcp_script_runner/ # Python source code
โ””โ”€โ”€ ๐Ÿงช tests/                 # Unit tests

Adding New Scripts

  1. Create script in scripts/ directory
  2. Make executable: chmod +x scripts/myscript.sh
  3. Add to .mcp-config.json:
{
  "scripts": {
    "myscript": {
      "path": "scripts/myscript.sh",
      "description": "My custom script",
      "arguments": ["arg1", "arg2"],
      "timeout": 30
    }
  }
}
  1. Reload configuration: Use reload_config tool

Contributing

  1. Fork the repository
  2. Create feature branch
  3. Add tests for new functionality
  4. Test with Docker: docker compose up --build
  5. Submit pull request

๐Ÿš€ Deployment

Production Deployment

# Using Docker Compose
docker compose up -d

# Using Docker Swarm
docker stack deploy -c docker-compose.yml mcp-stack

# Using Kubernetes
kubectl apply -f k8s/

Integration with MCP Clients

Claude Desktop Configuration

{
  "mcpServers": {
    "script-runner": {
      "command": "docker",
      "args": ["compose", "-f", "/path/to/devmcp/docker-compose.yml", "run", "--rm", "mcp-script-runner"]
    }
  }
}

๐Ÿ“„ License

MIT License - see LICENSE file for details.

๐Ÿค Support

  • ๐Ÿ“– Documentation: See for Docker usage
  • ๐Ÿ› Issues: Create GitHub issue
  • ๐Ÿ’ฌ Discussions: GitHub Discussions
  • ๐Ÿ“ง Contact: See repository contributors

Ready to get started?

๐Ÿณ Docker users: docker compose up --build ๐Ÿ Local users: pip install -r requirements.txt && python -m mcp_script_runner.server