Cover image
Try Now
2025-03-10

Claude和其他MCP兼容的AI助手的外壳执行MCP服务器

3 years

Works with Finder

1

Github Watches

1

Github Forks

0

Github Stars

Shell Execution MCP Server

A Model Context Protocol (MCP) server that provides persistent shell command execution capabilities for Claude and other MCP-compatible AI assistants.

Features

  • Persistent Shell Session: Maintains state between commands in the same session
  • Background Execution: Run commands in the background with proper process management
  • Cross-Platform: Works on macOS, Linux, and Windows with the appropriate shell
  • Timeout Control: Configure command execution timeouts to prevent hanging
  • Session Reset: Ability to reset the shell session if needed

Installation

# Clone the repository
git clone https://github.com/samihalawa/mcp-server-shell-exec.git
cd mcp-server-shell-exec

# Install dependencies
npm install

# Build the server
npm run build

Usage

Starting the Server

npm start

Configuration

Add the server to your MCP configuration:

{
  "servers": {
    "shell-exec-server": {
      "command": "/path/to/node",
      "args": ["/path/to/mcp-server-shell-exec/build/index.js"],
      "enabled": true,
      "port": 3006,
      "environment": {
        "NODE_PATH": "/path/to/node_modules",
        "PATH": "/usr/local/bin:/usr/bin:/bin"
      }
    }
  }
}

Available Tools

execute-command

Execute a shell command in the persistent shell session.

Parameters:

  • command (string, required): The shell command to execute
  • runInBackground (boolean, optional): Whether to run the command in the background. Default: false
  • timeoutMs (number, optional): Timeout in milliseconds for the command. Default: 30000

Returns:

  • success (boolean): Whether the command executed successfully
  • output (string): Output from the command execution

reset-shell

Reset the shell session. This will kill the current session and start a new one.

Parameters: None

Returns:

  • success (boolean): Whether the shell was reset successfully
  • message (string): Status message

Example Usage

  1. Execute a simple command:

    execute-command(command: "ls -la")
    
  2. Run a long-running command in the background:

    execute-command(command: "sleep 60 && echo 'Done'", runInBackground: true)
    
  3. Execute a command with a custom timeout:

    execute-command(command: "find / -name '*.js'", timeoutMs: 60000)
    
  4. Reset the shell session:

    reset-shell()
    

How It Works

The server uses Node.js's node-pty package to create a pseudo-terminal that maintains state between commands. This allows for:

  • Environment variables to persist between commands
  • Working directory to remain consistent
  • Background processes to continue running
  • Interactive commands that require stdin/stdout

Requirements

  • Node.js 14+
  • node-pty package
  • Compatible with Claude Desktop, Cursor, and other MCP-compatible applications

License

MIT

相关推荐

  • NiKole Maxwell
  • I craft unique cereal names, stories, and ridiculously cute Cereal Baby images.

  • Bora Yalcin
  • Evaluator for marketplace product descriptions, checks for relevancy and keyword stuffing.

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Callycode Limited
  • A geek-themed horoscope generator blending Bitcoin prices, tech jargon, and astrological whimsy.

  • Alexandru Strujac
  • Efficient thumbnail creator for YouTube videos

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Khalid kalib
  • Write professional emails

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • Beniyam Berhanu
  • Therapist adept at identifying core issues and offering practical advice with images.

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • apappascs
  • 发现市场上最全面,最新的MCP服务器集合。该存储库充当集中式枢纽,提供了广泛的开源和专有MCP服务器目录,并提供功能,文档链接和贡献者。

  • ShrimpingIt
  • MCP系列GPIO Expander的基于Micropython I2C的操作,源自ADAFRUIT_MCP230XX

  • OffchainLabs
  • 进行以太坊的实施

  • huahuayu
  • 统一的API网关,用于将多个Etherscan样区块链Explorer API与对AI助手的模型上下文协议(MCP)支持。

  • deemkeen
  • 用电源组合控制您的MBOT2:MQTT+MCP+LLM

    Reviews

    5 (1)
    Avatar
    user_gQ8Mx0Lu
    2025-04-16

    As a dedicated user of MCP Servers by pathintegral-institute, I can't recommend this product enough! Their servers are incredibly reliable, boasting excellent uptime and seamless integration. The user experience is superb, and setting up is straightforward thanks to their comprehensive welcome information. Check them out at https://mcp.so/server/mcp-servers/pathintegral-institute for top-tier server solutions!