Metadata-Version: 2.5
Name: mcp-win-stdio-terminal
Version: 0.5.7
Summary: Windows-optimized Workspace Terminal MCP server: multi-shell execution, session-isolated workspace context, sequential steps, and bounded process lifecycle.
Author: Mohan Kumar Indala
License-Expression: MIT
Keywords: ai,bash,claude,cmd,llm,mcp,powershell,pwsh,shell,terminal,windows,wsl
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Win32 (MS Windows)
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Classifier: Topic :: Software Development :: Build Tools
Requires-Python: >=3.11
Requires-Dist: mcp-win-stdio>=0.5.7
Requires-Dist: mcp>=2.0.0
Requires-Dist: typing-extensions>=4.6.0
Description-Content-Type: text/markdown

# mcp-win-stdio-terminal

Workspace Terminal MCP server for **mcp-win-stdio (`mws`)**.

Provides session-isolated local workspace command execution across **PowerShell**, **pwsh**, **cmd**, **Git Bash**, and **WSL** with bounded foreground execution, multi-step pipelines, and MWS Tunnel security integration.

## Installation

```bash
pip install mcp-win-stdio-terminal
# or via mws CLI:
mws install terminal
```

## Shell Support

- **Windows**: `powershell` (default), `pwsh`, `cmd`, `bash` (Git Bash), `wsl`
- **POSIX (Linux/macOS)**: `bash` (default), `sh`, `zsh`, `pwsh`

## Tools

### `terminal_configure`

Establish, update, or clear the active terminal configuration for your authenticated MWS session.

```json
{
  "type": "powershell",
  "workspace": "Z:/projects/youtube",
  "env": { "PYTHONUTF8": "1" }
}
```

- `type`: Optional shell runtime (`powershell`, `pwsh`, `cmd`, `bash`, `wsl`).
- `workspace`: Workspace directory path (validated to exist and be a directory; never silently falls back to process cwd).
- `env`: Optional environment variable overrides (values are never echoed in responses or audit logs).
- `clear`: Set `true` to clear the active session terminal configuration.

### `terminal_run`

Execute a single command or a sequential `steps` list in the session's configured workspace, shell, and environment.

**Single command:**

```json
{
  "command": "pytest",
  "args": ["tests/", "-q"]
}
```

**Multi-step execution:**

```json
{
  "steps": [
    { "command": "ruff", "args": ["check", "."] },
    { "command": "pytest", "args": ["tests/", "-q"] },
    { "command": "python", "args": ["scripts/build_all.py"] }
  ],
  "continue_on_error": false
}
```

- Uses direct process execution (`shell: false`) with argument arrays by default to preserve argument boundaries and avoid shell injection.
- Set `shell: true` only when shell-specific syntax (pipes, redirection, shell builtins) is needed.
- Stops on the first failed step by default (`continue_on_error: false`) and reports remaining steps as `skipped`.
- Enforces bounded timeouts (`timeout_seconds`, default 120s, max 600s) and per-stream output caps (`max_output_bytes`, default 64 KiB, max 1 MiB) with explicit truncation metadata (`truncated`, `max_output_bytes`, `original_bytes`, `truncation_notice`) and full process-tree cleanup on timeout.
- **Process Model & Limitations**: Each `terminal_run` call executes in a fresh foreground process (`cd` and shell variables do not persist across separate `terminal_run` calls; use `steps` for short multi-command workflows). Long-running development servers or file watchers should not be launched as blocking `terminal_run` commands.

## Environment Precedence

1. **Inherited process environment** (including system `PATH`) is preserved by default.
2. **Session-level overrides** from `terminal_configure(env=...)` overlay the inherited environment. Supplying a new `env` dictionary replaces previous session overrides; passing `{}` clears them.
3. **Per-call overrides** from `terminal_run(env=...)` merge on top of session-level overrides for that call only.

## Workspace Aliases

Sessions can register named workspace aliases without mutating the active workspace:

- `terminal_workspace_add(alias, path, select=False)`
- `terminal_workspace_list()`
- `terminal_workspace_remove(alias)`
- `terminal_workspace_select(alias)`
- `terminal_run(command="...", workspace="frontend")` (runs in the alias for that call only)

## Security & Session Isolation

- **Session Isolation**: Active terminal configuration is stored in the MWS gateway's `SessionContext`, keyed by transport-derived session identity. Child `terminal` processes are stateless and never share configuration across agents or tunnel clients.
- **Permission Ceiling**: Arbitrary command execution is classified as high-risk/mutating. Both `terminal_configure` and `terminal_run` are **blocked in `read_only` mode** and **blocked on unauthenticated (`--auth none`) tunnels** by default.
- **Scope Filtering**: Respects `ToolScopeFilter` (`--allow-servers`, `--disallow-servers`, `--allow-tools`, `--disallow-tools`).
- **Workspace Boundaries**: Optional `MWS_TERMINAL_ALLOWED_ROOTS` environment variable restricts allowed workspace directories.
- **Secret Redaction**: Environment variable values are never returned by `terminal_configure` or `manage_context`, and are redacted from audit logs and diagnostics.

## Installation & CLI Usage

```powershell
pip install mcp-win-stdio-terminal
```

```powershell
mws guide terminal     # Print client configuration snippets
mws run terminal       # Launch server over stdio via mws
mws-terminal           # Standalone stdio server
mws-terminal doctor    # Check available shells and health
```
