terminal-mcp-server
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@terminal-mcp-server run 'df -h' on prod-server"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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/configfile 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_DIRenvironment 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/configfor 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
Clone the repository:
git clone https://github.com/ptbsare/terminal-mcp-server.git cd terminal-mcp-serverInstall dependencies:
npm installBuild the project:
npm run build
Running the Server
To start the MCP server:
npm startThe 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.
Start the Terminal MCP Server as described above.
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_commandDescription: 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/configto 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 startThis will make all local commands executed via the MCP server start in /workdir unless explicitly overridden.
Available Tools
1 toolexecute_commandC
Execute commands on remote hosts or locally (This tool can be used for both remote hosts and the current machine)
Inputs: command (required), env, host.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 1 tool
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.
The single tool is named 'execute_command', which follows a clear verb_noun pattern. Consistency is trivially maintained with only one tool.
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.
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
Related MCP Connectors
Manage remote servers, SSH terminals, files, databases and proxies with scoped access and approvals.
Scoped, audited SSH exec, sessions, and SFTP on your saved servers without exposing credentials
Manage servers through SSH.
Securely control computers you explicitly pair through files, terminals, processes, screenshots, desktop UI/input, clipboard, browser automation, diagnostics, and document tools.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables 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.6MIT
- AlicenseBqualityDmaintenanceEnables 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.4116 npmMIT
- AlicenseCqualityDmaintenanceEnables SSH remote command execution on remote machines with persistent connections, supporting automatic key discovery and connection pooling.231 npmMIT
- FlicenseNot gradedqualityDmaintenanceEnables remote server management via SSH, including command execution, file transfer (SFTP), and interactive shell sessions, with support for multiple hosts.-