Shell Command MCP server

Secure shell command execution server that allows running system commands in a controlled environment through an allowlist system, returning results in YAML format.
Back to servers
Provider
EGOIST
Release date
Apr 08, 2025
Language
TypeScript
Package
Stats
223 downloads
26 stars

This MCP server allows you to execute shell commands through the Model Context Protocol, providing a way to run terminal commands programmatically. It includes safety features to restrict which commands can be executed.

Installation

You can run the shell-command-mcp server directly using npx without installing it first:

npx -y shell-command-mcp

Configuration Options

Setting Up Allowed Commands

For security reasons, you need to specify which shell commands are permitted to run. This is done using the ALLOWED_COMMANDS environment variable:

ALLOWED_COMMANDS="cat,ls,echo" npx -y shell-command-mcp

In this example, only the commands cat, ls, and echo will be allowed to execute.

Security Warning

You can use * to allow any command, but this is potentially dangerous as it gives unrestricted access to run any shell command:

ALLOWED_COMMANDS="*" npx -y shell-command-mcp

Integration with JSON Configuration

If you're setting up multiple MCP servers, you can configure the shell-command MCP server in a JSON configuration file:

{
  "mcpServers": {
    "shell-command": {
      "command": "npx",
      "args": ["-y", "shell-command-mcp"],
      "env": {
        "ALLOWED_COMMANDS": "cat,ls,echo"
      }
    }
  }
}

This configuration specifies:

  • The server identifier: shell-command
  • The command to run: npx
  • Arguments: -y shell-command-mcp
  • Environment variables: restricting allowed commands to cat, ls, and echo

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later