Skip to main content
Glama

MCP Shell Server

by mkusaka

MCP Shell Server

A server that uses the Model Context Protocol (MCP) to execute shell commands. It functions as a bridge that allows AI agents to safely execute shell commands.

Features

  • Execute shell commands (single-line and multi-line support)
  • Support for various shells (bash, zsh, fish, powershell, cmd, etc.)
  • Detailed error handling and logging
  • MCP Inspector compatible

Installation

From npm (as a user)

# Using npm npm install -g @mkusaka/mcp-shell-server # Using yarn yarn global add @mkusaka/mcp-shell-server # Using pnpm pnpm add -g @mkusaka/mcp-shell-server

From source (for development)

# Clone the repository git clone https://github.com/mkusaka/mcp-shell-server.git cd mcp-shell-server # Install dependencies pnpm install # Build the project pnpm build

MCP Configuration

Cursor Configuration

Add the following to your Cursor configuration file (~/.cursor/config.json):

{ "mcpServers": { "shell": { "command": "npx", "args": ["-y", "@mkusaka/mcp-shell-server"] } } }

Cline Integration

Cline is a VS Code extension that allows you to use MCP servers with Claude AI. To set up this MCP shell server with Cline:

  1. Open your Cline MCP settings file:
    • macOS: ~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
    • Windows: %APPDATA%/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
    • Linux: ~/.config/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
  2. Add the shell server MCP configuration:
    { "mcpServers": { "shell": { "command": "npx", "args": ["-y", "@mkusaka/mcp-shell-server"], "disabled": false, "autoApprove": [] } } }
    Alternatively, if you want to use a locally installed package:
    { "mcpServers": { "shell": { "command": "node", "args": ["/path/to/mcp-shell-server/dist/index.js"], "disabled": false, "autoApprove": [] } } }

Rule Configuration

Add the following to your AI assistant's rules or prompt:

You have MCP Shell tools at your disposal. Follow these rules regarding Shell tool usage: 1. ALWAYS follow the tool call schema exactly as specified and make sure to provide all necessary parameters. 2. **NEVER refer to tool names when speaking to me.** For example, instead of saying 'I need to use the shell_exec tool to run this command', just say 'I'll run that command for you'. 3. Only use Shell tools when they are necessary. If my task is general or you already know the answer, just respond without calling tools. 4. When I ask you to execute shell commands, use the appropriate tool to: - Run single-line commands - Run multi-line commands (using heredoc syntax when appropriate) - Execute file operations, git commands, or system utilities - Provide system information when relevant 5. Always be careful with shell commands that might modify the system, and explain what the command will do before executing it. 6. If a shell command produces an error, explain what went wrong in simple terms and suggest ways to fix it.

Usage

Direct Execution

node dist/index.js # or as an executable ./dist/index.js

Development Mode

pnpm dev

Testing with MCP Inspector

pnpm inspect

Command Line Arguments

-s, --shell <shell> Specify the path to the shell to use -w, --working-dir <directory> Specify the working directory for command execution -h, --help Display help message -V, --version Display version information

Tool Reference

shell_exec

Executes commands in the specified shell.

Parameters:

  • command (string, required): The shell command to execute
  • workingDir (string, optional): The working directory to execute the command in. Must be under $HOME.

Resource Reference

The server provides the following system information as resources:

hostname

Returns the hostname of the system.

URI: hostname://

platform

Returns the operating system platform.

URI: platform://

shell

Returns the shell path being used by the server.

URI: shell://

username

Returns the current username.

URI: username://

system-info

Returns comprehensive system information in JSON format, including:

  • hostname
  • platform
  • shell
  • username
  • CPU count
  • Total memory
  • Free memory
  • System uptime

Usage Examples

Basic Command Execution
{ "name": "shell_exec", "parameters": { "command": "echo Hello, World!" } }
Multi-line Command (Heredoc) Execution
{ "name": "shell_exec", "parameters": { "command": "cat << EOF | grep 'example'\nThis is an example text.\nAnother line without the keyword.\nEOF" } }

Development

Project Structure

src/ ├── index.ts # Main entry point └── shell-server/ ├── index.ts # Shell server implementation └── lib/ └── logger.ts # Logging configuration

Logging

Logs are written to the mcp-shell.log file.

License

MIT

Install Server
A
security – no known vulnerabilities
A
license - permissive license
A
quality - confirmed to work

local-only server

The server can only run on the client's local machine because it depends on local resources.

A server that uses the Model Context Protocol (MCP) to allow AI agents to safely execute shell commands on a host system.

  1. Features
    1. Installation
      1. From npm (as a user)
      2. From source (for development)
    2. MCP Configuration
      1. Cursor Configuration
      2. Cline Integration
      3. Rule Configuration
    3. Usage
      1. Direct Execution
      2. Development Mode
      3. Testing with MCP Inspector
    4. Command Line Arguments
      1. Tool Reference
        1. shell_exec
      2. Resource Reference
        1. hostname
        2. platform
        3. shell
        4. username
        5. system-info
        6. Usage Examples
      3. Development
        1. Project Structure
        2. Logging
      4. License

        Related MCP Servers

        • A
          security
          A
          license
          A
          quality
          A secure shell command execution server implementing the Model Context Protocol (MCP). This server allows remote execution of whitelisted shell commands with support for stdin input.
          Last updated -
          1
          113
          Python
          MIT License
          • Apple
        • A
          security
          A
          license
          A
          quality
          A server that enables AI assistants to execute terminal commands and retrieve outputs via the Model Context Protocol (MCP).
          Last updated -
          3
          13
          Python
          MIT License
          • Apple
          • Linux
        • A
          security
          F
          license
          A
          quality
          An MCP server that allows AI models to execute system commands on local machines or remote hosts via SSH, supporting persistent sessions and environment variables.
          Last updated -
          1
          248
          17
          TypeScript
        • A
          security
          F
          license
          A
          quality
          A Model Context Protocol (MCP) server that enables AI assistants to perform comprehensive file operations including finding, reading, writing, editing, searching, moving, and copying files with security validations.
          Last updated -
          7
          TypeScript

        View all related MCP servers

        MCP directory API

        We provide all the information about MCP servers via our MCP API.

        curl -X GET 'https://glama.ai/api/mcp/v1/servers/mkusaka/mcp-shell-server'

        If you have feedback or need assistance with the MCP directory API, please join our Discord server