Skip to main content

Add your description here

Project description

Interactive Terminal MCP

English | 中文

A Model Context Protocol (MCP) server that provides stateful, interactive terminal access.

Unlike standard command execution tools that run in isolation, this server allows LLMs to spawn persistent processes (like ssh, ipython, or gdb), maintain session context, and interact with shells via standard input/output streams.

Why use this MCP?

Standard command execution tools usually run in isolation (stateless). This MCP server allows for persistent sessions (stateful), which is critical for remote management and debugging tools.

Side-by-Side Comparison

Scenario Without this MCP (Stateless) With Interactive-Terminal-MCP (Stateful)
1. Remote SSH Session Context Lost: Must reconnect for every command.

> ssh user@host "cd /var/www" (exits)
> ssh user@host "ls" (starts in home dir)
Context Preserved: Maintains one connection.

1. spawn_process(["ssh", "user@host"])
2. send_command(id, "cd /var/www")
3. send_command(id, "ls") -> index.php
2. Interactive Debugging Unsupported: Cannot handle interactive prompts or wait for specific output patterns. Supported: Can drive interactive tools.

1. spawn_process(["gdb", "./binary"])
2. send_command(id, "break main")
3. send_command(id, "run")

Features

  • Stateful Sessions: Environment variables, working directories, and process states persist between commands.
  • Interactive Support: Specifically designed for REPLs and interactive CLIs that require continuous input.
  • Output Control: Supports waiting for specific output patterns (regex) to ensure commands complete before returning.
  • Session Management: Handle multiple concurrent terminal sessions.
  • History: Access full session logs via MCP resources.

Usage

Running Directly

uvx interactive-terminal-mcp

Integration with Claude Code

You can add this server to Claude Code uvx.

Using pipx:

claude mcp add --transport stdio interactive-terminal-mcp -- uvx interactive-terminal-mcp

Manual Configuration (claude_config.json):

{
  "mcpServers": {
    "interactive-terminal": {
      "command": "uvx",
      "args": ["interactive-terminal-mcp"]
    }
  }
}

Available Tools

spawn_process

Starts a new interactive process.

  • Arguments:
    • command (List[str]): The command to run (e.g., ["bash"], ["python3", "-i"]).
  • Returns: session_id (str)

send_command

Sends input to an active session and waits for output.

  • Arguments:
    • session_id (str): The target session ID.
    • cmd (str): The command string to send.
    • wait_for (str, optional): Regex pattern to wait for (e.g., \$\s*). Defaults to a short timeout if not provided.
    • timeout (int, optional): Maximum time to wait in seconds.

read_buffer

Reads any pending output from the session buffer without sending new commands.

  • Arguments: session_id (str)

kill_session

Terminates a specific session.

  • Arguments: session_id (str)

Resources

  • cli://{session_id}/history: Retrieves the full interaction history (inputs and outputs) for a specific session.

Roadmap

  • Session Recording: Support saving interaction logs in standard formats (e.g., asciinema) for replay and auditing.
  • Human Intervention: Enable mechanisms for users to pause, terminate, or manually intervene in active shell sessions managed by the Agent.

[!WARNING] Security Warning: This tool provides full terminal access to the connected LLM. The LLM will have the same permissions as the user running the MCP server. Use only in trusted environments or sandboxed containers (e.g., Docker) to prevent unauthorized system modifications.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

interactive_terminal_mcp-0.1.5.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

interactive_terminal_mcp-0.1.5-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file interactive_terminal_mcp-0.1.5.tar.gz.

File metadata

  • Download URL: interactive_terminal_mcp-0.1.5.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for interactive_terminal_mcp-0.1.5.tar.gz
Algorithm Hash digest
SHA256 e2d81bf1d3539eb983bc0f82ff334bfc476ad09d9318807b1f39bb49c2ce2969
MD5 f32816d70a6bdcf9bf4485177b01f9c2
BLAKE2b-256 7b6a35ccefac36c457ae37bfa1aea4349e8b2f1be03750654b1af8d4c6116a89

See more details on using hashes here.

File details

Details for the file interactive_terminal_mcp-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: interactive_terminal_mcp-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for interactive_terminal_mcp-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 5754fc96985ef65556cdeadc2011409fbf0bed956935becfa7dc46cc3153fa64
MD5 6e35a21adf4d26143edeb598082e3ccd
BLAKE2b-256 997cdcea1e89e36ed1ad71a81293042dce7c1543bff8b9b8914ed583cd7dfc4c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page