MCP SSH Server

Execute comandos remotos de forma segura e realize operações de arquivos via SSH, com suporte para autenticação por senha e chave.

Documentação

MCP SSH Server

Uma implementação poderosa de servidor SSH para o Model Context Protocol (MCP). Este servidor permite execução segura de comandos remotos e operações de arquivos através do protocolo SSH, suportando autenticação por senha e por chave.

Recursos

  • ✨ Gerenciamento seguro de conexões SSH
  • 🔑 Autenticação por senha e por chave
  • 💻 Execução de comandos remotos
  • 📁 Operações de arquivos (upload/download)
  • 📊 Acompanhamento de progresso para transferências de arquivos
  • 🔐 Gerenciamento de permissões
  • 📂 Operações de diretórios
  • 🚀 Transferências em massa de arquivos
  • 📝 Registro detalhado (logging)

Instalação

  1. Instale o pacote:
npm install mcp-ssh
  1. Adicione à configuração do seu Claude desktop (claude_desktop_config.json):
{
  "mcpServers": {
    "ssh": {
      "command": "node",
      "args": ["%APPDATA%/npm/node_modules/mcp-ssh/dist/server.js"],
      "env": {
        "SSH_PORT": "8889",
        "SSH_LOG_LEVEL": "info"
      }
    }
  }
}

Uso

Autenticação por senha

$body = @{
    id = "test"
    host = "example.com"
    port = 22
    username = "user"
    password = "pass123"
} | ConvertTo-Json

Invoke-RestMethod -Uri "http://localhost:8889/connect" -Method Post -Body $body -ContentType "application/json"

Autenticação por chave

$body = @{
    id = "test"
    host = "example.com"
    port = 22
    username = "user"
    privateKey = Get-Content ~/.ssh/id_rsa | Out-String
    passphrase = "optional-key-passphrase"  # if your key is protected
} | ConvertTo-Json

Invoke-RestMethod -Uri "http://localhost:8889/connect" -Method Post -Body $body -ContentType "application/json"

Executar comandos

$execBody = @{
    id = "test"
    command = "ls -la"
} | ConvertTo-Json

Invoke-RestMethod -Uri "http://localhost:8889/exec" -Method Post -Body $execBody -ContentType "application/json"

Operações de arquivos

# Upload file
$uploadForm = @{
    file = Get-Item -Path "localfile.txt"
    remotePath = "/remote/path/file.txt"
}
Invoke-RestMethod -Uri "http://localhost:8889/upload/test" -Method Post -Form $uploadForm

# Download file
Invoke-RestMethod -Uri "http://localhost:8889/download/test?remotePath=/remote/path/file.txt" -Method Get -OutFile "downloaded.txt"

Operações de diretórios

# List directory
Invoke-RestMethod -Uri "http://localhost:8889/ls/test?path=/remote/path" -Method Get

# Get connection status
Invoke-RestMethod -Uri "http://localhost:8889/status/test" -Method Get

Desenvolvimento

  1. Clone o repositório:
git clone https://github.com/shaike1/mcp-server-ssh.git
cd mcp-server-ssh
  1. Instale as dependências:
npm install
  1. Compile:
npm run build
  1. Inicie o servidor:
npm start

Variáveis de Ambiente

  • SSH_PORT: Porta do servidor (padrão: 8889)
  • SSH_LOG_LEVEL: Nível de registro (padrão: info)

Contribuindo

  1. Faça um fork do repositório
  2. Crie sua branch de recurso (git checkout -b feature/amazing-feature)
  3. Faça commit das suas alterações (git commit -m 'Add some amazing feature')
  4. Envie para a branch (git push origin feature/amazing-feature)
  5. Abra um Pull Request

Licença

MIT