MCP Shell Server

MCP Shell Server

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

mkusaka

Developer Tools
Visit Server

Tools

shell_exec

Executes commands in the specified shell

README

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"]
    }
  }
}

Rule Configuration

Add the following to your Cursor rules file:

You have tools at your disposal to solve the coding task. Follow these rules regarding tool calls:
1. ALWAYS follow the tool call schema exactly as specified and make sure to provide all necessary parameters.
2. The conversation may reference tools that are no longer available. NEVER call tools that are not explicitly provided.
3. **NEVER refer to tool names when speaking to the USER.** For example, instead of saying 'I need to use the shell_exec tool to execute your command', just say 'I will execute your command'.
4. Only calls tools when they are necessary. If the USER's task is general or you already know the answer, just respond without calling tools.
5. Before calling each tool, first explain to the USER why you are calling 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
-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

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

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
MCP Package Docs Server

MCP Package Docs Server

Facilitates LLMs to efficiently access and fetch structured documentation for packages in Go, Python, and NPM, enhancing software development with multi-language support and performance optimization.

Featured
Local
TypeScript
Claude Code MCP

Claude Code MCP

An implementation of Claude Code as a Model Context Protocol server that enables using Claude's software engineering capabilities (code generation, editing, reviewing, and file operations) through the standardized MCP interface.

Featured
Local
JavaScript
@kazuph/mcp-taskmanager

@kazuph/mcp-taskmanager

Model Context Protocol server for Task Management. This allows Claude Desktop (or any MCP client) to manage and execute tasks in a queue-based system.

Featured
Local
JavaScript
Linear MCP Server

Linear MCP Server

Enables interaction with Linear's API for managing issues, teams, and projects programmatically through the Model Context Protocol.

Featured
JavaScript
mermaid-mcp-server

mermaid-mcp-server

A Model Context Protocol (MCP) server that converts Mermaid diagrams to PNG images.

Featured
JavaScript
Jira-Context-MCP

Jira-Context-MCP

MCP server to provide Jira Tickets information to AI coding agents like Cursor

Featured
TypeScript
Linear MCP Server

Linear MCP Server

A Model Context Protocol server that integrates with Linear's issue tracking system, allowing LLMs to create, update, search, and comment on Linear issues through natural language interactions.

Featured
JavaScript
Sequential Thinking MCP Server

Sequential Thinking MCP Server

This server facilitates structured problem-solving by breaking down complex issues into sequential steps, supporting revisions, and enabling multiple solution paths through full MCP integration.

Featured
Python