Skip to main content
Glama
zhangqi-eiq

SSH Remote File MCP Server

by zhangqi-eiq

SSH Remote File MCP Server

リモートサーバーのファイルを、まるでローカルファイルのように、Claude Code から読み取り、編集し、コマンドを実行します。

MCP サーバーで、リモート SSH ホストをファイルシステムツールのセットとして公開します。Claude Code に登録すると、/home/you/proj/main.py を読み取ったり、関数を編集したり、pytest を実行したり、リモートツリー全体を grep したりできます — そして、パスのスコープ制御とコマンドフィルタリングを適用しながら、SSH 経由でサーバーと通信します。

中文ドキュメント / Chinese version → · GitHub →

ライセンス

MIT — LICENSE を参照してください。


Related MCP server: MCP SSH Server

機能

ツール

目的

ssh_read_file

リモートファイルを読み取る

ssh_write_file

リモートファイルを作成・上書きする(追記も可能)

ssh_edit_file

リモートファイル内を検索・置換する

ssh_list_directory

リモートディレクトリをパーミッション・サイズ・mtime 付きで一覧表示する

ssh_run_command

リモートでシェルコマンドを実行する(安全フィルター付き)

ssh_search_files

名前のグロブまたは内容でファイルを検索する

ssh_get_env_info

OS / Python / ディスク / メモリ / CPU のスナップショット取得

ssh_file_info

単一パスの詳細な stat 情報を取得する


クイックスタート

# 1. Clone and enter
git clone https://github.com/zhangqi-eiq/server_mcp.git
cd server_mcp

# 2. Install (editable mode — picks up code changes immediately)
python install.py

# 3. Edit your real credentials
#    (file is at ~/.ssh-mcp-server/config.json by default)

# 4. Restart Claude Code, then in a chat:
#    "show me the env of my server"

これだけです。install.py は次の 3 つのことを行います:

  1. pip install -e . — パッケージをインストールします。

  2. config.json(プレースホルダー値入り)を ~/.ssh-mcp-server/ にコピーします。

  3. claude mcp add を実行し、サーバーが Claude Code に表示されるようにします。

まだ claude CLI がない場合は、python install.py --no-register を実行し、MCP エントリを手動で追加してください(手動設定 を参照してください)。


手動設定

手動で設定したい場合、または install.py が正しく登録できなかった場合:

1. パッケージをインストールする

pip install -e .

これにより、ssh_mcp_server が Python のインポートパスに配置され、python -m ssh_mcp_server でサーバーを起動できるようになります。

2. 設定ファイルを作成する

config.json~/.ssh-mcp-server/config.json にコピーします(SSH_MCP_CONFIG が未設定の場合、ローダーはこの場所を参照します)。そして実際の値を入力します:

mkdir -p ~/.ssh-mcp-server
cp config.json ~/.ssh-mcp-server/config.json
$EDITOR ~/.ssh-mcp-server/config.json

3. Claude Code に登録する

MCP エントリは、パッケージをインストールした Python インタープリタ経由でサーバーを起動する必要があります。下の <python> は、そのインタープリタの 絶対パス(有効化した環境の sys.executable。例: Windows では C:\Users\you\.conda\envs\myenv\python.exe、Linux では /home/you/.venv/bin/python)に置き換えてください。

オプション A — ユーザースコープ(すべてのプロジェクトで利用可能):

claude mcp add --scope user ssh-remote \
  -e SSH_MCP_CONFIG="$HOME/.ssh-mcp-server/config.json" \
  -- "<python>" -m ssh_mcp_server

オプション B — プロジェクトスコープ(このプロジェクトのみ):

プロジェクトのルートに .mcp.json を作成します:

{
  "mcpServers": {
    "ssh-remote": {
      "command": "<absolute path to python>",
      "args": ["-m", "ssh_mcp_server"],
      "env": {
        "SSH_MCP_CONFIG": "/absolute/path/to/your/config.json"
      }
    }
  }
}

注: Claude Code は mcpServers を 2 か所で探します — ~/.claude.json(CLI 管理、claude mcp add が書き込む場所)と ~/.claude/settings.json(手動編集)。上記の CLI ルートは自動的に正しい場所に書き込みます。

設定リファレンス

config.json の形式:

{
  "ssh": {
    "host": "your-server.example.com",
    "port": 22,
    "username": "your-username",
    "auth": {
      "type": "password",
      "key_path": "",
      "password": "your-password",
      "key_password": ""
    },
    "connect_timeout": 10,
    "keepalive_interval": 30
  },
  "allowed_paths": [
    "/home/your-username/projects"
  ],
  "security": {
    "blocked_commands": ["rm -rf /", "mkfs", ...],
    "max_file_size_mb": 50,
    "max_output_chars": 100000,
    "command_timeout": 30
  }
}

SSH 接続

フィールド

説明

デフォルト

ssh.host

サーバーアドレス(IP またはドメイン)

必須

ssh.port

SSH ポート

22

ssh.username

ログインユーザー名

必須

ssh.auth.type

"key" または "password"

"key"

ssh.auth.key_path

秘密鍵のパス(キー認証)

type=key の場合は必須

ssh.auth.password

ログインパスワード(パスワード認証)

type=password の場合は必須

ssh.auth.key_password

キーのパスフレーズ

空白

ssh.connect_timeout

接続タイムアウト(秒)

10

ssh.keepalive_interval

キープアライブ間隔(秒)

30

アクセス制御

  • allowed_paths — リモートディレクトリのホワイトリスト。すべてのファイル操作は、.. の正規化後にこのリストに対して検証されます。リスト外のリクエストは拒否されます。サブパスはアクセスを継承します(例: /data/proj が許可されていれば /data/proj/sub/file.py も許可されます)。

  • security.blocked_commandsssh_run_command が実行を拒否するシェルコマンドのパターンリストと、そのブロックリスト。デフォルトでは危険な操作 (rm -rf /mkfsshutdown、フォーク爆弾、ブロックデバイスへの生書き込み) をカバーしています。リストを拡張することはできますが、正当なニーズを「解決」するために弱めてはいけませんセキュリティモデル を参照してください。

リソース制限

フィールド

影響

デフォルト

max_file_size_mb

ssh_read_file はこの値を超えるファイルを拒否する

50

max_output_chars

ssh_run_command はこの文字を超えた出力を切り捨てる

100000

command_timeout

ssh_run_command はこの秒数後に強制終了する

30


認証

キー認証(推奨)

# On your local machine
ssh-keygen -t ed25519 -C "you@example.com"

# Push the public key to the remote
ssh-copy-id -i ~/.ssh/id_ed25519.pub user@server

次に、config.json で指定します:

"auth": {
  "type": "key",
  "key_path": "~/.ssh/id_ed25519",
  "key_password": ""
}

key_password は、秘密鍵自体が暗号化されている場合にのみ必要です。

パスワード認証

"auth": {
  "type": "password",
  "password": "your-password"
}

パスワードは config.json に平文で保存されます。キー認証を推奨します。


GUI マネージャー(オプション)

小さな Tk ベースの GUI で、複数のサーバープロファイルを管理し、切り替えることができます:

# From source
python server_manager.py

# Or build a standalone Windows exe and put it on PATH
pip install -e ".[gui]"   # adds pyinstaller
python build.py
python setup_global.py
# now `SSH-Server-Manager` is on PATH

プロファイルは profiles.json に保存されます。切り替えると、選択したプロファイルが config.json にコピーされるため、次回起動時に MCP サーバーがそれを読み込みます。


セキュリティモデル

このサーバーは意図的に制限的な設計です。リモートホストを保護する 2 つの独立したレイヤがあります:

  1. パスのスコープ制御。 すべてのファイル操作は正規化 (.. を解決し、重複スラッシュをまとめる) され、その後 allowed_paths に対して検証されます。このリストから抜け出す方法はありません — チェックはリモート側でパスが解決された後にサーバー側で行われます。

  2. コマンドフィルタリング。 ssh_run_commandsecurity.blocked_commands(部分一致)に一致するコマンドを拒否します。既定のリストは、再帰的な破壊、ブロックデバイスへの生書き込み、システムのシャットダウン、フォーク爆弾、リモートシェルインストーラー (curl … | sh) をブロックします。特定のことを許可する必要がある場合はリストを拡張できますが、根本的に無効化してはいけません

このサーバーが行わないこと:

  • リモートで root として実行しません。root 以外のユーザーで接続してください。

  • sudo をバイパスしません。設定されたユーザーが sudo できなければ、サーバーもできません。

  • 対話シェルを提供しません。長時間実行されるプロセスは command_timeout によって強制終了されます。


トラブルシューティング

症状

考えられる原因

修正方法

claude mcp list が何も表示しない

正しいスコープに登録されていない、または claude CLI のバージョンが ~/.claude/settings.json を読まない

ルート claude mcp add --scope user ...(~/.claude.json に書き込み)

ModuleNotFoundError: No module named 'mcp'

パッケージが claude が使用する Python と異なる Python にインストールされた

Claude Code に使用するインタープリータ・ラで install.py を実行する

ERROR: ssh.host is required

設定ファイルがまだプレースホルダーのまま

~/.ssh-mcp-server/config.json を編集して your-server.example.comCHANGE_ME などを置き換える

Access denied: outside allowed paths

LLM が試したパスが allowed_paths に含まれていない

設定の allowed_paths にそのパスを追加する

Command blocked: dangerous pattern

LLM がブラックリストにあるコマンドを試した

本当に必要な場合のみ security.blocked_commands を調整する

SSH authentication failed

認証情報が誤っている、またはユーザーが間違っている

通常のシェルで ssh user@host を実行して確認する

サーバーは起動するが Claude Code にツールが表示されない

VSCode 拡張機能のプロセスが古い

VSCode を完全に終了して再起動する


プロジェクト構成

server/
├── ssh_mcp_server/         # MCP server package (the actual product)
│   ├── server.py           #   tool definitions
│   ├── ssh_client.py       #   paramiko wrapper
│   ├── security.py         #   path + command validation
│   └── config.py           #   config loader
├── server_manager.py       # Tk GUI for managing profiles
├── profiles.json           # GUI profile store
├── config.json             # runtime config template (placeholder values)
├── setup.py                # pip-installable package metadata
├── install.py              # one-shot installer (install + register)
├── setup_global.py         # optional: deploy GUI exe to PATH
├── build.py                # optional: PyInstaller wrapper for the GUI
├── SSH-Server-Manager.spec # PyInstaller spec for fine-grained builds
├── requirements.txt        # raw dependency pins
├── LICENSE                 # MIT
├── README.md               # this file (English)
└── README.zh.md            # Chinese translation

ライセンス

MIT — 全テキストはファイルを参照してください。

A
license - permissive license
Not graded
quality - not tested
B
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

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

Related MCP Servers

  • A
    license
    A
    quality
    C
    maintenance
    Enables SSH remote access to servers through Claude, allowing users to execute commands, transfer files via SFTP, and manage multiple remote connections using natural language.
    12
    8
    MIT
  • A
    license
    Not graded
    quality
    Not graded
    maintenance
    Connects Claude to remote servers via SSH to execute commands, manage files, and browse directories. It allows users to add, edit, and switch between multiple server configurations through natural language conversations.
  • -
    license
    Not graded
    quality
    Not graded
    maintenance
    Enables Claude Code to control remote servers via SSH for automated deployment, testing, and operations, including command execution and file transfer.
    4

View all related MCP servers

Related MCP Connectors

  • Operate Linux, macOS and Windows from your LLM. Every action runs through an auditable allowlist.

  • Let AI operate servers without SSH. Choose actions, approve risky changes, and audit every step.

  • Read, edit, publish, and preview your pepita websites from Claude.

View all MCP Connectors

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/zhangqi-eiq/server_mcp'

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