MCP Shell Server

MIT License
59
1
  • Linux
  • Apple

Integrations

  • Enables execution of Git commands through the shell interface, allowing AI agents to perform version control operations like commits, pulls, pushes, and branch management.

  • Supports running npm commands through the shell interface, enabling package management operations like installing, updating, and removing JavaScript packages.

  • Facilitates running pnpm commands through the shell interface, offering fast, disk-space efficient package management for JavaScript projects.

Servidor Shell MCP

Un servidor que utiliza el Protocolo de Contexto de Modelo (MCP) para ejecutar comandos de shell. Funciona como un puente que permite a los agentes de IA ejecutar comandos de shell de forma segura.

Características

  • Ejecutar comandos de shell (soporte de una sola línea y de varias líneas)
  • Soporte para varios shells (bash, zsh, fish, powershell, cmd, etc.)
  • Manejo y registro detallado de errores
  • Compatible con MCP Inspector

Instalación

Desde npm (como usuario)

# 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

Desde la fuente (para desarrollo)

# 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

Configuración de MCP

Configuración del cursor

Agregue lo siguiente a su archivo de configuración de Cursor ( ~/.cursor/config.json ):

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

Configuración de reglas

Agregue lo siguiente a su archivo de reglas de cursor:

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.

Uso

Ejecución directa

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

Modo de desarrollo

pnpm dev

Pruebas con MCP Inspector

pnpm inspect

Argumentos de la línea de comandos

-s, --shell <shell> Specify the path to the shell to use -h, --help Display help message -V, --version Display version information

Referencia de herramientas

shell_exec

Ejecuta comandos en el shell especificado.

Parámetros:

  • command (cadena, obligatorio): el comando de shell a ejecutar

Referencia de recursos

El servidor proporciona la siguiente información del sistema como recursos:

nombre de host

Devuelve el nombre de host del sistema.

URI: hostname://

plataforma

Devuelve la plataforma del sistema operativo.

URI: platform://

caparazón

Devuelve la ruta del shell que utiliza el servidor.

URI: shell://

nombre de usuario

Devuelve el nombre de usuario actual.

URI: username://

información del sistema

Devuelve información completa del sistema en formato JSON, que incluye:

  • nombre de host
  • plataforma
  • caparazón
  • nombre de usuario
  • Número de CPU
  • Memoria total
  • Memoria libre
  • Tiempo de actividad del sistema

Ejemplos de uso

Ejecución de comandos básicos

{ "name": "shell_exec", "parameters": { "command": "echo Hello, World!" } }

Ejecución de comandos multilínea (Heredoc)

{ "name": "shell_exec", "parameters": { "command": "cat << EOF | grep 'example'\nThis is an example text.\nAnother line without the keyword.\nEOF" } }

Desarrollo

Estructura del proyecto

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

Explotación florestal

Los registros se escriben en el archivo mcp-shell.log .

Licencia

Instituto Tecnológico de Massachusetts (MIT)

You must be authenticated.

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

Un servidor que utiliza el Protocolo de contexto de modelo (MCP) para permitir que los agentes de IA ejecuten de forma segura comandos de shell en un sistema host.

  1. Features
    1. Installation
      1. From npm (as a user)
      2. From source (for development)
    2. MCP Configuration
      1. Cursor Configuration
      2. 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
        ID: t1x2r819sf