mcp-ssh-tool
mcp-ssh-tool
GitHub CopilotおよびVS Code向けに自律的なSSH操作を提供するModel Context Protocol (MCP) SSHクライアントサーバーです。手動のプロンプトやGUI操作なしで、自然言語によるSSH自動化を実現します。
公式MCPレジストリエントリ: io.github.oaslananka/mcp-ssh-tool
レジストリメタデータ: https://registry.modelcontextprotocol.io/v0.1/servers/io.github.oaslananka%2Fmcp-ssh-tool/versions/latest
クイックスタート
インストール
グローバルインストール(推奨):
npm install -g mcp-ssh-tool一回限りの実行:
npx mcp-ssh-tool
MCPクライアント設定 (VS Code / Claude Desktop / その他)
MCP設定ファイル (mcp.json, .vscode/mcp.json, またはClaude DesktopのMCP設定) に以下を追加します:
{
"servers": {
"ssh-mcp": {
"type": "stdio",
"command": "mcp-ssh-tool",
"args": []
}
}
}使用例
設定が完了すると、MCPクライアントで自然言語を使用できます:
SSH接続: "Connect to server 192.168.1.100 as admin using SSH key"
ファイル操作: "Read the content of /etc/nginx/nginx.conf on the server"
コマンド実行: "Run 'systemctl status nginx' on the remote server"
パッケージ管理: "Install htop package on Ubuntu server"
サービス制御: "Restart the nginx service"
Claude Desktop: "connect to my server and check disk usage"
パッケージ/サービススタックのインストール: "install nginx on my remote server"
設定ファイルの読み込み: "read the file /etc/nginx/nginx.conf"
サービスの再起動: "restart the nginx service"
ログの閲覧: "list files in /var/log"
利用可能なツール
ssh_open_session- さまざまな認証方法でSSH接続を確立ssh_close_session- SSHセッションを閉じるssh_list_sessions- アクティブなすべてのSSHセッションを一覧表示ssh_ping- セッションが生存し応答可能か確認ssh_list_configured_hosts- ~/.ssh/config からホストを一覧表示ssh_resolve_host- SSH設定からホストエイリアスを解決proc_exec- リモートでコマンドを実行(タイムアウト指定可能)proc_sudo- sudo権限でコマンドを実行fs_read,fs_write,fs_list,fs_stat,fs_mkdirp,fs_rmrf,fs_rename- ファイルシステム操作ensure_package-presentおよびabsent状態でのパッケージ管理ensure_service-restartedを含むサービス制御ensure_lines_in_file-presentおよびabsent状態でのファイル行管理patch_apply- ファイルにパッチを適用os_detect- システム情報の検出get_metrics- JSONまたはPrometheus形式でのサーバーメトリクスproc_exec_stream- チャンク出力によるストリーミングコマンド実行file_upload,file_download- SFTPファイル転送ヘルパーtunnel_local_forward,tunnel_remote_forward,tunnel_close,tunnel_list- トンネル管理
利用可能なリソース
mcp-ssh-tool://sessions/active- JSON形式のアクティブセッションmcp-ssh-tool://metrics/json- JSON形式のメトリクススナップショットmcp-ssh-tool://metrics/prometheus- Prometheusメトリクスエクスポートmcp-ssh-tool://ssh-config/hosts- 解析されたローカルSSHホストエイリアス
概要
SSH MCPサーバーは、GitHub CopilotとリモートシステムをSSH経由でつなぐブリッジとして機能します。以下をサポートしています:
非対話型SSH操作 - プロンプトやGUI操作は不要
複数の認証方法 - パスワード、SSH鍵、またはSSHエージェント
セッション管理 - TTLおよびLRUエビクションによる自動接続プーリング
ファイルシステム操作 - SFTP経由でのリモートファイルの読み取り、書き込み、一覧表示、管理。SFTPサブシステムを公開していないホスト向けにはSSHシェルへのフォールバック機能付き
プロセス実行 - リモートでのコマンド実行およびsudo操作
高度な自動化 - パッケージ管理、サービス制御、構成管理
セキュリティ - ログ内の機密データの自動マスキング
アーキテクチャ
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ GitHub Copilot │────│ SSH MCP Server │────│ Remote Systems │
│ / VS Code │ │ │ │ (via SSH) │
└─────────────────┘ └──────────────────┘ └─────────────────┘
│ │ │
│ MCP stdio protocol │ Session management │ SSH + optional SFTP
│ │ LRU cache + TTL │
│ │ Auth strategies │組み込み / BusyBoxターゲット
一部の組み込みターゲットはSSHコマンド実行を公開していますが、SFTPサブシステムを搭載していません。これはDropbearやBusyBoxベースのシステムで一般的です。その場合でも ssh_open_session は成功し、sftpAvailable: false を報告します。fs_read、fs_write、fs_stat、fs_list、fs_mkdirp、fs_rmrf、fs_rename などのコアファイルツールは、自動的にシェルベースの実装にフォールバックします。
インストール
前提条件
Node.js ≥ 20 (LTS)
ターゲットシステムへのSSHアクセス
認証用のSSH鍵または資格情報
npmからのインストール
npm install -g mcp-ssh-toolソースからのビルド
git clone https://github.com/oaslananka/mcp-ssh-tool.git
cd mcp-ssh-tool
npm install
npm run build
npm linkCLIフラグ
--help/-h: 使用方法と例を表示。--version/-v: バージョンを表示。--stdio: stdioモードを強制(デフォルト)。
注意: これはMCP stdioサーバーです。ターミナルは対話型シェルではありません。MCPクライアント(Claude Desktop、VS Code MCPなど)を使用するか、stdio経由でJSON-RPCを送信してください。
プラットフォームに関する注意点
Linux / macOS: 安全なクォーティングを備えたPOSIXシェルラッパーを使用。デフォルトの一時ディレクトリ:
/tmp。Windowsターゲット: OpenSSHサーバー/エージェントが必要です。鍵の検出は
C:\Users\<you>\.ssh\をチェックします。コマンドはPowerShellで安全に実行できるようにラップされます。パッケージ/サービスヘルパーは、Windowsターゲットでは意図的に無効化されています。ホスト鍵: ホスト鍵のチェックはデフォルトで緩和されています。検証を強制するには
STRICT_HOST_KEY_CHECKING=trueを設定し、オプションでKNOWN_HOSTS_PATHを指定してください。
ChatGPT Desktop統合
クイックセットアップ
npm run setup:chatgptこのコマンドは、ChatGPT Desktopがmcp-ssh-toolを使用するように自動的に設定します。
手動セットアップ
ChatGPT DesktopのMCP設定に追加してください:
macOS:
~/Library/Application Support/ChatGPT/mcp.jsonWindows:
%APPDATA%\ChatGPT\mcp.jsonLinux:
~/.config/chatgpt/mcp.json
{
"mcpServers": {
"ssh-mcp-server": {
"name": "ssh-mcp-server",
"command": "npx",
"args": ["-y", "mcp-ssh-tool"]
}
}
}詳細な使用方法については、docs/chatgpt-usage.md を参照してください。
Codex統合
クイックセットアップ
パッケージをグローバルにインストールし、Codexに登録します:
npm install -g mcp-ssh-tool
codex mcp add ssh-mcp -- mcp-ssh-toolグローバルインストールを避けたい場合は、npx を通じて登録できます:
codex mcp add ssh-mcp -- npx -y mcp-ssh-tool検証
CodexがMCPサーバーを認識しているか確認します:
codex mcp list
codex mcp get ssh-mcpコマンドが mcp-ssh-tool または npx である有効なstdioサーバーが表示されるはずです。
オプションのセキュリティ強化
Codex管理下のサーバープロセスでホスト鍵検証を強制するには:
codex mcp remove ssh-mcp
codex mcp add ssh-mcp \
--env STRICT_HOST_KEY_CHECKING=true \
--env KNOWN_HOSTS_PATH=/path/to/known_hosts \
-- mcp-ssh-toolサーバーを追加した後、Codexを再起動するか新しいセッションを開き、アクティブなセッションの一覧表示やSSH接続の開始など、単純なツール呼び出しを試してください。
VS Code Copilot統合
ユーザーレベル設定(推奨)
VS Codeを開き、Ctrl+Shift+P を押して "MCP: Open User Configuration" を実行します。
mcp.json に以下を追加します:
{
"servers": {
"ssh-mcp": {
"type": "stdio",
"command": "mcp-ssh-tool",
"args": []
}
}
}ワークスペースレベル設定
ワークスペースに .vscode/mcp.json を作成します:
{
"servers": {
"ssh-mcp": {
"type": "stdio",
"command": "mcp-ssh-tool",
"args": []
}
}
}検証
VS Codeを再起動
Copilot Chatを開く
SSH MCPツールが利用可能なツールリストに表示されるはずです
次のプロンプトでテスト: "Connect to 192.168.1.100 as admin and run 'uname -a'"
Claude Desktop、Antigravity、およびその他のMCPクライアント
stdioサーバーを起動できるMCP互換クライアントであれば、mcp-ssh-tool を使用できます。正確な設定画面や設定ファイルはクライアントによって異なりますが、プロセスは同じです:
パッケージをインストール:
npm install -g mcp-ssh-tool以下を起動するstdio MCPサーバーを登録:
{
"servers": {
"ssh-mcp": {
"type": "stdio",
"command": "mcp-ssh-tool",
"args": []
}
}
}クライアントが
serversではなくmcpServers形式のスキーマを使用している場合は、同等のエントリを使用してください:
{
"mcpServers": {
"ssh-mcp-server": {
"command": "npx",
"args": ["-y", "mcp-ssh-tool"]
}
}
}Claude Desktopの場合は、MCP設定で上記のstdioコマンドパターンを使用してください。Antigravityやその他のMCPクライアントの場合は、クライアント独自のMCP設定UIまたは設定形式を使用し、同じ実行可能コマンドを指定してください。
使用例
基本的な接続とコマンド実行
"Connect to 10.11.12.13 as deployer with password 'mypass' and run 'df -h'"ファイル操作
"Connect to server.example.com as admin, read /etc/nginx/nginx.conf and show me the server blocks"システム管理
"Connect to 192.168.1.50 as root, install htop package, start nginx service, and list /var/www contents"構成管理
"Connect to web-server as admin, add these lines to /etc/hosts:
192.168.1.10 db-server
192.168.1.20 cache-server
Then restart networking service"すぐに使えるプロンプトのアイデア
"connect to my server and check disk usage""install nginx on my remote server""read the file /etc/nginx/nginx.conf""restart the nginx service""list files in /var/log"プロのヒント
複数のセッション: ホストまたは環境ごとに1つのセッションを開き、本番環境、ステージング環境、開発環境を切り替える際は
ssh_list_sessionsとssh_pingでセッションを維持してください。BusyBox/Dropbear用のSFTPフォールバック: SFTPサブシステムを公開していない組み込みシステムでは、
ssh_open_sessionがsftpAvailable: falseで成功し、コアのfs_*ツールが自動的にシェルベースの実装にフォールバックします。ホスト鍵検証: MCPサーバー環境で
STRICT_HOST_KEY_CHECKING=trueを設定し、オプションでKNOWN_HOSTS_PATHを指定すると、より厳格な本番グレードのSSH検証が可能になります。
APIリファレンス
アーキテクチャ
src/
├── container.ts - Dependency injection wiring
├── config.ts - ConfigManager (env + programmatic overrides)
├── index.ts - CLI entry point & graceful shutdown
├── mcp.ts - MCP server (thin: delegates to ToolRegistry)
├── tools/
│ ├── registry.ts - ToolRegistry (routes CallTool requests)
│ ├── types.ts - ToolProvider interface
│ ├── session.provider.ts
│ ├── process.provider.ts
│ ├── fs.provider.ts
│ ├── ensure.provider.ts
│ ├── system.provider.ts
│ ├── transfer.provider.ts
│ └── tunnel.provider.ts
├── session.ts - SessionManager (LRU cache + TTL)
├── resources.ts - MCP resources for sessions, metrics, and SSH hosts
├── telemetry.ts - Optional OpenTelemetry tracing
├── rate-limiter.ts - Sliding window rate limiter
├── metrics.ts - Prometheus-compatible metrics
├── safety.ts - Command safety warnings (non-blocking)
└── ... - fs-tools, process, ensure, detect, ...新しいツールグループの追加
ToolProviderを実装するsrc/tools/<your-namespace>.provider.tsを作成src/tools/index.tsに登録test/unit/tools/<your-namespace>.provider.test.tsにユニットテストを追加
mcp.ts への変更は不要です。
セッションツール
ssh_open_session
{
"host": "example.com",
"username": "admin",
"port": 22,
"auth": "auto",
"password": "optional",
"privateKey": "optional-inline-key",
"privateKeyPath": "optional-path",
"passphrase": "optional",
"useAgent": false,
"readyTimeoutMs": 20000,
"ttlMs": 900000
}戻り値:
{
"sessionId": "ssh-1645123456789-1",
"host": "example.com",
"username": "admin",
"expiresInMs": 900000
}ssh_close_session
{
"sessionId": "ssh-1645123456789-1"
}ssh_list_sessions, ssh_ping, ssh_list_configured_hosts, ssh_resolve_host
ssh_list_sessionsは、残りのTTLを含むアクティブなセッションを返します。ssh_pingは、セッションの生存確認とレイテンシをチェックします。ssh_list_configured_hostsは~/.ssh/configを読み取ります。ssh_resolve_hostはSSHホストエイリアスを接続パラメータに展開します。
コマンドツール
proc_exec
{
"sessionId": "ssh-1645123456789-1",
"command": "ls -la /home",
"cwd": "/tmp",
"env": {
"DEBUG": "1"
},
"timeoutMs": 30000
}proc_sudo
{
"sessionId": "ssh-1645123456789-1",
"command": "systemctl restart nginx",
"password": "sudo-password",
"cwd": "/etc",
"timeoutMs": 30000
}両方とも以下を返します:
{
"code": 0,
"stdout": "command output",
"stderr": "",
"durationMs": 245
}ファイルツール
fs_read
{
"sessionId": "ssh-1645123456789-1",
"path": "/etc/hosts",
"encoding": "utf8"
}fs_write
{
"sessionId": "ssh-1645123456789-1",
"path": "/tmp/config.txt",
"data": "server_name example.com;\nlisten 80;",
"mode": 420
}fs_statはsize、mtime、mode、typeを返します。fs_listは{ "entries": [...], "nextToken": "optional" }を返します。fs_mkdirpはディレクトリを再帰的に作成します。fs_rmrfはファイルまたはディレクトリを再帰的に削除します。fs_renameはパスの名前変更または移動を行います。
構成および自動化ツール
ensure_package
{
"sessionId": "ssh-1645123456789-1",
"name": "nginx",
"state": "present",
"sudoPassword": "optional"
}state は present および absent をサポートします。
ensure_service
{
"sessionId": "ssh-1645123456789-1",
"name": "nginx",
"state": "restarted",
"sudoPassword": "optional"
}state は started、stopped、restarted、enabled、disabled をサポートします。
ensure_lines_in_file
{
"sessionId": "ssh-1645123456789-1",
"path": "/etc/hosts",
"lines": [
"192.168.1.10 db-server",
"192.168.1.20 cache-server"
],
"state": "present",
"createIfMissing": true,
"sudoPassword": "optional"
}state は present および absent をサポートします。
patch_apply
{
"sessionId": "ssh-1645123456789-1",
"path": "/etc/hosts",
"diff": "@@ -1 +1 @@\n-old\n+new"
}os_detect
リモートプラットフォーム、ディストリビューション、バージョン、パッケージマネージャー、initシステム、シェル、一時ディレクトリを返します。
get_metrics
サーバーメトリクスを返します。デフォルト出力はJSONです。オプションの { "format": "prometheus" } でPrometheusテキスト形式を出力します。
認証
サーバーは自動フォールバック付きの複数の認証方法をサポートしています:
認証戦略の優先順位
パスワード (提供されている場合)
SSH鍵 (インライン → パス → 自動検出)
SSHエージェント (利用可能な場合)
SSH鍵の自動検出
サーバーは以下の場所でSSH鍵を自動的に検索します:
~/.ssh/id_ed25519~/.ssh/id_rsa~/.ssh/id_ecdsa
注意: DSA鍵 (`id_dsa
Available Tools
33 toolsconnector_statusConnector StatusARead-onlyIdempotent
Use this when ChatGPT or Claude needs to understand the remote connector profile, authentication mode, and credential broker readiness without exposing secrets.
Inputs: no named parameters. Returns: Remote connector readiness without secrets
ensure_lines_in_fileEnsure Lines In FileADestructiveIdempotent
Ensures specific lines are present or absent in a file
Inputs: sessionId (required), path (required), lines (required), state, +1 more. Returns: Line management result
ensure_packageEnsure Package StateCDestructiveIdempotent
Ensures a package is installed or removed
Inputs: sessionId (required), name (required), state. Returns: Package state result
ensure_serviceEnsure Service StateBDestructiveIdempotent
Ensures a service is in the desired state
Inputs: sessionId (required), name (required), state (required). Returns: Service state result
file_downloadDownload FileARead-only
Downloads a remote file to the local machine over SFTP
Inputs: sessionId (required), remotePath (required), localPath (required). Returns: Download result with integrity details
file_uploadUpload FileBDestructive
Uploads a local file to the remote host over SFTP
Inputs: sessionId (required), localPath (required), remotePath (required). Returns: Upload result with integrity details
fs_listList Remote DirectoryCRead-onlyIdempotent
Lists directory contents
Inputs: sessionId (required), path (required), page, limit. Returns: Remote directory entries
fs_mkdirpCreate Remote DirectoriesAIdempotent
Creates directories recursively
Inputs: sessionId (required), path (required). Returns: Directory creation result
fs_readRead Remote FileBRead-onlyIdempotent
Reads a file from the remote system
Inputs: sessionId (required), path (required), encoding, maxBytes. Returns: Remote file content wrapped as structured content
fs_renameRename Remote PathBDestructive
Renames or moves a file/directory
Inputs: sessionId (required), from (required), to (required). Returns: Rename result
fs_rmrfRemove Remote Path RecursivelyADestructive
Removes files or directories recursively
Inputs: sessionId (required), path (required). Returns: Recursive remove result
fs_statStat Remote PathARead-onlyIdempotent
Gets file or directory statistics
Inputs: sessionId (required), path (required). Returns: Remote path stat result
fs_writeWrite Remote FileBDestructive
Writes data to a file on the remote system
Inputs: sessionId (required), path (required), data (required), mode. Returns: File write result
get_metricsGet Runtime MetricsARead-onlyIdempotent
Returns server metrics including session counts, command statistics, and uptime
Inputs: format. Returns: Runtime metrics
os_detectDetect Remote OSARead-onlyIdempotent
Detects operating system and environment information
Inputs: sessionId (required). Returns: Remote operating system information
patch_applyApply PatchBDestructive
Applies a patch to a file
Inputs: sessionId (required), path (required), diff (required). Returns: Patch application result
proc_execExecute Remote CommandA
Executes a non-interactive command on the remote system after policy and safety checks
Inputs: sessionId (required), command (required), cwd, env, +1 more. Returns: Remote command result
proc_exec_streamExecute Streaming CommandA
Executes a command and returns streaming output chunks
Inputs: sessionId (required), command (required), cwd, env, +1 more. Returns: Streaming command result with output chunks
proc_sudoExecute Sudo CommandADestructive
Executes a command with sudo privileges only when allowRawSudo policy permits it
Inputs: sessionId (required), command (required), cwd, timeoutMs. Returns: Remote sudo command result
ssh_close_sessionClose SSH SessionBIdempotent
Closes an SSH session
Inputs: sessionId (required). Returns: Boolean close result wrapped as structured content
ssh_host_inspectInspect SSH HostARead-only
Use this when ChatGPT or Claude needs read-only host inspection through the server-side credential broker. The user supplies only a configured host alias and selected checks; no secret material or login details are accepted.
Inputs: hostAlias (required), checks. Returns: Read-only host inspection result
ssh_hosts_listList Safe SSH Host AliasesARead-onlyIdempotent
Use this when ChatGPT or Claude needs a safe list of SSH host aliases that may be inspected through the remote connector. Sensitive login material is omitted.
Inputs: no named parameters. Returns: Redacted SSH host aliases allowed by policy
ssh_list_configured_hostsList Configured HostsARead-onlyIdempotent
Lists all hosts configured in ~/.ssh/config
Inputs: no named parameters. Returns: Configured SSH host aliases
ssh_list_sessionsList SSH SessionsARead-onlyIdempotent
Lists all active SSH sessions with their details
Inputs: no named parameters. Returns: Active SSH sessions
ssh_mutation_planPlan SSH MutationARead-onlyIdempotent
Use this when ChatGPT or Claude needs a non-executing plan for a remote SSH change. It never runs commands, writes files, uploads data, starts tunnels, or escalates privileges.
Inputs: hostAlias (required), goal (required), category. Returns: Non-executing remote mutation plan
ssh_open_sessionOpen SSH SessionB
Opens a new SSH session with authentication
Inputs: host (required), username (required), port, auth, +12 more. Returns: Session creation result or explain-mode connection plan
ssh_pingPing SSH SessionARead-onlyIdempotent
Checks if an SSH session is still alive and responsive
Inputs: sessionId (required). Returns: Session health check result
ssh_policy_explainExplain SSH PolicyARead-onlyIdempotent
Use this when ChatGPT or Claude needs to explain whether a requested SSH inspection or mutation would be allowed. This is explain-only and does not execute commands or open tunnels.
Inputs: hostAlias, action, command, path. Returns: Explain-only policy decision
ssh_resolve_hostResolve SSH HostARead-onlyIdempotent
Resolves a host alias from ~/.ssh/config to connection parameters
Inputs: hostAlias (required). Returns: Resolved SSH connection parameters
tunnel_closeClose SSH TunnelBIdempotent
Closes an active tunnel
Inputs: tunnelId (required). Returns: Tunnel close result
tunnel_listList SSH TunnelsARead-onlyIdempotent
Lists active tunnels, optionally filtered by session
Inputs: sessionId. Returns: Active tunnels
tunnel_local_forwardCreate Local SSH TunnelC
Creates a local SSH port forward
Inputs: sessionId (required), localPort (required), remoteHost (required), remotePort (required). Returns: Local tunnel information
tunnel_remote_forwardCreate Remote SSH TunnelC
Creates a remote SSH port forward
Inputs: sessionId (required), remotePort (required), localHost (required), localPort (required). Returns: Remote tunnel information
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 33 tools
Each tool targets a distinct operation or resource type (file, command, session, tunnel, package, service, inspection). There is no significant overlap; even similar tools like proc_exec and proc_exec_stream are differentiated by execution mode.
Tools are grouped by domain (fs_, proc_, tunnel_, ssh_, ensure_) with consistent patterns within groups. However, the overall naming convention mixes prefixes (fs_list vs file_download) and some tools use long phrasal names (ensure_lines_in_file).
At 33 tools, the server is heavily featured. While most tools serve a clear purpose, the count is above the typical sweet spot and includes several niche utilities (get_metrics, os_detect, ssh_mutation_plan) that could be consolidated.
The tool surface covers the full lifecycle of SSH interactions: session management, file operations, command execution, package/service management, tunneling, and safety/planning. No obvious gaps exist for a generic SSH administration server.
Maintenance
Related MCP Connectors
Connect ChatGPT and Claude to your Mac, Windows or Linux with secure MCP remote access.
Termalin's hosted MCP server. Claude, ChatGPT or any MCP client runs commands, moves files over SFTP, queries databases and reads server metrics and monitoring alerts on your servers, keylessly through Termalin Connectors: no SSH key is handed over and no inbound port is opened. Per-host command policy and an audit log. Needs a termal.in Pro or Team account (new accounts start with a 14-day Pro trial).
Remote MCP server exposing your Node Command fleet (files, shell, processes, browser) to AI hosts.
Remote MCP server for supportsheep: run AI interviews and manage support content for your blog.