Skip to main content
Glama
Shell MCP Server
by hdresearch

Shell MCP Server

A Node.js implementation of the Model Context Protocol (MCP) that provides secure shell command execution capabilities. This server allows AI models to execute shell commands in a controlled environment with built-in security measures. Easily integrates with Claude Desktop for connecting Claude with your shell.

Features

  • MCP-compliant server implementation

  • Secure command execution with blacklist protection

  • Command existence validation

  • Standard I/O based transport

  • Error handling and graceful shutdown

Related MCP server: MCP Shell Server

Installation

Run npx mcp-shell.

To add it to Claude Desktop, run npx mcp-shell config. Or add npx -y mcp-shell to your config manually.

Start (or restart) Claude Desktop and you should see the MCP tool listed on the landing page.

Security Features

The server implements several security measures:

  1. Command Blacklisting

    • Prevents execution of dangerous system commands

    • Blocks access to critical system modifications

    • Protects against file system destruction

    • Prevents privilege escalation

  2. Command Validation

    • Verifies command existence before execution

    • Validates against the blacklist

    • Returns clear error messages for invalid commands

Available Tools

The server provides one tool:

run_command

Executes a shell command and returns its output.

Input Schema:

{
  "type": "object",
  "properties": {
    "command": { "type": "string" }
  }
}

Response:

  • Success: Command output as plain text

  • Error: Error message as plain text

Blacklisted Commands

The following command categories are blocked for security:

  • File System Destruction Commands (rm, rmdir, del)

  • Disk/Filesystem Commands (format, mkfs, dd)

  • Permission/Ownership Commands (chmod, chown)

  • Privilege Escalation Commands (sudo, su)

  • Code Execution Commands (exec, eval)

  • System Communication Commands (write, wall)

  • System Control Commands (shutdown, reboot, init)

Error Handling

The server includes comprehensive error handling:

  • Command not found errors

  • Blacklisted command errors

  • Execution errors

  • MCP protocol errors

  • Graceful shutdown on SIGINT

Implementation Details

The server is built using:

  • Model Context Protocol SDK

  • StdioServerTransport for communication

  • execa for command execution

  • command-exists for command validation

Development

To modify the security settings, you can:

  1. Edit the BLACKLISTED_COMMANDS set to adjust blocked commands

  2. Modify the validateCommand function to add additional validation rules

  3. Enhance the command parsing logic in the CallToolRequestSchema handler

Available Tools

1 tool
run_commandC

Run a shell command

Inputs: command.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    C2.9/5.0

    Scored across 1 tool

    Disambiguation5/5

    With only one tool, there is no possibility of ambiguity or overlap between tools. The single tool 'run_command' has a clear and distinct purpose that cannot be confused with any other tool in this set.

    Naming Consistency5/5

    The naming is perfectly consistent as there is only one tool. It follows a clear verb_noun pattern ('run_command'), and with no other tools to compare against, there is no inconsistency in naming conventions.

    Tool Count2/5

    A single tool is too few for a server named 'Shell MCP Server', which implies broader shell-related functionality. This minimal set feels thin and under-scoped, as it only covers basic command execution without supporting common shell operations like listing files, checking processes, or managing environment variables.

    Completeness2/5

    The tool set is severely incomplete for a shell server. While 'run_command' covers arbitrary command execution, it lacks tools for specific shell tasks (e.g., file operations, process management, directory navigation), leaving significant gaps that will likely cause agent failures when trying to perform common shell workflows.

    Maintenance

    ActivityNo data
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      A Model Context Protocol server that allows LLMs to execute shell commands and receive their output in a controlled manner.
      7
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      A secure interface that enables language models to execute shell commands on the host operating system through the Model Context Protocol.
      1
      -
    • F
      license
      A
      quality
      D
      maintenance
      A local Model Context Protocol server that allows LLMs to securely execute shell commands on remote Linux and Windows systems via SSH connections.
      6
      10 npm
      2
      -
    • F
      license
      B
      quality
      D
      maintenance
      A Model Context Protocol server that enables LLM applications to safely execute shell commands with error handling and timeout settings.
      1
      -