ssh-mcp
Enables remote server management via SSH, including command execution, file transfer (SFTP), and interactive shell sessions, with support for multiple hosts.
README
ssh-mcp
MCP server ที่เปิดให้ Claude (หรือ MCP client อื่น) สั่งงานเครื่องปลายทางผ่าน SSH ได้ —
รันคำสั่ง, อ่าน/เขียนไฟล์, โอนไฟล์ SFTP และเปิด shell แบบ interactive
กำหนดหลายโฮสต์ผ่านไฟล์ .env ยืนยันตัวตนด้วย username/password
ความสามารถ (Tools)
| Tool | หน้าที่ |
|---|---|
ssh_list_hosts |
แสดงรายชื่อโฮสต์ที่ตั้งค่าไว้ (ไม่คืน password) |
ssh_exec |
รันคำสั่ง คืน stdout / stderr / exit_status |
ssh_read_file |
อ่านไฟล์ปลายทางผ่าน SFTP |
ssh_write_file |
เขียน/สร้างไฟล์ปลายทางผ่าน SFTP |
ssh_list_dir |
แสดงรายการไฟล์ในไดเรกทอรีปลายทาง |
ssh_upload |
อัปโหลดไฟล์ในเครื่อง → ปลายทาง |
ssh_download |
ดาวน์โหลดไฟล์ปลายทาง → เครื่องนี้ |
ssh_session_open |
เปิด interactive shell คืน session_id |
ssh_session_send |
ส่งข้อความ/คำสั่งเข้าเซสชัน แล้วคืน output |
ssh_session_read |
อ่าน output ที่ค้างในเซสชัน |
ssh_session_close |
ปิดเซสชัน |
ssh_list_sessions |
แสดงเซสชันที่เปิดอยู่ |
ติดตั้ง
pip install -r requirements.txt
# หรือแบบ editable พร้อม console script `ssh-mcp`
pip install -e .
ตั้งค่า
คัดลอก .env.example → .env แล้วแก้ค่าโฮสต์จริง แต่ละโฮสต์เป็น "profile" ตามรูปแบบ prefix:
SSH_PROFILES=prod,staging
SSH_PROD_HOST=10.0.0.1
SSH_PROD_PORT=22
SSH_PROD_USER=root
SSH_PROD_PASSWORD=secret
SSH_STAGING_HOST=10.0.0.2
SSH_STAGING_USER=deploy
SSH_STAGING_PASSWORD=secret
- ชื่อ profile (ตัวพิมพ์เล็ก เช่น
prod,staging) คือค่าที่ส่งเป็น argumenthostของแต่ละ tool SSH_PROFILESระบุ/จัดลำดับ profile ที่จะเปิดใช้ ถ้าเว้นว่างจะ auto-detect จากSSH_*_HOSTทั้งหมด- Global options:
SSH_CONNECT_TIMEOUT,SSH_COMMAND_TIMEOUT,SSH_KNOWN_HOSTS_POLICY(auto_add|reject)
ความปลอดภัย:
.envอยู่ใน.gitignoreอยู่แล้ว อย่า commit ค่าจริง สำหรับ production แนะนำตั้งSSH_KNOWN_HOSTS_POLICY=reject(โฮสต์ต้องอยู่ใน~/.ssh/known_hosts)
รัน
python -m ssh_mcp.server # stdio transport
# หรือ (หลัง pip install -e .)
ssh-mcp
เชื่อมกับ Claude Code / Claude Desktop
เพิ่มเข้าไฟล์ config MCP:
{
"mcpServers": {
"ssh": {
"command": "python",
"args": ["-m", "ssh_mcp.server"],
"cwd": "d:\\AI\\apos"
}
}
}
ทดสอบด้วย MCP Inspector
npx @modelcontextprotocol/inspector python -m ssh_mcp.server
แล้วลองเรียก ssh_list_hosts → ssh_exec (เช่น whoami) → วงจร ssh_session_open / ssh_session_send / ssh_session_close
ตัวอย่างการใช้ interactive session
ssh_session_open(host="prod")→ ได้session_idssh_session_send(session_id, data="top\n")→ คืน output รอบแรกssh_session_send(session_id, data="q")เพื่อออกจาก topssh_session_close(session_id)
หมายเหตุ:
ssh_session_sendไม่เติม newline ให้อัตโนมัติ — ต้องใส่\nเองเมื่อต้องการกด enter
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
Neon Database
MCP server for interacting with Neon Management API and databases
E2B
Using MCP to run code via e2b.
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.