Skip to main content
Glama
ptbsare

terminal-mcp-server

by ptbsare

Terminal MCP Server

简体中文

The Terminal MCP Server is a Model Context Protocol (MCP) server designed to facilitate remote and local command execution, with robust SSH capabilities. It allows your AI models or other applications to securely execute commands on remote hosts via SSH or locally, providing a powerful way to interact with various systems.

Highlights

  • Secure SSH Command Execution: Execute commands on remote servers securely using SSH, with support for SSH alias config file parsing. Automatically parses your ~/.ssh/config file to retrieve connection details like HostName, User, IdentityFile, Passphrase, and Port, simplifying SSH management.

  • Local Command Execution: Run commands directly on the local machine where the MCP server is running.

  • Session Management with Timeout: Maintains persistent SSH sessions with configurable timeouts for efficient command execution and resource management.

  • Environment Variable Support: Pass environment variables to both remote and local commands.

  • Default Directory for Local Commands: Configure a DEFAULT_DIR environment variable to specify the starting directory for local command execution.

Related MCP server: mcp-ssh

Features

  • Remote Command Execution: Connects to remote hosts via SSH and executes specified commands.

  • Local Command Execution: Executes commands on the local machine.

  • SSH Configuration Parsing: Reads and interprets ~/.ssh/config for streamlined connection setup.

  • Connection Pooling: Reuses existing SSH connections to minimize overhead.

  • Error Handling and Retries: Implements retry mechanisms for connection attempts and robust error reporting.

Usage

Installation

  1. Clone the repository:

    git clone https://github.com/ptbsare/terminal-mcp-server.git
    cd terminal-mcp-server
  2. Install dependencies:

    npm install
  3. Build the project:

    npm run build

Running the Server

To start the MCP server:

npm start

The server will listen for incoming MCP requests.

SSH Configuration

Ensure your SSH configuration (~/.ssh/config) is set up correctly for the hosts you wish to connect to. The server will automatically parse this file.

Example ~/.ssh/config:

Host my_remote_server
  HostName your_remote_server_ip_or_hostname
  User your_username
  IdentityFile ~/.ssh/id_rsa
  Port 22
  # Passphrase your_passphrase (uncomment and set if your key is encrypted)

Using with Claude (or other AI models)

To integrate this MCP server with Claude, you need to configure Claude to connect to a local MCP server.

  1. Start the Terminal MCP Server as described above.

  2. Configure Claude: In your Claude environment, you will typically add a tool definition that points to this MCP server. The exact configuration steps depend on the Claude interface or API you are using.

    To configure the MCP server for Claude, you would typically create a JSON file (e.g., mcp_server.json) with the following structure:

    {
      "mcpServers": {
        "terminal-mcp-server": {
          "command": "npm",
          "args": [
            "--prefix",
            "/path/to/terminal-mcp-server",
            "run",
            "start"
          ]
        }
      }
    }

    This server provides a single tool: execute_command.

    Tool: execute_command

    • Description: Executes a shell command on a remote host via SSH or locally.

    • Parameters:

      • command (string, required): The shell command to execute.

      • host (string, optional): The SSH host alias from your ~/.ssh/config to execute the command on. If not provided, the command will be executed locally.

      • env (object, optional): Environment variables to set for the command execution. Keys and values should be strings.

    Save this JSON content as mcp_server.json (or any other name) and provide it to Claude's MCP configuration. The exact method for providing this configuration depends on your Claude environment (e.g., via a specific UI, API call, or configuration file).

Local Command Default Directory

You can set an environment variable DEFAULT_DIR before starting the terminal-mcp-server to specify the default working directory for local commands.

Example:

DEFAULT_DIR="/workdir" npm start

This will make all local commands executed via the MCP server start in /workdir unless explicitly overridden.

Available Tools

1 tool
execute_commandC

Execute commands on remote hosts or locally (This tool can be used for both remote hosts and the current machine)

ParametersJSON Schema
NameRequiredDescriptionDefault
envNoEnvironment variables
hostNoHost to connect to (optional, if not provided the command will be executed locally)
commandYesCommand to execute. Before running commands, it's best to determine the system type (Mac, Linux, etc.)

TDQS

C2.4/5.0
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description must carry the full burden of disclosure. It does not mention that command execution can be destructive, require permissions, or produce side effects. The only behavioral detail (remote/local) is already evident from the schema.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is short, but the parenthetical 'This tool can be used for both remote hosts and the current machine' repeats the first clause. This redundancy is somewhat inefficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a command execution tool with no output schema and no annotations, the description is severely lacking. It does not explain return values, error handling, or the potential for system-altering effects, which is essential for a tool of this power.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the baseline is 3. The tool description adds no parameter-level detail, but the schema descriptions for command, host, and env are clear and include relevant context like checking system type.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states it executes commands on remote hosts or locally, which is a specific verb+resource combination. There are no sibling tools to differentiate from, so the clarity is sufficient.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description mentions it works for remote and local hosts, but provides no guidance on when to use this tool versus alternatives or when not to use it. No exclusions or preconditions are given.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 1 tool updatev0.0.1
    • First observedexecute_command

TDQS

B3/5.0
Disambiguation5/5

There is only one tool, so no ambiguity exists between tools. The tool's purpose is clearly stated to execute commands on remote or local hosts.

Naming Consistency5/5

The single tool is named 'execute_command', which follows a clear verb_noun pattern. Consistency is trivially maintained with only one tool.

Tool Count3/5

The server provides a single tool, which feels thin for a terminal server. While the tool is broad, additional tools for file operations or process management would be expected.

Completeness4/5

The tool covers basic command execution, which is the core functionality. However, it lacks features like interactive session handling, background process management, or file transfer, which are common gaps for terminal servers.

Maintenance

ActivityInactive
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables SSH connections and remote command execution with persistent session management and real-time browser-based terminal monitoring. Supports multiple simultaneous SSH sessions with command history tracking and live WebSocket streaming of terminal output.
    6
    MIT
  • A
    license
    B
    quality
    D
    maintenance
    Enables secure SSH connections to remote servers for executing shell commands and managing active sessions. It supports authentication via passwords or private keys and provides optional host-based access control.
    4
    210
    MIT
  • F
    license
    Not graded
    quality
    C
    maintenance
    Enables remote server management via SSH, including command execution, file transfer (SFTP), and interactive shell sessions, with support for multiple hosts.
    -

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ptbsare/terminal-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server