Terminal MCP Server provides an interface for executing commands on local or remote hosts via the Model Context Protocol (MCP). It enables AI models and applications to run system commands locally or remotely through SSH connections, with features like session persistence and environment variable customization.
The simplest way to install the terminal-mcp-server for Claude Desktop is using Smithery:
npx -y @smithery/cli install @weidwonder/terminal-mcp-server --client claude
To install the server 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 connection method uses standard input/output:
# Start with npm
npm start
# Or run the built file directly
node build/index.js
For remote connections via HTTP Server-Sent Events:
# Start with npm
npm run start:sse
# Or run directly with SSE flag
node build/index.js --sse
Customize the SSE server with these options:
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 configuration:
node build/index.js --sse --port 3000 --endpoint /mcp --host 0.0.0.0
This makes the server available at http://0.0.0.0:3000/mcp
.
To verify your server is working correctly:
npm run inspector
The core 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 address (omit for local execution) |
username | string | When using host | SSH username |
session | string | No | Session identifier (default: "default") |
env | object | No | Environment variables (default: empty object) |
{
"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"
}
}
Open the Roo Code settings file:
~/Library/Application Support/Code/User/globalStorage/rooveterinaryinc.roo-cline/settings/cline_mcp_settings.json
Add one of these configurations:
For stdio mode:
{
"mcpServers": {
"terminal-mcp": {
"command": "node",
"args": ["/path/to/terminal-mcp-server/build/index.js"],
"env": {}
}
}
}
For SSE mode:
{
"mcpServers": {
"terminal-mcp-sse": {
"url": "http://localhost:8080/sse",
"headers": {}
}
}
}
~/.cline/config.json
~/Library/Application Support/Claude/claude_desktop_config.json
&&
to maintain environmentnohup
or screen
/tmux
~/.ssh/id_rsa
)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 > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
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 explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.