modelscope·@rpavez/ssh-mcp
暂无描述。
A Model Context Protocol (MCP) server that enables Cursor IDE to execute SSH commands on remote servers and manage Google Cloud Platform (GCE) instances. This server provides a seamless integration between Cursor and your remote infrastructure.
~/.ssh/config for host configurationClone or navigate to the repository:
cd mcp-remote
Install dependencies:
npm install
Start the MCP server:
node src/index.js
The server will start on http://localhost:3000 by default.
First, you need to configure your SSH connection in ~/.ssh/config. The server always uses the host alias dev regardless of what you specify in prompts.
Create or edit ~/.ssh/config:
Host dev
HostName your-server.example.com
User your-username
Port 22
IdentityFile ~/.ssh/id_rsa
# Optional: Add additional SSH options
# ServerAliveInterval 60
# ServerAliveCountMax 3
# StrictHostKeyChecking no
# UserKnownHostsFile ~/.ssh/known_hosts
Example with AWS EC2:
Host dev
HostName ec2-12-34-56-78.compute-1.amazonaws.com
User ubuntu
Port 22
IdentityFile ~/.ssh/my-aws-key.pem
Example with Google Cloud:
Host dev
HostName 34.123.45.67
User root
Port 22
IdentityFile ~/.ssh/gcp-key.pem
Important Notes:
dev (all lowercase)dev regardless of the host you specify in promptschmod 600 ~/.ssh/id_rsaConfigure Cursor to connect to the MCP server by editing ~/.cursor/mcp.json:
{
"mcpServers": {
"local-mcp": {
"name": "Local MCP",
"url": "http://localhost:3000",
"description": "Runs SSH commands and manages GCE instances",
"apiKeyHeader": "x-api-key",
"apiKeyValue": "8BOe6KshR5Eq0otTSjSGMEf5P1edKcq"
}
}
}
Configuration Fields:
name: Display name for the MCP server in Cursorurl: The URL where your MCP server is running (default: http://localhost:3000)description: Description of what the server doesapiKeyHeader: Header name for API authentication (currently optional)apiKeyValue: API key value for authentication (currently optional)After modifying mcp.json:
You can set environment variables to customize behavior:
# SSH Configuration (optional - defaults to ~/.ssh/id_rsa)
export SSH_USERNAME=your-username
export SSH_PRIVATE_KEY_PATH=~/.ssh/custom_key
# Server Configuration
export PORT=3000
# GCP Configuration (for GCE features)
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/gcp-credentials.json
# Start the server
node src/index.js
# Or with custom port
PORT=8080 node src/index.js
The server will output:
MCP server running on http://localhost:3000
Ready to accept MCP connections from Cursor
Once configured, you can use the MCP tools directly in Cursor:
Run SSH Commands:
dev and execute the commanddf -h on my remote server"Manage GCE Instances:
run_command
dev from ~/.ssh/confighost: Ignored (always uses dev)cmdKey: The command to execute (e.g., df -h, ls -la)start_instance
project: GCP project IDzone: GCE zone (e.g., us-central1-a)instance: Instance namestop_instance
project: GCP project IDzone: GCE zoneinstance: Instance nameThe server maintains a pool of SSH connections to improve performance:
The server reads connection details from ~/.ssh/config:
~ expansion in file pathsCheck if port is already in use:
lsof -i :3000
Check Node.js version:
node --version # Should be 16+
Verify server is running:
curl http://localhost:3000
Check ~/.cursor/mcp.json syntax:
Restart Cursor IDE after modifying mcp.json
Test SSH connection manually:
ssh dev
Verify SSH config:…