mcp-wezterm

blaakstone/mcp-wezterm

3.1

If you are the rightful owner of mcp-wezterm and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.

MCP WezTerm is a secure and configurable Model Context Protocol server that integrates with WezTerm for robust output capture and session management.

Tools
9
Resources
0
Prompts
0

mcp-wezterm

Serveur MCP WezTerm (MCP stdio) avec sécurité par profils et ALLOWLIST/DENYLIST globales, confirmation GUI zenity pour les opérations sensibles, et capture de sortie robuste via WezTerm.

Installation

git clone git@github.com:zyce/mcp-wezterm.git
cd mcp-wezterm
poetry install

Prérequis : Python 3.13+

Utilisation (dev)

# Lancer le serveur MCP (stdio)
poetry run python -m mcp_wezterm.server

Configuration (config.yaml)

Fichier YAML: config.yaml (dans le dépôt, ou via l'env CONFIG)

ALLOWLIST: [
  "ls", "cat", "grep", "df", "du",
  "hostnamectl", "systemctl status", "journalctl -n",
  "ip addr", "ip route", "curl", "wget", "ping",
]
DENYLIST: [
  "rm -rf /", "mkfs", "dd if=/dev", ":(){:|:&};:",
  "systemctl restart", "systemctl stop", "shutdown", "reboot"
]

profiles:
  read_only:
    ENABLE_WRITE_COMMANDS: false
    DENYLIST: []
    ALLOWED_PATHS: ["/home", "/etc", "/var/log"]
    DEFAULT_TIMEOUT_S: 60
  ops:
    ENABLE_WRITE_COMMANDS: true
    CONFIRM_BEFORE_EXEC: true
    CONFIRM_METHOD: zenity
    DENYLIST: []
    ALLOWED_PATHS: ["/"]
    DEFAULT_TIMEOUT_S: 60

Politique

  • ALLOWLIST globale: commandes sûres. read_only n’exécute que celles‑ci. ops les exécute sans confirmation.
  • Hors ALLOWLIST: en ops, confirmation zenity avant exécution.
  • DENYLIST globale: interdites pour tous les profils.
  • Chemins: read_only limité à /home, /etc, /var/log; ops autorisé partout (/).

Dépendance GUI: installer zenity pour la confirmation (GTK, thème système respecté).

Exemple .cursor/mcp.json:

{
  "mcpServers": {
    "mcp-wezterm": {
      "command": "/abs/path/.venv/bin/python",
      "args": ["-m", "mcp_wezterm.server", "--transport", "stdio"],
      "env": {
        "CONFIG": "/abs/path/config.yaml",
        "LOG_FILE": "/abs/path/.runtime/mcp-wezterm.log",
        "STATE_FILE": "/abs/path/.runtime/sessions.json"
      }
    }
  }
}

Outils MCP

  • start_session(host?, cwd?, env?, profile?) → {session_id, wezterm_pane_id}
  • send_input(session_id, data) → {ok}
  • exec_once(command, host?, timeout_s?, cwd?, profile?) → {stdout, stderr, exit_code, wezterm_pane_id}
  • read_output(session_id, max_bytes?) → {stdout}
  • focus_ui(session_id) → {ok}
  • kill_session(session_id) → {ok}
  • list_sessions() → {sessions:[...]}
  • attach_session(session_id) → {ok}
  • resume_last() → {session_id, wezterm_pane_id}

Persistance sessions

  • Fichier: STATE_FILE (env), ex: .runtime/sessions.json
  • Réconciliation au démarrage avec les panes WezTerm existants

Note: le fichier d’état sessions.json n’est pas versionné (cf. .gitignore). En production, il réside typiquement sous ~/.mcp-tools/mcp-wezterm/state/sessions.json et peut être redéfini via STATE_FILE dans mcp.json.

Profils

Les profils sont définis dans config.yaml (section profiles).

Tests et qualité du code

poetry run pytest

Créé par zyce zyce@pve.local le 12-08-2025