Skip to main content
Glama
shell-mcp

shell-mcp

by dcvetkovic88

shell-mcp

A local MCP server that lets an AI assistant run commands in your own shell on macOS, Windows and Linux.

WARNING

This gives an AI model the same power over your computer as you have in a terminal. It can read, change and delete files, install or remove software, change settings, use your logged-in accounts (git, cloud CLIs, SSH) and send data over the network. There is no undo and no sandbox. Read Before you install first.

Contents

Related MCP server: Command Center

The problem it solves

Desktop AI assistants can usually explain which command to run, but can't run it. You copy the command into a terminal, copy the output back, and repeat.

Servers that do run commands often support a single operating system. They also start with a reduced environment, so git, node or gh work in your terminal but fail with "command not found" in the assistant.

shell-mcp runs the command and returns the exit code, stdout and stderr:

  • The same tools work on macOS, Windows and Linux.

  • It supports bash, zsh, sh, fish, cmd and PowerShell.

  • It finds your tools, by loading your login profile on macOS/Linux and reading the registry on Windows.

  • Commands have a time limit, and when it passes their child processes are stopped too.

  • Long output is shortened in the middle so it doesn't flood the conversation.

Before you install

What it can change

  • Any file your user account can write to, including deleting it.

  • Installed software, system settings and running processes, within your account's rights.

  • Anything your account is signed in to: git pushes, cloud resources, databases, SSH hosts.

What it can see

  • Any file you can read, and environment variables, including tokens and passwords stored there.

  • Command output is passed to the AI client, which normally sends it to the model provider.

Risks to know about

  • The model can make mistakes, such as a wrong path in a delete command.

  • A web page, file or email the model reads can contain instructions meant to trick it into running something harmful (prompt injection).

  • The server keeps no command log and can't roll anything back.

How to use it safely

  1. Keep tool approval on in your client and read each command before allowing it. Avoid "always allow" for run_command.

  2. Never run it as root or Administrator.

  3. Keep backups, and commit your work to git before letting the model change it.

  4. For untrusted content or risky work, run it in a virtual machine or container.

  5. Don't rely on SHELL_MCP_DENY for protection. It is a plain text match and easy to get around.

The server communicates over stdio with the client that launched it and opens no network port. The commands it runs can use the network.

Built with

Component

Used for

Python 3.10+

Language

MCP Python SDK (mcp)

Protocol and stdio transport; the only direct runtime dependency

uv

Installing and running

Hatchling

Package build

pytest and GitHub Actions

Tests on Windows, macOS and Linux

Installation

1. Install uv. See the uv installation guide. It downloads a suitable Python if you don't have one.

2. Get the code and its dependencies.

git clone https://github.com/dcvetkovic88/shell-mcp.git
cd shell-mcp
uv sync

3. Connect a client. See Where to use it.

To update later, run git pull and uv sync, then restart the client. To uninstall, remove the shell entry from the client's configuration and delete the folder.

Where to use it

It works with MCP clients that can start a local (stdio) server. It does not work with browser-only assistants, which can't start a program on your computer.

Replace /path/to/shell-mcp below with your folder. On Windows use forward slashes, for example C:/dev/shell-mcp.

Claude Desktop

uv run shell-mcp install

This adds a shell entry to the config file, keeps your other settings, and saves the previous version with a .bak ending. Restart the app afterwards.

To do it by hand, edit the config file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

  • Windows: %APPDATA%\Claude\claude_desktop_config.json

{
  "mcpServers": {
    "shell": {
      "command": "uv",
      "args": ["--directory", "/path/to/shell-mcp", "run", "shell-mcp"]
    }
  }
}

Claude Code

claude mcp add shell -- uv --directory /path/to/shell-mcp run shell-mcp

Cursor

Put the same JSON as for Claude Desktop in ~/.cursor/mcp.json (all projects) or .cursor/mcp.json (one project).

VS Code

Put this in .vscode/mcp.json:

{
  "servers": {
    "shell": {
      "type": "stdio",
      "command": "uv",
      "args": ["--directory", "/path/to/shell-mcp", "run", "shell-mcp"]
    }
  }
}

Other clients

Use the same command and args wherever the client defines local MCP servers.

Tools

Tool

What it does

Arguments

run_command

Runs a command and returns exit code, stdout, stderr and duration

command, and optionally shell, cwd, timeout, env, stdin

change_directory

Sets the working directory for later commands

path

get_cwd

Returns the current working directory

none

system_info

Shows OS, architecture, user, default shell and installed shells

none

check_tools

Shows versions and locations of git, gh, node, npm, python, uv, docker and others, plus PATH

none

get_env

Returns one variable, or lists all with secret-looking values hidden

optional name

run_command arguments:

Argument

Meaning

command

Command line to run. Pipes, && and redirects follow the chosen shell's rules.

shell

default, bash, zsh, sh, fish, cmd, powershell or pwsh. default is your login shell on macOS/Linux and cmd on Windows.

cwd

Working directory for this command

timeout

Time limit in seconds

env

Extra environment variables

stdin

Text passed to the command's input

Commands can't be interactive, so prompts and editors such as vim won't work.

get_env shows the full value when asked for a variable by name, even if it looks like a secret.

Examples

Things you can ask the assistant:

  • "Which version of Node and Python do I have?"

  • "Show the git status of ~/projects/shop and summarize the changes."

  • "Run the tests in this folder and explain the failures."

  • "Find the ten largest files in Downloads. Don't delete anything."

  • "Use PowerShell to list the services that are running."

What the tool calls look like:

{ "command": "git status --short", "cwd": "~/projects/shop" }
{ "command": "npm run build", "cwd": "~/projects/shop", "timeout": 600 }
{ "command": "Get-Service | Where-Object Status -eq 'Running'", "shell": "powershell" }
{ "command": "wc -l", "shell": "bash", "stdin": "one\ntwo\n" }

A result:

exit_code: 0
cwd: /Users/you/projects/shop
duration: 0.12s
--- stdout ---
 M src/cart.py
?? notes.txt

Configuration

Set these environment variables in the client's env block. All are optional.

Variable

Default

Meaning

SHELL_MCP_CWD

home folder

Starting working directory

SHELL_MCP_TIMEOUT

60

Default time limit in seconds

SHELL_MCP_MAX_TIMEOUT

1200

Highest time limit a call may ask for

SHELL_MCP_MAX_OUTPUT

50000

Characters kept from each of stdout and stderr

SHELL_MCP_DENY

empty

Comma-separated texts; commands containing one are refused

{
  "mcpServers": {
    "shell": {
      "command": "uv",
      "args": ["--directory", "/path/to/shell-mcp", "run", "shell-mcp"],
      "env": {
        "SHELL_MCP_CWD": "~/projects",
        "SHELL_MCP_TIMEOUT": "120",
        "SHELL_MCP_DENY": "sudo ,mkfs,shutdown"
      }
    }
  }
}

Platform notes

macOS and Linux: bash, zsh and sh run as login shells, so PATH additions from your login profile apply. Settings that are only in .zshrc or .bashrc may not load.

Windows:

  • User and system variables are read from the registry on each call. Common folders for Git, GitHub CLI, Node, scoop, VS Code and PowerShell 7 are added to PATH.

  • bash means Git Bash when it is installed in a standard location. Otherwise it is whichever bash is on PATH, which is often WSL.

  • powershell is Windows PowerShell 5 and pwsh is PowerShell 7. Each falls back to the other.

Troubleshooting

Problem

What to try

The client can't start the server

Use the full path of uv as command (find it with which uv, or where uv on Windows)

"command not found"

Ask the assistant to run check_tools and look at the PATH it reports

A command is stopped too early

Pass a higher timeout or raise SHELL_MCP_TIMEOUT. The client may have its own limit.

A command waits and then times out

It probably asks for input. Use a flag such as -y, or pass stdin.

The tools don't appear

Restart the client completely and check its MCP logs

Development

src/shell_mcp/__init__.py   server and tools
src/shell_mcp/windows.py    Windows environment and Git Bash lookup
src/shell_mcp/install.py    Claude Desktop installer
tests/                      tests

Run the tests:

uv run pytest

Try the server in the MCP Inspector (needs Node):

npx @modelcontextprotocol/inspector uv --directory . run shell-mcp

License

MIT

Tool Schema Changelog

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

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables safe execution of terminal commands across different shells (bash, cmd, PowerShell) with configurable timeouts, working directories, and resource limits for command-line operations through AI assistants.
      -
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI coding agents to keep persistent shell sessions open across turns—running tests, tailing logs, driving REPLs and holding SSH connections—alongside text-file tools, all bounded by person-controlled folder limits and a command blocklist. Runs locally on macOS, Linux and Windows with no telemetry or remote calls.
      Apache 2.0
    • A
      license
      A
      quality
      B
      maintenance
      Enables AI agents to execute shell commands without a shell and receive structured JSON output, with parsers for dozens of commands, row filtering/sorting, large-result pagination, and pre-execution guards for allowed commands, paths, and secrets.
      3
      75 npm
      12
      MIT
    • A
      license
      B
      quality
      B
      maintenance
      Enables LLMs to execute shell commands with configurable security controls, foreground/background task management, timeouts, and output truncation over local or HTTP transports.
      4
      MIT