# ag88/cmdshellmcp [Health: Active]

**Category:** 🖥️ Command Line  
**Repository:** https://github.com/ag88/cmdshellmcp  
**GitHub Stars:** 3  
**Views:** 0  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/ag88-cmdshellmcp

## Description
A constrained command and file-operation MCP server for AI agents. Limits command execution through an explicit allowlist, lets every tool be individually disabled, and supports automatically generated authentication tokens. Provides constrained Unix commands, file operations, patching, and URL fetching without exposing an unrestricted shell.

## Tools
Capabilities this server exposes over MCP:

- **command** — the command name, which must appear in the allowlist
- **args** — list of arguments/flags to pass to the command
- **file** — a relative path under `cwd`
- **text** — content to write
- **append** — if `true`, append instead of overwrite
- **newline** — append a trailing newline when `true`
- **script** — a `sed` editing expression or program, such as `s/old/new/g`,
- **diff** — patch text, normally a unified diff
- **pnum** — number of leading path components to strip, corresponding to GNU

## Claude Desktop Quick Installation
No generated config for this server: it installs through its own setup steps.

The project's own setup steps (from https://github.com/ag88/cmdshellmcp), copied verbatim. Follow them in order; they are not an mcpServers config.

1. Install:

```sh
pip install fastmcp requests beautifulsoup4
```

2. Install:

```sh
pip install -r requirements.txt
```

3. Start the server:

```sh
python cmdshellmcp2.py --conf /path/to/cmdshellmcp.json --cwd /path/to/project
```

4. Start the server:

```sh
python cmdshellmcp2.py
```

5. Start the server:

```sh
python cmdshellmcp2.py --sse
```

6. Start the server:

```sh
python cmdshellmcp2.py --cwd /path/to/project
```

## Documentation

## What ag88/cmdshellmcp does

ag88/cmdshellmcp provides MCP tools for running selected Unix commands and manipulating files within a configured working directory. Its command interface accepts a command name and an argument list, but execution is limited to names in the configured `allowed_commands` list. The server also exposes file reading, writing, listing, copying, moving, renaming, deletion, directory creation, and directory removal operations.

Editing support includes `sed`-based text changes with numbered backups and unified-diff application through `patch`. A URL-fetching capability can retrieve HTTP content and optionally prettify HTML. These operations let an MCP client perform common project or workspace tasks without receiving a general-purpose shell tool.

## How it works

The Python implementation uses the `fastmcp` package. It listens on `127.0.0.1:8003` with streamable HTTP unless started with `--sse`, which selects the SSE transport. Both HTTP modes include CORS handling for browser-based MCP clients.

A JSON configuration file is mandatory. The server chooses an explicitly supplied `--conf` file first, then checks `/etc/cmdshellmcp.d/cmdshellmcp.json` and `/usr/local/python/cmdshellmcp/cmdshellmcp.json`. It does not automatically search the current directory, and startup fails if the selected file is missing, unreadable, invalid, or lacks a working directory supplied through either configuration or `--cwd`.

Path checks attempt to stop command arguments from escaping `cwd`, although the checks are heuristic rather than a complete security boundary. Authentication is enabled by default with a generated bearer token, or a fixed token can be set through configuration or `--auth`. Audit records can be written to standard output and optionally to a file.

## Setup and configuration

Install the Python dependencies in a virtual environment or directly into the target environment:

```bash
python -m venv .venv
source .venv/bin/activate
pip install fastmcp requests beautifulsoup4
```

GNU `sed` with its `--sandbox` option and `diff` must also be installed for `editFile`; those executables do not need to be included in `allowed_commands`.

Start the service with an explicit configuration and workspace:

```bash
python cmdshellmcp2.py --conf /path/to/cmdshellmcp.json --cwd /path/to/project
```

Important configuration keys include `host`, `port`, `cwd`, `allowed_commands`, `disableTools`, `auth`, `auditlog`, `quiet`, `shellnopathchk`, and `editdelbk`. `disableTools` takes exact, case-sensitive MCP tool names, allowing write or destructive operations to be omitted. Use `--sse` to select SSE transport.

## Tools and capabilities

- Run allowlisted commands with positional arguments and flags.
- Read, write, append, list, copy, move, rename, and delete files.
- Create and remove directories under the configured workspace.
- Apply `sed` edits with optional numbered backups.
- Apply unified patches with configurable leading path-component stripping.
- Fetch URLs and optionally format returned HTML.
- Enforce bearer authentication and emit audit logs.

## Limitations and notes

This server still provides remote command execution. Allowing commands such as `bash`, `sh`, `python`, `perl`, `sudo`, or `docker` can undermine the intended restrictions, and commands that write files may cause substantial damage. The path validation is pattern-based and may both block legitimate paths and miss unsafe behavior based on command semantics.

Run it as an unprivileged user in a disposable Docker container or virtual machine, restrict filesystem, network, credential, and device access, and review the default and configured command allowlists before use. Avoid `--noauth`, and do not expose the service to untrusted clients or untrusted models.

_Full upstream README: https://allmcps.com/mcp/ag88-cmdshellmcp/readme_

