Terminal MCP Server is a powerful tool that implements the Model Context Protocol (MCP), allowing AI models and applications to execute commands on local or remote machines. It provides a straightforward interface for command execution with support for session persistence and environment variable customization.
The easiest way to install Terminal MCP Server for Claude Desktop is through Smithery:
npx -y @smithery/cli install @weidwonder/terminal-mcp-server --client claude
If you prefer to install manually:
# Clone the repository
git clone https://github.com/weidwonder/terminal-mcp-server.git
cd terminal-mcp-server
# Install dependencies
npm install
# Build the project
npm run build
The default mode uses stdio for communication:
# Start the server using npm
npm start
# Or run the built file directly
node build/index.js
Server-Sent Events (SSE) mode allows remote connections via HTTP:
# Start the server in SSE mode
npm run start:sse
# Or run with SSE flag
node build/index.js --sse
Option | Description | Default |
---|---|---|
--port or -p |
The port to listen on | 8080 |
--endpoint or -e |
The endpoint path | /sse |
--host or -h |
The host to bind to | localhost |
Example with custom options:
# Custom SSE configuration
node build/index.js --sse --port 3000 --endpoint /mcp --host 0.0.0.0
The main functionality of Terminal MCP Server is provided through the execute_command
tool.
Parameter | Type | Required | Description |
---|---|---|---|
command | string | Yes | The command to execute |
host | string | No | Remote host (if omitted, executes locally) |
username | string | Required with host | SSH username |
session | string | No | Session name (defaults to "default") |
env | object | No | Environment variables |
{
"command": "ls -la",
"session": "my-local-session",
"env": {
"NODE_ENV": "development"
}
}
{
"host": "example.com",
"username": "user",
"command": "ls -la",
"session": "my-remote-session",
"env": {
"NODE_ENV": "production"
}
}
Add the following to your Claude Desktop settings file at ~/Library/Application Support/Claude/claude_desktop_config.json
:
{
"mcpServers": {
"terminal-mcp": {
"command": "node",
"args": ["/path/to/terminal-mcp-server/build/index.js"],
"env": {}
}
}
}
{
"mcpServers": {
"terminal-mcp-sse": {
"url": "http://localhost:8080/sse",
"headers": {}
}
}
}
Add to the Roo Code settings file at ~/Library/Application Support/Code/User/globalStorage/rooveterinaryinc.roo-cline/settings/cline_mcp_settings.json
:
Similar configuration format as Claude Desktop, with stdio or SSE options.
Add to the Cline settings file at ~/.cline/config.json
:
Similar configuration format as Claude Desktop, with stdio or SSE options.
&&
between commandsnohup
or screen
/tmux
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "terminal-mcp" '{"command":"node","args":["/path/to/terminal-mcp-server/build/index.js"],"env":[]}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"terminal-mcp": {
"command": "node",
"args": [
"/path/to/terminal-mcp-server/build/index.js"
],
"env": []
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"terminal-mcp": {
"command": "node",
"args": [
"/path/to/terminal-mcp-server/build/index.js"
],
"env": []
}
}
}
3. Restart Claude Desktop for the changes to take effect