Skip to main content
Glama
Node Terminal MCP

Node Terminal MCP

by henryzhz

Node Terminal MCP

npm GitHub

A local MCP server for persistent terminal sessions. It uses node-pty and communicates with its MCP client over stdio. Each session keeps its own shell state, including its working directory.

Install

Use Node.js 18 or newer. On Windows, use Windows 10 version 1809 or newer. For an MCP client with JSON stdio configuration, launch the existing npm package with npx.

{
  "mcpServers": {
    "node-terminal-mcp": {
      "command": "npx",
      "args": ["-y", "@hazzel-cn/node-terminal-mcp"]
    }
  }
}

You can also run npm install -g @hazzel-cn/node-terminal-mcp and set the client's command to node-terminal-mcp with an empty arguments list. See SETUP.md for Gemini CLI, local builds, and connection troubleshooting. Google ADK uses StdioConnectionParams for the same command and arguments.

The shell starts in the MCP server's working directory and inherits its environment and OS permissions. Connect the server to a trusted local client. Output is raw terminal text and may include ANSI control sequences.

Related MCP server: pty-mcp

Tools

Tool

What it does

terminal_create

Start a session with a unique active sessionId. You can supply a shell executable and initial dimensions.

terminal_write

Send an input string verbatim. Submit a line by including a newline or sending Enter separately.

terminal_send_key

Send a named key such as enter, backspace, esc, up, or ctrl+c.

terminal_read

Read and clear pending output for one session.

terminal_resize

Set the columns and rows of an active session.

terminal_list

List active session IDs.

terminal_close

Close a session and discard its unread output.

The server uses SHELL when it is set and /bin/bash otherwise. Pass a shell executable explicitly on Windows. Terminals start at 80 columns by 24 rows.

For example, create demo, write echo hello, send enter, and read from demo. Output may arrive after the write finishes. Reading clears the pending output, and an exited session is removed. Closing a session releases its ID immediately and starts PTY cleanup in the background. The server also reaps managed PTYs when the client closes stdin.

Develop

git clone https://github.com/henryzhz/node-terminal-mcp.git
cd node-terminal-mcp
npm ci
npm test
npm run test:package

npm test builds the project and exercises the MCP server and a local PTY. npm run test:package packs the CLI, installs it into a fresh directory, and opens a PTY from that installation. CI runs these checks on Linux, macOS, and Windows.

This release pins node-pty@1.2.0-beta.18 on all platforms. For a source build, see node-pty's native build prerequisites.

The prepack step copies the extra compiled paths from compat-dist/ into dist/. Those files come byte-for-byte from the published 1.0.7 package to preserve direct imports.

Releases

GitHub Actions builds and tests the package. npm releases are issued separately by a maintainer of @hazzel-cn/node-terminal-mcp. Before releasing, confirm the npm account with npm whoami, run the tests, and inspect the tarball with npm pack --dry-run.

Keep the npm package name and executable stable. If npm trusted publishing is configured later, use henryzhz/node-terminal-mcp and the exact publish workflow filename in the npm settings.

License

MIT

Available Tools

7 tools
terminal_closeA

Close a terminal session permanently. This will terminate the shell process and free up resources. Use this when you no longer need a terminal session or want to clean up. Note: Any running processes in the terminal will be terminated.

Inputs: sessionId (required).

terminal_createA

Create a new persistent terminal session that will continue running until explicitly closed. Terminal sessions maintain their state, environment variables, working directory, and command history. Use this to establish a long-running interactive environment for executing commands, running processes, or maintaining context across multiple operations.

Inputs: sessionId (required), cols, rows, shell.

terminal_listA

List all currently active terminal sessions. Use this to check which terminal sessions are available before interacting with them, or to manage multiple terminal contexts. Each session maintains its own state, working directory, and environment.

Inputs: no named parameters.

terminal_readA

Read the current output buffer from a terminal session. CRITICAL: Always call this after sending input to see command results, error messages, prompts, or any terminal output. The terminal session maintains its state, so you should read frequently to stay updated on the current state, especially after commands that might change the working directory, environment, or running processes.

Inputs: sessionId (required).

terminal_resizeA

Resize a terminal session to adjust its dimensions. Useful when output is truncated or when you need to accommodate different content formats. Some commands and applications behave differently based on terminal size.

Inputs: cols (required), rows (required), sessionId (required).

terminal_send_keyB

Send special keys and key combinations to a terminal session. Use this for navigation, control sequences, and interactive commands that require specific key presses. Essential for terminal interactions like confirming prompts, navigating command history, or sending interrupt signals.

Inputs: key (required), sessionId (required).

terminal_writeA

Send text input to a terminal session. This is used for typing commands, text, or any character input. The terminal will process this input as if typed by a user. Always follow up with read_from_terminal to see the results and any output generated by the command.

Inputs: input (required), sessionId (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 7 tools

    Disambiguation4/5

    Each tool maps to a distinct lifecycle action on a terminal session, and descriptions clearly separate input (terminal_write) from special key sequences (terminal_send_key). The write vs. send_key boundary is the only place an agent could hesitate, but the descriptions resolve it well enough.

    Naming Consistency5/5

    Every tool uses the identical terminal_<verb> snake_case pattern with a single, unambiguous verb (create, write, send_key, read, resize, list, close). No mixed conventions or vague names.

    Tool Count5/5

    Seven tools is a tight, well-scoped set that covers exactly the operations needed to manage persistent terminal sessions without filler. Nothing appears redundant or missing at the count level.

    Completeness4/5

    Full session lifecycle is covered: create, interact (write/send_key/read), resize, list, and close. A convenience exec-style tool for one-shot command execution or explicit exit-status retrieval would round it out, but agents can work around this via write+read.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Provides a pseudo-terminal (PTY) interface that allows AI agents to interact with command-line tools requiring interactive prompts. It enables agents to autonomously spawn processes, read output, and send inputs for workflows like database migrations and project scaffolding.
      1
      MIT
    • F
      license
      A
      quality
      D
      maintenance
      Enables AI agents to start and manage pseudo-terminal sessions, run shell commands and interact with REPLs programmatically.
      7
      -
    • F
      license
      Not graded
      quality
      D
      maintenance
      Provides AI agents with persistent, interactive pseudo-terminal sessions for running CLI tools, SSH, and AWS SSM, including support for prompts, concurrent commands, and a live web TUI.
      -