mcp-ssh-server-tool 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -105
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,6 +9,12 @@
|
|
|
9
9
|
- 💻 **远程命令执行** - 在连接的服务器上执行命令并获取输出
|
|
10
10
|
- 📊 **会话管理** - 管理多个 SSH 连接会话
|
|
11
11
|
|
|
12
|
+
## 安装
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npx -y mcp-ssh-server-tool
|
|
16
|
+
```
|
|
17
|
+
|
|
12
18
|
## MCP 工具
|
|
13
19
|
|
|
14
20
|
### ssh_connect
|
|
@@ -34,7 +40,7 @@
|
|
|
34
40
|
**返回:**
|
|
35
41
|
- `stdout`: 标准输出
|
|
36
42
|
- `stderr`: 标准错误
|
|
37
|
-
- `
|
|
43
|
+
- `exitCode`: 退出码
|
|
38
44
|
|
|
39
45
|
### ssh_disconnect
|
|
40
46
|
断开 SSH 连接
|
|
@@ -45,93 +51,6 @@
|
|
|
45
51
|
### ssh_list_sessions
|
|
46
52
|
列出所有活动的 SSH 会话
|
|
47
53
|
|
|
48
|
-
## 安装
|
|
49
|
-
|
|
50
|
-
### 步骤 1: 安装依赖
|
|
51
|
-
|
|
52
|
-
在终端中运行:
|
|
53
|
-
```bash
|
|
54
|
-
pip install paramiko mcp
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
### 步骤 2: 安装 SSH MCP Server
|
|
58
|
-
|
|
59
|
-
```bash
|
|
60
|
-
pip install -e .
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
## 配置
|
|
64
|
-
|
|
65
|
-
### 重要: 确保依赖已安装
|
|
66
|
-
|
|
67
|
-
在使用 MCP 之前,请确保你的 AI 客户端使用的 Python 环境中已安装依赖:
|
|
68
|
-
|
|
69
|
-
```bash
|
|
70
|
-
pip install paramiko mcp
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
### Claude Desktop 配置
|
|
74
|
-
|
|
75
|
-
在 Claude Desktop 的配置文件中添加:
|
|
76
|
-
|
|
77
|
-
**Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
|
|
78
|
-
|
|
79
|
-
```json
|
|
80
|
-
{
|
|
81
|
-
"mcpServers": {
|
|
82
|
-
"ssh-mcp-server": {
|
|
83
|
-
"command": "python",
|
|
84
|
-
"args": ["-m", "mcp_ssh_server.index"],
|
|
85
|
-
"env": {}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
### Cursor / VS Code 配置
|
|
92
|
-
|
|
93
|
-
在 `.cursor/mcp.json` 或 `.vscode/mcp.json` 中添加相同配置:
|
|
94
|
-
|
|
95
|
-
```json
|
|
96
|
-
{
|
|
97
|
-
"mcpServers": {
|
|
98
|
-
"ssh-mcp-server": {
|
|
99
|
-
"command": "python",
|
|
100
|
-
"args": ["-m", "mcp_ssh_server.index"],
|
|
101
|
-
"env": {}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
### 故障排除
|
|
108
|
-
|
|
109
|
-
如果遇到 `Connection closed` 错误:
|
|
110
|
-
|
|
111
|
-
1. **确认依赖已安装**:
|
|
112
|
-
```bash
|
|
113
|
-
python -c "import paramiko; import mcp; print('OK')"
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
2. **检查 Python 路径**: 在终端中运行以下命令获取 Python 路径,并在配置中使用完整路径:
|
|
117
|
-
```bash
|
|
118
|
-
where python # Windows
|
|
119
|
-
which python # Linux/Mac
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
3. **使用完整路径配置**:
|
|
123
|
-
```json
|
|
124
|
-
{
|
|
125
|
-
"mcpServers": {
|
|
126
|
-
"ssh-mcp-server": {
|
|
127
|
-
"command": "C:\\Users\\你的用户名\\anaconda3\\python.exe",
|
|
128
|
-
"args": ["-m", "mcp_ssh_server.index"],
|
|
129
|
-
"env": {}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
```
|
|
134
|
-
|
|
135
54
|
## 使用示例
|
|
136
55
|
|
|
137
56
|
### 1. 密码认证连接
|
|
@@ -154,7 +73,7 @@ pip install paramiko mcp
|
|
|
154
73
|
"port": 22,
|
|
155
74
|
"username": "admin",
|
|
156
75
|
"auth_type": "public_key",
|
|
157
|
-
"private_key_path": "
|
|
76
|
+
"private_key_path": "/home/user/.ssh/id_rsa"
|
|
158
77
|
}
|
|
159
78
|
```
|
|
160
79
|
|
|
@@ -175,24 +94,11 @@ pip install paramiko mcp
|
|
|
175
94
|
}
|
|
176
95
|
```
|
|
177
96
|
|
|
178
|
-
## 项目结构
|
|
179
|
-
|
|
180
|
-
```
|
|
181
|
-
SSH-MCP/
|
|
182
|
-
├── mcp_ssh_server/
|
|
183
|
-
│ ├── __init__.py
|
|
184
|
-
│ ├── index.py # MCP Server 主入口
|
|
185
|
-
│ └── ssh_manager.py # SSH 连接管理器
|
|
186
|
-
├── pyproject.toml # Python 项目配置
|
|
187
|
-
├── mcp.json # MCP 配置文件示例
|
|
188
|
-
└── README.md # 使用说明
|
|
189
|
-
```
|
|
190
|
-
|
|
191
97
|
## 依赖
|
|
192
98
|
|
|
193
|
-
-
|
|
194
|
-
-
|
|
195
|
-
-
|
|
99
|
+
- Node.js >= 18.0.0
|
|
100
|
+
- ssh2 >= 1.15.0
|
|
101
|
+
- uuid >= 9.0.0
|
|
196
102
|
|
|
197
103
|
## License
|
|
198
104
|
|