Skip to main content
Glama
marttinm

windows-terminal-mcp

by marttinm

windows-terminal-mcp

Ein MCP (Model Context Protocol)-Server, der es jedem LLM ermöglicht, Befehle in einem Windows-Terminal auszuführen – einschließlich lokaler Shells und Remote-SSH-Verbindungen.

Funktionen

  • Ausführen von Befehlen über cmd, powershell oder bash (Git Bash)

  • Ausführen von Remote-Befehlen über SSH mit schlüsselbasierter Authentifizierung

  • 3-stufiges Sicherheitsmodell (sicher / bestätigen / blockiert)

  • Konfigurierbares Timeout pro Befehl

  • Funktioniert mit Claude Desktop und jedem MCP-kompatiblen Client

Related MCP server: Windows CLI MCP Server

Installation

git clone https://github.com/marttinm/windows-terminal-mcp.git
cd windows-terminal-mcp
pip install -e .

Erfordert Python 3.11+ unter Windows.

Konfiguration

Fügen Sie den Server zu Ihrer Claude Desktop-Konfigurationsdatei hinzu (%APPDATA%\Claude\claude_desktop_config.json):

{
  "mcpServers": {
    "windows-terminal": {
      "command": "cmd",
      "args": ["/c", "python", "-m", "windows_terminal_mcp.server"]
    }
  }
}

Oder verweisen Sie direkt auf das Skript:

{
  "mcpServers": {
    "windows-terminal": {
      "command": "cmd",
      "args": ["/c", "python", "C:/path/to/windows-terminal-mcp/src/windows_terminal_mcp/server.py"]
    }
  }
}

Tool: execute_command

Parameter

Parameter

Typ

Standard

Beschreibung

command

string

erforderlich

Auszuführender Befehl. Für SSH: user@host command

shell

string

cmd

Shell: cmd, powershell, bash, ssh

working_dir

string

—

Arbeitsverzeichnis (nur lokale Befehle)

timeout_ms

integer

120000

Timeout in Millisekunden

ssh_key

string

—

Pfad zum privaten SSH-Schlüssel (z. B. ~/.ssh/id_rsa)

Antwort

{
  "stdout": "...",
  "stderr": "...",
  "exit_code": 0,
  "execution_time": 0.42
}

Anwendungsbeispiele

Lokale Befehle

Run: dir C:\Users
Shell: cmd

Run: Get-Process | Select-Object -First 5
Shell: powershell

Run: git status
Shell: bash

SSH-Befehle

Run: ubuntu@192.168.1.10 "df -h && uptime"
Shell: ssh
SSH key: ~/.ssh/id_rsa
Run: ubuntu@192.168.1.10 "docker ps"
Shell: ssh
SSH key: ~/.ssh/my_key
Timeout: 30000

Sicherheit

Befehle werden in drei Stufen klassifiziert:

Sicher — wird direkt ausgeführt
echo, dir, type, git, npm, node, python, pip, curl und die meisten schreibgeschützten Befehle.

Gefährlich — Claude warnt vor der Ausführung
del, rmdir, rm, taskkill, net stop, net start, sc delete, reg add usw.

Blockiert — wird immer abgelehnt
format, del /s /q, rd /s /q, reg delete, regedit, shutdown, net user, rm -rf, mkfs, fdisk und ähnliche destruktive Operationen.

Entwicklung

Projektstruktur

windows-terminal-mcp/
├── src/windows_terminal_mcp/
│   ├── __init__.py
│   ├── server.py      # MCP server (main entry point)
│   ├── executor.py    # subprocess execution
│   ├── main.py        # simple stdin/stdout handler
│   └── security.py    # command safety checks
├── tests/
│   └── test_windows_terminal_mcp.py
├── pyproject.toml
├── LICENSE
└── README.md

Tests ausführen

pip install pytest
pytest tests/ -v

Als Python-Modul verwenden

from windows_terminal_mcp.server import execute_command

result = execute_command("echo hello", shell="cmd")
print(result)
# {'stdout': 'hello\n', 'stderr': '', 'exit_code': 0, 'execution_time': 0.02}

result = execute_command(
    "ubuntu@192.168.1.10 uptime",
    shell="ssh",
    ssh_key="~/.ssh/id_rsa",
    timeout_ms=10000,
)
print(result)

Changelog

v0.2.0

  • SSH-Unterstützung mit schlüsselbasierter Authentifizierung hinzugefügt

  • SSH-Befehlskonstruktion korrigiert (Host und Remote-Befehl werden als separate Argumente übergeben)

  • ~-Erweiterung in SSH-Schlüsselpfaden unter Windows korrigiert

  • stdin-Vererbung korrigiert, die dazu führte, dass SSH innerhalb des MCP-Serverprozesses hängen blieb

v0.1.0

  • Grundlegende Befehlsausführung über cmd, powershell, bash

  • Erfassung von stdout/stderr/exit_code

  • 3-stufiges Sicherheitsmodell

  • Unit-Tests

Lizenz

MIT — siehe LICENSE

Related MCP Connectors

Related MCP Servers

  • A
    license
    B
    quality
    F
    maintenance
    A Model Context Protocol server that provides secure command-line access to Windows systems, allowing MCP clients like Claude Desktop to safely execute commands in PowerShell, CMD, and Git Bash shells with configurable security controls.
    9
    959 npm
    268
    MIT
  • F
    license
    A
    quality
    D
    maintenance
    A local Model Context Protocol server that allows LLMs to securely execute shell commands on remote Linux and Windows systems via SSH connections.
    6
    6 npm
    2
    -
  • A
    license
    B
    quality
    A
    maintenance
    A secure MCP server for shell operations, terminal management, and process control, enabling AI assistants to safely execute commands and manage interactive sessions.
    13
    264 npm
    6
    MIT