Skip to main content
Glama
idletoaster

SSH MCP Server

by idletoaster

๐Ÿš€ SSH MCP Server (Node.js)

NPM Version GitHub Issues License: MIT Node.js

A secure, high-performance Model Context Protocol (MCP) server that enables AI assistants like Claude Desktop to execute SSH commands on remote servers. Built with Node.js and the official MCP SDK for maximum compatibility and reliability.

๐Ÿ”„ Version 2.1.0 - Token-Efficient File Operations: Complete rewrite in Node.js with official MCP SDK - eliminates all previous Go compatibility issues!


โœจ Features

  • ๐Ÿ” Secure SSH: Private key authentication with multiple key format support

  • ๐Ÿค– AI-Ready: Official MCP SDK integration for Claude Desktop and other AI tools

  • โšก High Performance: Node.js async architecture for fast command execution

  • ๐Ÿ“ฆ Zero Setup: One-command installation via NPX - no compilation required

  • ๐ŸŒ Universal: Pure JavaScript runs on Windows, macOS, and Linux

  • ๐Ÿ›ก๏ธ Type Safe: Built with modern JavaScript and comprehensive error handling

  • ๐Ÿ“‹ Standards Compliant: Uses official @modelcontextprotocol/sdk


Related MCP server: ssh-mcp-server

๐Ÿš€ Quick Start

Installation & Usage

# Use directly with NPX (recommended)
npx @idletoaster/ssh-mcp-server@latest

# Or install globally
npm install -g @idletoaster/ssh-mcp-server

Claude Desktop Configuration

Add to your Claude Desktop MCP configuration file:

{
  "mcpServers": {
    "ssh": {
      "command": "npx",
      "args": ["-y", "@idletoaster/ssh-mcp-server@latest"],
      "env": {}
    }
  }
}

That's it! Claude can now execute SSH commands on your remote servers.


๐Ÿ’ฌ Usage Examples

Once configured, Claude can help you with commands like:

"Check disk usage on my production server at 192.168.1.100"

"Restart the nginx service on server.example.com as user admin"

"Show running processes on my Ubuntu server using my SSH key"

Manual Tool Usage

{
  "tool": "remote-ssh",
  "arguments": {
    "host": "192.168.1.100",
    "user": "ubuntu",
    "command": "df -h",
    "privateKeyPath": "/home/user/.ssh/id_rsa"
  }
}

๐Ÿ”ง Configuration

SSH Key Authentication

The server supports multiple authentication methods:

1. Explicit Key Path

{
  "privateKeyPath": "/path/to/your/private/key"
}

2. Environment Variable

export SSH_PRIVATE_KEY="/home/user/.ssh/id_rsa"

3. Auto-Discovery

Automatically searches for keys in:

  • ~/.ssh/id_rsa

  • ~/.ssh/id_ed25519

  • ~/.ssh/id_ecdsa

Supported Key Formats

  • โœ… RSA keys (id_rsa)

  • โœ… ED25519 keys (id_ed25519)

  • โœ… ECDSA keys (id_ecdsa)

  • โœ… OpenSSH format

  • โœ… PEM format


๐Ÿ› ๏ธ Development

Prerequisites

  • Node.js 18+ (check: node --version)

  • NPM 9+ (check: npm --version)

Install Node.js

Windows:

Download from nodejs.org or use Chocolatey:

choco install nodejs

Linux (Ubuntu/Debian):

curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs

Linux (CentOS/RHEL):

curl -fsSL https://rpm.nodesource.com/setup_20.x | sudo bash -
sudo yum install -y nodejs

macOS:

brew install node

Build from Source

# Clone repository
git clone https://github.com/idletoaster/ssh-mcp-server.git
cd ssh-mcp-server

# Install dependencies
npm install

# Run locally
npm start

# Development with auto-reload
npm run dev

๐Ÿ—๏ธ Architecture

ssh-mcp-server/
โ”œโ”€โ”€ package.json          # NPM configuration & dependencies
โ”œโ”€โ”€ index.js              # Main MCP server (Official SDK)
โ”œโ”€โ”€ lib/
โ”‚   โ””โ”€โ”€ ssh-client.js     # SSH connection management
โ”œโ”€โ”€ README.md             # Documentation
โ”œโ”€โ”€ LICENSE               # MIT license
โ””โ”€โ”€ .gitignore           # Node.js gitignore

Technology Stack

  • Runtime: Node.js 18+ with ES Modules

  • MCP SDK: @modelcontextprotocol/sdk (Official)

  • SSH: ssh2 library for Node.js

  • Distribution: NPM with direct NPX execution


๐Ÿ”’ Security

Best Practices

  • โœ… Private key authentication only (no passwords)

  • โœ… Configurable SSH algorithms and timeouts

  • โœ… No persistent connections (session-based)

  • โœ… Input validation and sanitization

  • โœ… Comprehensive error handling

Security Guidelines

  • ๐Ÿ” Store private keys with restrictive permissions (chmod 600)

  • ๐ŸŒ Use SSH key passphrases when possible

  • ๐Ÿ›ก๏ธ Restrict SSH keys to specific hosts in ~/.ssh/config

  • ๐Ÿ“ Monitor SSH access logs

  • ๐Ÿšซ Never run as root unless absolutely necessary

Network Security

# Example SSH config for restricted access
Host production-server
    HostName 192.168.1.100
    User deploy
    IdentityFile ~/.ssh/production_key
    IdentitiesOnly yes
    StrictHostKeyChecking yes

๐Ÿงช Testing

Local Testing

# Test the MCP server
echo '{"host":"test.server.com","user":"testuser","command":"whoami"}' | npm start

Integration Testing

# Verify Node.js installation
node --version  # Should be 18+
npm --version   # Should be 9+

# Test NPX execution
npx @idletoaster/ssh-mcp-server@latest --help

๐ŸŒ Compatibility

Operating Systems

  • โœ… Windows 10/11 (x64, ARM64)

  • โœ… macOS 12+ (Intel & Apple Silicon)

  • โœ… Linux (x64, ARM64) - All major distributions

AI Platforms

  • ๐Ÿค– Claude Desktop (Primary target)

  • ๐Ÿค– Cursor IDE

  • ๐Ÿค– Any MCP-compatible application

Node.js Compatibility

  • โœ… Node.js 18.x (LTS)

  • โœ… Node.js 20.x (LTS)

  • โœ… Node.js 22.x (Current)


๐Ÿ“Š Migration from v1.x (Go)

Upgrading from the Go version? The Node.js version offers:

โœ… Improvements

  • Zero compilation - No more binary builds

  • Better compatibility - Official MCP SDK

  • Faster development - Direct code changes

  • Simpler deployment - Pure NPX distribution

  • No protocol issues - Official Anthropic SDK

๐Ÿ”„ Migration Steps

  1. Uninstall old version: Remove Go-based installation

  2. Install new version: npx @idletoaster/ssh-mcp-server@latest

  3. Update Claude config: Same configuration works!

  4. Test connection: Verify SSH functionality


๐Ÿค Contributing

Development Workflow

  1. Fork the repository

  2. Create a feature branch: git checkout -b feature/amazing-feature

  3. Make your changes

  4. Test thoroughly: npm test

  5. Submit a pull request

Code Style

  • Use ES6+ modern JavaScript

  • Follow Node.js best practices

  • Add JSDoc comments for functions

  • Validate with existing patterns


๐Ÿ“„ License

MIT License - see LICENSE file for details.


๐Ÿ™ Acknowledgments


๐Ÿ“ž Support


Built with โค๏ธ for the AI development community using Node.js and official MCP SDK

๐Ÿ†• NEW in v2.1.0: Token-Efficient File Operations

Enhanced with 4 powerful tools inspired by Desktop Commander for optimal token usage:

๐ŸŽฏ Token-Efficient Tools

  1. ssh-edit-block - Edit specific text blocks (80-90% token reduction vs full rewrites)

  2. ssh-read-lines - Read file sections by line numbers (massive savings for large files)

  3. ssh-search-code - Pattern search without reading full files

  4. ssh-write-chunk - Efficient content writing with append/rewrite modes

๐Ÿ’ก Benefits

  • 80-90% fewer tokens for file operations

  • No more full file rewrites for small changes

  • Partial file reading for large codebases

  • Pattern searching without token overhead

๐Ÿ“– New Tool Usage

// Edit specific text blocks
{
  "name": "ssh-edit-block",
  "arguments": {
    "host": "server.com",
    "user": "username", 
    "filePath": "/path/to/file.js",
    "oldText": "version: '2.0.0'",
    "newText": "version: '2.1.0'"
  }
}

// Read specific lines only
{
  "name": "ssh-read-lines", 
  "arguments": {
    "host": "server.com",
    "user": "username",
    "filePath": "/path/to/large-file.js",
    "startLine": 100,
    "endLine": 150
  }
}

// Search patterns efficiently
{
  "name": "ssh-search-code",
  "arguments": {
    "host": "server.com", 
    "user": "username",
    "path": "/project",
    "pattern": "function.*export",
    "filePattern": "*.js"
  }
}

Available Tools

5 tools
remote-sshB

Execute SSH commands on remote servers with private key authentication

ParametersJSON Schema
NameRequiredDescriptionDefault
hostYesRemote server hostname or IP address
userYesSSH username
commandYesCommand to execute on remote server
privateKeyPathNoPath to SSH private key (optional, falls back to SSH_PRIVATE_KEY env var)
portNoSSH port (default: 22)

TDQS

B3.3/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description must disclose behavioral traits. It only mentions authentication method but omits details on command execution behavior, such as whether it streams output, typical timeouts, exit code handling, or error responses.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single concise sentence that efficiently conveys the core purpose. However, it may be too brief to cover essential behavioral details, but for conciseness alone it performs well.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given there is no output schema and no annotations, the description fails to specify what the tool returns (e.g., stdout, exit code) or how it handles errors. It also does not mention runtime considerations like timeout or command chaining, leaving the agent underinformed for a potentially sensitive operation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% so parameters are well-described in the schema. The description adds only the authentication context; it does not provide additional semantic nuance beyond what the schema already offers, so baseline 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The tool name 'remote-ssh' and description 'Execute SSH commands on remote servers with private key authentication' clearly state the verb (execute) and resource (SSH commands on remote servers), and they distinguish from siblings like 'ssh-edit-block' which focus on file editing.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies this tool is for executing arbitrary commands versus the siblings that handle specific operations (edit, read, search, write), but it does not provide explicit when-to-use or when-not-to-use guidance, nor does it mention prerequisites or alternatives.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

ssh-edit-blockB

Edit specific text blocks in remote files (token-efficient alternative to full rewrites)

ParametersJSON Schema
NameRequiredDescriptionDefault
hostYesRemote server hostname or IP address
userYesSSH username
filePathYesPath to file on remote server
oldTextYesText to find and replace
newTextYesReplacement text
expectedReplacementsNoExpected number of replacements (default: 1)
privateKeyPathNoPath to SSH private key (optional)
portNoSSH port (default: 22)

TDQS

B3.3/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Without annotations, the description must disclose behavioral traits. It only states 'edit specific text blocks' without detailing whether the operation is destructive, requires permissions, handles missing oldText, or is idempotent. This is insufficient for a mutation tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single concise sentence that efficiently conveys the core purpose and unique value proposition. While appropriately front-loaded, it could benefit from slight structural expansion for completeness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations and no output schema, the description is insufficiently complete. It does not cover prerequisites, error conditions, return behavior, or when to use alternatives. The tool has 8 parameters and potential side effects, yet the description provides minimal context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so baseline is 3. The description adds no extra meaning beyond the schema; it simply repeats the idea of editing text blocks. No additional context for parameters like expectedReplacements or privateKeyPath is provided.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool edits specific text blocks in remote files, and positions itself as a token-efficient alternative to full rewrites. This effectively distinguishes it from sibling tools like ssh-read-lines, ssh-search-code, and ssh-write-chunk.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for small edits via 'token-efficient alternative to full rewrites', but lacks explicit guidance on when to use this tool versus siblings like ssh-write-chunk for full rewrites or remote-ssh for general commands. No when-not-to-use or alternative conditions are provided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

ssh-read-linesA

Read specific lines from remote files (token-efficient for large files)

ParametersJSON Schema
NameRequiredDescriptionDefault
hostYesRemote server hostname or IP address
userYesSSH username
filePathYesPath to file on remote server
startLineNoStarting line number (1-based)
endLineNoEnding line number (optional, reads to end if not specified)
maxLinesNoMaximum lines to read (default: 100)
privateKeyPathNoPath to SSH private key (optional)
portNoSSH port (default: 22)

TDQS

A3.6/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description must cover behavioral traits. It states the tool reads lines and emphasizes token efficiency, but does not disclose auth requirements, error behavior, or confirm read-only nature. The name implies a safe operation, but more detail is needed for full transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, concise sentence that includes an important trait (token efficiency). It is front-loaded with the core purpose, though it could be slightly more structured with usage hints.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple read tool with 8 parameters and no output schema or annotations, the description provides the basic purpose and a key benefit. However, it lacks details on prerequisites, error conditions, or when to use alternatives, leaving some gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the baseline is 3. The description adds a general note about token efficiency but does not clarify parameter meanings beyond what the schema already provides.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Read specific lines from remote files' clearly states the action and resource. The name and description together distinguish it from sibling tools like ssh-edit-block, ssh-write-chunk, etc., which perform different operations.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description hints at a use case ('token-efficient for large files') but does not explicitly state when to use this tool versus alternatives. It lacks guidance on when not to use it or direct comparisons to siblings.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

ssh-search-codeA

Search for patterns in remote files without reading full content (token-efficient)

ParametersJSON Schema
NameRequiredDescriptionDefault
hostYesRemote server hostname or IP address
userYesSSH username
pathYesDirectory path to search on remote server
patternYesText pattern to search for
filePatternNoFile pattern (e.g., "*.js", "*.py")
ignoreCaseNoCase-insensitive search
maxResultsNoMaximum number of results
contextLinesNoLines of context around matches
privateKeyPathNoPath to SSH private key (optional)
portNoSSH port (default: 22)

TDQS

A3.8/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the burden. It mentions token-efficiency but lacks details on read-only behavior, error handling, or security considerations. Adequate but not comprehensive.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence, to the point, no extraneous information. Excellent conciseness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Despite 10 parameters and no output schema, the description provides no guidance on result format, limits, or error conditions. Incomplete for a complex tool with many parameters.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the description adds no new parameter-level meaning beyond the overall purpose. Baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action 'Search for patterns' and the resource 'remote files', and distinguishes it from siblings by emphasizing 'without reading full content (token-efficient)'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies when to use (token-efficient search) and distinguishes from siblings like ssh-read-lines, but does not explicitly state when not to use or provide alternative tool names.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

ssh-write-chunkB

Write content to remote files with append/rewrite modes (token-efficient for large content)

ParametersJSON Schema
NameRequiredDescriptionDefault
hostYesRemote server hostname or IP address
userYesSSH username
filePathYesPath to file on remote server
contentYesContent to write
modeNoWrite mode: "rewrite" or "append"rewrite
privateKeyPathNoPath to SSH private key (optional)
portNoSSH port (default: 22)

TDQS

B3.3/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description must fully disclose behavior. It notes append/rewrite modes and token efficiency but omits key details like connection handling, overwrite behavior, error semantics, or return value. For a write tool, this is insufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

A single sentence front-loads the verb and resource, then adds mode and efficiency hint. It is efficient but sacrifices depth. No fluff, but missing needed details.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool has 7 parameters and no output schema. The description does not explain return values, error handling, prerequisites (e.g., SSH key setup), or how multiple chunks interact. It is incomplete for a reliable agent invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the schema already describes all parameters. The description adds only a general hint about token efficiency without enriching individual parameter semantics. Baseline 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'Write', the resource 'remote files', and specifies append/rewrite modes, distinguishing it from sibling tools like ssh-edit-block. The mention of token efficiency for large content adds further context.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies use for writing or updating remote files, especially large content, but does not explicitly compare with siblings like ssh-edit-block or provide when-not-to-use guidance. No prerequisites or alternatives are mentioned.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 5 tool updatesv2.1.8
    • First observedremote-ssh
    • First observedssh-edit-block
    • First observedssh-read-lines
    • First observedssh-search-code
    • First observedssh-write-chunk

TDQS

A3.7/5.0
Disambiguation5/5

Each tool has a clearly distinct purpose: remote-ssh for general command execution, and the four ssh-* tools for specific file operations (edit block, read lines, search code, write chunk). There is no overlap or ambiguity.

Naming Consistency4/5

Four tools follow the consistent 'ssh-verb-noun' pattern (e.g., ssh-read-lines), but 'remote-ssh' breaks this pattern. Still, the naming is mostly consistent and predictable.

Tool Count5/5

With 5 tools, the server is well-scoped for its purpose of SSH remote operations. It covers essential file manipulation and command execution without being too sparse or bloated.

Completeness4/5

The tool set covers command execution and core file operations (read, write, edit, search). However, it lacks file listing, deletion, or transfer capabilities, leaving minor gaps for a complete SSH toolkit.

Maintenance

ActivityInactive
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    A
    maintenance
    Enables secure remote command execution and bidirectional file transfers on SSH servers through the Model Context Protocol. It features robust security controls including command whitelisting, credential isolation, and support for multiple SSH connection profiles.
    1,321
    830
    ISC

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/idletoaster/ssh-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server