home / mcp / terminal mcp server

Terminal MCP Server

Make LLM can control your PC or Server with ssh or terminal.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "weidwonder-terminal-mcp-server": {
      "url": "http://localhost:8080/sse",
      "headers": {
        "NODE_ENV": "development"
      }
    }
  }
}

Terminal MCP Server lets you execute commands on the local machine or on remote hosts via SSH using a simple, persistent, model-context interface. It supports local and remote command execution, session reuse for a defined time, and configurable environment variables, making it useful for AI-driven automation and remote administration.

How to use

You interact with Terminal MCP Server through an MCP client. Start a local server and issue commands that run in your machine’s shell, or run commands on a remote host over SSH. Use a persistent session to reuse the same terminal environment for related tasks, which helps maintain context across multiple commands. When you connect via SSE, you can operate the server over HTTP from another machine.

To execute a command, specify the command you want to run, optionally a session name to keep the environment alive, and any environment variables that should apply to that command. If you connect to a remote host, provide the host address and SSH credentials. If a session remains inactive for a period, it will time out and close automatically after the default 20 minutes.

When you use the SSE mode, you connect over HTTP at the configured host/port and endpoint. Start the server in SSE mode, then connect clients to the SSE URL to send commands and receive output in real time.

How to install

Prerequisites: you need Node.js installed on your system. Preferably use a recent LTS version.

Install the terminal MCP server locally by cloning the project, installing dependencies, and building the project.

git clone https://github.com/weidwonder/terminal-mcp-server.git
cd terminal-mcp-server
npm install
npm run build

Additional sections

Configuration and usage notes help you customize how the server runs and how clients connect.

Starting the server in stdio mode uses the local command path and runs directly on your machine. You can start the server with the npm start command, or run the built file with node build/index.js.

Starting the server in SSE mode enables remote connections over HTTP. Use the provided options to set the port and endpoint, for example port 8080 and endpoint /sse by default.

To test and inspect MCP connections, you can use the MCP Inspector tool mentioned in the setup steps.

Best practices include using full paths for commands, handling SSH keys for remote hosts, and reusing sessions for consistent environments. Remember that sessions time out after 20 minutes of inactivity.

Available tools

execute_command

Core function to run a command on a local or remote host, with support for session persistence and environment variables.