Labsco
tinywind logo

Bash MCP

โ˜… 9

from tinywind

Execute shell commands without permission prompts.

๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅโœ“ VerifiedFreeNeeds API keys

bash-mcp

A simple MCP (Model Context Protocol) server that enables Claude to execute shell commands without permission prompts.

โš ๏ธ Security Warning: This server executes arbitrary shell commands. Use with caution and only in trusted environments.

Available Tools

run - Execute a command

// Simple command
run("ls -la")

// With working directory
run("npm test", { cwd: "/path/to/project" })

// With timeout (milliseconds)
run("long-running-command", { timeout: 60000 })

run_background - Start a background process

// Start a dev server
run_background("npm run dev", "frontend")

// Start backend service with working directory
run_background("./gradlew bootRun", "backend", { cwd: "./backend" })

kill_background - Stop a background process

kill_background("frontend")

list_background - List all background processes

list_background()

Response Format

All tools return JSON formatted responses:

{
  "success": true,
  "stdout": "command output",
  "stderr": "error output if any",
  "command": "executed command"
}

For background processes:

{
  "success": true,
  "name": "frontend",
  "pid": 12345,
  "command": "npm run dev",
  "message": "Started background process 'frontend' (PID: 12345)"
}

Features

  • Execute any shell command without permission prompts
  • Run long-running processes in the background
  • Manage background processes (list, kill)
  • Capture stdout and stderr
  • Set working directory for commands
  • Configure timeout for commands
  • Automatic cleanup on server shutdown
  • NEW: Automatic output truncation with full output saved to temp files
  • NEW: Configurable output size limits and temp directory via environment variables

Environment Variables

  • BASH_MCP_MAX_OUTPUT_SIZE: Maximum output size in bytes before truncation (default: 51200/50KB)
  • BASH_MCP_TEMP_DIR: Directory for storing full output when truncated (default: system temp directory)

Example Configuration

{
  "mcpServers": {
    "bash": {
      "command": "npx",
      "args": ["bash-mcp"],
      "env": {
        "BASH_MCP_MAX_OUTPUT_SIZE": "102400",
        "BASH_MCP_TEMP_DIR": "/tmp/bash-mcp-outputs"
      }
    }
  }
}

Output Overflow Handling

When command output exceeds BASH_MCP_MAX_OUTPUT_SIZE:

  1. Output is truncated to the specified limit
  2. Full output is saved to a temporary file
  3. The response includes the file path where full output can be found
  4. If custom temp directory fails, falls back to system temp directory

Security Considerations

This MCP server executes arbitrary shell commands with the same privileges as the Node.js process. Only use in development environments or trusted contexts.

Author

tinywind tinywind0@gmail.com