Skip to main content
Glama
README.md4.96 kB
# ssh-mcp-remote Remote MCP-style HTTP+SSE server that exposes simple tools including `ssh.exec` for executing commands on remote hosts over SSH. ## 概要 - Node.js + Express による HTTP サーバー - MCP Remote Connector から利用できるような形で、以下の 2 エンドポイントを提供します: - `GET /sse` : サーバーからのイベントを受け取るための SSE ストリーム - `POST /query`: MCP 風のツール呼び出し (`search`, `fetch`, `ssh.exec`) - レスポンスは MCP 互換の形に近づけるため、必ず次の形を返します: ```json { "content": [ { "type": "text", "text": "<JSON文字列>" } ] } ``` `text` フィールド内に、実際の JSON オブジェクトを文字列化したものが入ります。 ## セットアップ リポジトリのルート (`ghostfolio`) で依存をインストールします。 ```powershell cd ssh-mcp-remote npm install ``` ## 起動方法 ```powershell cd ssh-mcp-remote npm start ``` デフォルトではポート `8787` で起動します。Replit や Render などのホスティング環境では、環境変数 `PORT` が自動的に付与されるため、それを利用してリッスンします。 起動後: - `http://localhost:8787/` : ヘルスチェック用の簡単な JSON レスポンス - `http://localhost:8787/sse`: SSE ストリーム (ブラウザや MCP Remote Connector が接続) - `POST http://localhost:8787/query`: MCP 風ツール呼び出し ## /query の使い方 ### search ツール (ダミー) ```bash curl -X POST http://localhost:8787/query \ -H "Content-Type: application/json" \ -d '{ "tool": "search", "query": "ssh" }' ``` 返り値は `ssh` ツール 1 件だけを含むダミーのレスポンスです。 ### fetch ツール (ダミー) ```bash curl -X POST http://localhost:8787/query \ -H "Content-Type: application/json" \ -d '{ "tool": "fetch", "id": "ssh" }' ``` `search` と同様のダミー応答を返します。 ### ssh.exec ツール ```bash curl -X POST http://localhost:8787/query \ -H "Content-Type: application/json" \ -d '{ "tool": "ssh.exec", "args": { "host": "192.168.0.x", "user": "mizuki", "password": "your-password", "command": "ls -la" } }' ``` または `username` や `privateKey` も利用可能です: ```bash curl -X POST http://localhost:8787/query \ -H "Content-Type: application/json" \ -d '{ "tool": "ssh.exec", "args": { "host": "192.168.0.x", "username": "mizuki", "privateKey": "C:/Users/you/.ssh/id_rsa", "command": "uname -a" } }' ``` レスポンスの `content[0].text` 内には、次のような JSON 文字列が入ります: ```json { "host": "192.168.0.x", "user": "mizuki", "command": "ls -la", "stdout": "...", "stderr": "...", "code": 0, "error": null } ``` 同時に、SSE に接続しているクライアントには `type: "ssh.exec.result"` のイベントとして同じ内容が PUSH されます。 ## ChatGPT MCP Remote Connector への登録例 > 実際の UI や設定方法は ChatGPT のバージョンによって異なります。ここでは概念的な例を示します。 - **Server URL (ローカル)**: `http://localhost:8787` - **SSE Endpoint**: `/sse` - **Query Endpoint**: `/query` Remote MCP Connector の設定画面が以下のような項目を要求する場合: - Base URL: `http://localhost:8787` - SSE Path: `/sse` - Query Path: `/query` と設定すれば、このサーバーが Remote MCP として機能します。 ### クラウド (Replit / Render) にデプロイした場合の URL 例 Replit や Render にこのプロジェクトをデプロイした場合、ベース URL は以下のようになります。 - **Base URL (Render)**: `https://ssh-mcp-remote.onrender.com` (サービス名に応じて変わります) - **Base URL (Replit)**: `https://your-repl-name.your-username.repl.co` - **SSE Path**: `/sse` - **Query Path**: `/query` ChatGPT MCP Remote Connector 側では、上記の Base URL とパスを指定してください。 例: Render に `ssh-mcp-remote` という名前でデプロイした場合: - Base URL: `https://ssh-mcp-remote.onrender.com` - SSE Path: `/sse` - Query Path: `/query` ## 推奨コマンドまとめ ```bash # セットアップ cd ssh-mcp-remote npm install # 起動 npm start # 動作確認 (例: ssh.exec) curl -X POST http://localhost:8787/query \ -H "Content-Type: application/json" \ -d '{ "tool": "ssh.exec", "args": { "host": "192.168.0.x", "user": "mizuki", "password": "your-password", "command": "ls -la" } }' ``` この構成を元に、ChatGPT MCP Remote Connector から `ssh.exec` を呼び出せば、NAS や Linux/VPS 上でコマンドを実行し、その結果を ChatGPT 側で扱えるようになります。

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/shiroi1229/ssh-mcp-remote'

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