ssh-client-mcp-server 1.1.0 → 1.3.1
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 +108 -50
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -121
- package/dist/index.js.map +1 -0
- package/package.json +69 -14
package/README.md
CHANGED
|
@@ -1,92 +1,150 @@
|
|
|
1
1
|
# SSH Client MCP Server
|
|
2
2
|
|
|
3
3
|
[](./LICENSE)
|
|
4
|
-
[](https://www.npmjs.com/package/ssh-mcp)
|
|
4
|
+
[](https://www.npmjs.com/package/ssh-client-mcp-server)
|
|
5
|
+
[](https://github.com/jordanburke/ssh-client-mcp-server/actions/workflows/ci.yml)
|
|
5
6
|
|
|
6
|
-
**SSH Client MCP Server** is a local Model Context Protocol (MCP) server that
|
|
7
|
+
**SSH Client MCP Server** is a local Model Context Protocol (MCP) server that lets LLMs and other MCP clients execute shell commands on remote hosts over SSH. It runs from Linux, macOS, or Windows and targets any reachable SSH server (Linux, macOS, Windows with OpenSSH, etc.).
|
|
8
|
+
|
|
9
|
+
Built on [`somamcp`](https://github.com/sapientsai/SomaMCP) — a functional MCP framework over FastMCP with telemetry, introspection, and backend abstraction.
|
|
7
10
|
|
|
8
11
|
## Contents
|
|
9
12
|
|
|
10
13
|
- [Quick Start](#quick-start)
|
|
11
14
|
- [Features](#features)
|
|
15
|
+
- [Tools](#tools)
|
|
12
16
|
- [Installation](#installation)
|
|
17
|
+
- [Configuration](#configuration)
|
|
13
18
|
- [Client Setup](#client-setup)
|
|
14
19
|
- [Testing](#testing)
|
|
20
|
+
- [Development](#development)
|
|
15
21
|
- [Disclaimer](#disclaimer)
|
|
16
|
-
- [Support](#support)
|
|
17
22
|
|
|
18
23
|
## Quick Start
|
|
19
24
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
25
|
+
1. Configure your MCP client (Claude Desktop, Cursor, Cline, etc.) to launch this server via `npx` — see [Client Setup](#client-setup).
|
|
26
|
+
2. Ask your LLM to run shell commands on the target host.
|
|
27
|
+
|
|
28
|
+
No global install required — `npx` fetches and runs the latest published version.
|
|
24
29
|
|
|
25
30
|
## Features
|
|
26
31
|
|
|
27
|
-
-
|
|
28
|
-
-
|
|
29
|
-
-
|
|
30
|
-
-
|
|
32
|
+
- **Single `exec` tool** — runs a shell command on the remote host, returns stdout. stderr surfaces as a structured error.
|
|
33
|
+
- **Auth** — password or SSH private key (or defer to the SSH agent when no credentials are provided).
|
|
34
|
+
- **Smart path expansion** — `--key` supports `~`, `$VAR`, `${VAR}`, and relative paths via [`functype-os`](https://github.com/jordanburke/functype-os). Unresolved variables fail fast with a typed error.
|
|
35
|
+
- **OS-user fallback** — `--user` defaults to the current OS username when omitted.
|
|
36
|
+
- **Fail-fast auth** — the SSH key is loaded and validated at server startup, not on the first `exec` call.
|
|
37
|
+
- **Introspection out-of-the-box** — `soma_health`, `soma_capabilities`, `soma_connections` auto-registered by somamcp.
|
|
38
|
+
- **Cross-platform** — runs on Linux, macOS, Windows (anywhere Node 22+ runs).
|
|
31
39
|
|
|
32
|
-
|
|
40
|
+
## Tools
|
|
33
41
|
|
|
34
|
-
|
|
42
|
+
| Tool | Description |
|
|
43
|
+
| ------------------- | ------------------------------------------------------------------- |
|
|
44
|
+
| `exec` | Execute a shell command on the remote SSH server and return stdout. |
|
|
45
|
+
| `soma_health` | Server uptime, status, active session count. |
|
|
46
|
+
| `soma_capabilities` | Enumerate registered tools, resources, and prompts. |
|
|
47
|
+
| `soma_connections` | Gateway connection status (unused here). |
|
|
35
48
|
|
|
36
49
|
## Installation
|
|
37
50
|
|
|
38
|
-
|
|
39
|
-
```bash
|
|
40
|
-
git clone https://github.com/jordanburke/ssh-client-mcp-server.git
|
|
41
|
-
cd ssh-client-mcp-server
|
|
42
|
-
```
|
|
43
|
-
2. **Install dependencies:**
|
|
44
|
-
```bash
|
|
45
|
-
pnpm install
|
|
46
|
-
```
|
|
51
|
+
### Run via `npx` (recommended)
|
|
47
52
|
|
|
48
|
-
|
|
53
|
+
No install step — your MCP client launches it on demand. See [Client Setup](#client-setup).
|
|
54
|
+
|
|
55
|
+
### Global install
|
|
49
56
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
57
|
+
```bash
|
|
58
|
+
npm install -g ssh-client-mcp-server
|
|
59
|
+
# then:
|
|
60
|
+
ssh-client-mcp-server --host=1.2.3.4 --user=root --password=pass
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### From source (for contributors)
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
git clone https://github.com/jordanburke/ssh-client-mcp-server.git
|
|
67
|
+
cd ssh-client-mcp-server
|
|
68
|
+
pnpm install
|
|
69
|
+
pnpm build
|
|
70
|
+
```
|
|
56
71
|
|
|
72
|
+
## Configuration
|
|
57
73
|
|
|
58
|
-
|
|
74
|
+
The server reads SSH connection info from CLI flags:
|
|
75
|
+
|
|
76
|
+
| Flag | Required | Default | Description |
|
|
77
|
+
| ------------ | -------- | ----------- | ------------------------------------------------------------------------------ |
|
|
78
|
+
| `--host` | yes | — | Hostname or IP of the remote SSH server. |
|
|
79
|
+
| `--user` | no | OS username | SSH username. Falls back to the local OS user (`whoami`) when omitted. |
|
|
80
|
+
| `--port` | no | `22` | SSH port. |
|
|
81
|
+
| `--password` | no\* | — | SSH password. |
|
|
82
|
+
| `--key` | no\* | — | Path to a private SSH key. Supports `~`, `$VAR`, `${VAR}`, and relative paths. |
|
|
83
|
+
|
|
84
|
+
\*If both `--password` and `--key` are omitted, the server starts anyway and delegates authentication to the SSH agent (or fails on first `exec` if none is available).
|
|
85
|
+
|
|
86
|
+
## Client Setup
|
|
87
|
+
|
|
88
|
+
### Claude Desktop (`claude_desktop_config.json`)
|
|
89
|
+
|
|
90
|
+
```json
|
|
59
91
|
{
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
"ssh-client-mcp-server",
|
|
65
|
-
"-y",
|
|
66
|
-
"--",
|
|
67
|
-
"--host=1.2.3.4",
|
|
68
|
-
"--port=22",
|
|
69
|
-
"--user=root",
|
|
70
|
-
"--password=pass",
|
|
71
|
-
"--key=path/to/key"
|
|
72
|
-
]
|
|
73
|
-
}
|
|
92
|
+
"mcpServers": {
|
|
93
|
+
"ssh-client-mcp-server": {
|
|
94
|
+
"command": "npx",
|
|
95
|
+
"args": ["-y", "ssh-client-mcp-server", "--host=1.2.3.4", "--user=root", "--key=~/.ssh/id_ed25519"]
|
|
74
96
|
}
|
|
97
|
+
}
|
|
75
98
|
}
|
|
76
99
|
```
|
|
77
100
|
|
|
101
|
+
### Password auth
|
|
102
|
+
|
|
103
|
+
Replace the `--key` arg with `--password=hunter2`. Avoid checking this into version control.
|
|
104
|
+
|
|
105
|
+
### Using the current OS user
|
|
106
|
+
|
|
107
|
+
Omit `--user` entirely — the server defaults to your local username.
|
|
108
|
+
|
|
109
|
+
### Other MCP clients
|
|
110
|
+
|
|
111
|
+
Any client that speaks the stdio MCP transport works. Same `command` / `args` shape.
|
|
112
|
+
|
|
78
113
|
## Testing
|
|
79
114
|
|
|
80
|
-
|
|
115
|
+
### Against a published build
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
npx @modelcontextprotocol/inspector npx ssh-client-mcp-server --host=1.2.3.4 --user=root --key=~/.ssh/id_ed25519
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Against a local build (after `pnpm build`)
|
|
81
122
|
|
|
82
|
-
```
|
|
83
|
-
pnpm
|
|
123
|
+
```bash
|
|
124
|
+
pnpm inspect
|
|
84
125
|
```
|
|
85
126
|
|
|
127
|
+
This builds and launches the [MCP Inspector](https://modelcontextprotocol.io/docs/tools/inspector) pointed at `dist/index.js`.
|
|
128
|
+
|
|
129
|
+
## Development
|
|
130
|
+
|
|
131
|
+
All tooling is delegated to [`ts-builds`](https://github.com/jordanburke/ts-builds):
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
pnpm validate # format → lint → typecheck → test → build
|
|
135
|
+
pnpm test # vitest run
|
|
136
|
+
pnpm test:watch # vitest watch mode
|
|
137
|
+
pnpm build # production build to dist/
|
|
138
|
+
pnpm dev # tsdown watch mode to lib/
|
|
139
|
+
pnpm inspect # build + launch MCP Inspector
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Pure helpers (`parseArgv`, `validateConfig`, `resolveAuth`, `effectiveUser`) live in `src/config.ts` and are covered by `test/config.spec.ts` (18 cases, including tempfile-backed key reads and env-var expansion).
|
|
143
|
+
|
|
86
144
|
## Disclaimer
|
|
87
145
|
|
|
88
|
-
|
|
146
|
+
Provided under the [MIT License](./LICENSE). Use at your own risk. Not affiliated with or endorsed by any SSH vendor or MCP provider. Be careful granting LLMs shell access — audit commands, restrict target-account privileges, and consider a jump box.
|
|
89
147
|
|
|
90
|
-
##
|
|
148
|
+
## Contributing
|
|
91
149
|
|
|
92
|
-
|
|
150
|
+
Issues and PRs welcome at [jordanburke/ssh-client-mcp-server](https://github.com/jordanburke/ssh-client-mcp-server). Please run `pnpm validate` before submitting.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/index.js
CHANGED
|
@@ -1,122 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { ErrorCode, McpError } from "@modelcontextprotocol/sdk/types.js";
|
|
6
|
-
import { Client as SSHClient } from "ssh2";
|
|
7
|
-
import { z } from "zod";
|
|
8
|
-
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
9
|
-
function parseArgv() {
|
|
10
|
-
const args = process.argv.slice(2);
|
|
11
|
-
const config = {};
|
|
12
|
-
for (const arg of args) {
|
|
13
|
-
const match = arg.match(/^--([^=]+)=(.*)$/);
|
|
14
|
-
if (match) {
|
|
15
|
-
config[match[1]] = match[2];
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
return config;
|
|
19
|
-
}
|
|
20
|
-
var argvConfig = parseArgv();
|
|
21
|
-
var HOST = argvConfig.host;
|
|
22
|
-
var PORT = argvConfig.port ? parseInt(argvConfig.port) : 22;
|
|
23
|
-
var USER = argvConfig.user;
|
|
24
|
-
var PASSWORD = argvConfig.password;
|
|
25
|
-
var KEY = argvConfig.key;
|
|
26
|
-
function validateConfig(config) {
|
|
27
|
-
const errors = [];
|
|
28
|
-
if (!config.host) errors.push("Missing required --host");
|
|
29
|
-
if (!config.user) errors.push("Missing required --user");
|
|
30
|
-
if (config.port && isNaN(Number(config.port))) errors.push("Invalid --port");
|
|
31
|
-
if (errors.length > 0) {
|
|
32
|
-
throw new Error("Configuration error:\n" + errors.join("\n"));
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
validateConfig(argvConfig);
|
|
36
|
-
var server = new McpServer({
|
|
37
|
-
name: "SSH MCP Server",
|
|
38
|
-
version: "1.0.5",
|
|
39
|
-
capabilities: {
|
|
40
|
-
resources: {},
|
|
41
|
-
tools: {}
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
server.tool(
|
|
45
|
-
"exec",
|
|
46
|
-
"Execute a shell command on the remote SSH server and return the output.",
|
|
47
|
-
{
|
|
48
|
-
command: z.string().describe("Shell command to execute on the remote SSH server")
|
|
49
|
-
},
|
|
50
|
-
async ({ command }) => {
|
|
51
|
-
if (typeof command !== "string" || !command.trim()) {
|
|
52
|
-
throw new McpError(ErrorCode.InternalError, "Command must be a non-empty string.");
|
|
53
|
-
}
|
|
54
|
-
const sshConfig = {
|
|
55
|
-
host: HOST,
|
|
56
|
-
port: PORT,
|
|
57
|
-
username: USER
|
|
58
|
-
};
|
|
59
|
-
try {
|
|
60
|
-
if (PASSWORD) {
|
|
61
|
-
sshConfig.password = PASSWORD;
|
|
62
|
-
} else if (KEY) {
|
|
63
|
-
const fs = await import("fs/promises");
|
|
64
|
-
sshConfig.privateKey = await fs.readFile(KEY, "utf8");
|
|
65
|
-
}
|
|
66
|
-
const result = await execSshCommand(sshConfig, command);
|
|
67
|
-
return result;
|
|
68
|
-
} catch (err) {
|
|
69
|
-
if (err instanceof McpError) throw err;
|
|
70
|
-
throw new McpError(ErrorCode.InternalError, `Unexpected error: ${err?.message || err}`);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
);
|
|
74
|
-
async function execSshCommand(sshConfig, command) {
|
|
75
|
-
return new Promise((resolve, reject) => {
|
|
76
|
-
const conn = new SSHClient();
|
|
77
|
-
conn.on("ready", () => {
|
|
78
|
-
conn.exec(command, (err, stream) => {
|
|
79
|
-
if (err) {
|
|
80
|
-
reject(new McpError(ErrorCode.InternalError, `SSH exec error: ${err.message}`));
|
|
81
|
-
conn.end();
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
let stdout = "";
|
|
85
|
-
let stderr = "";
|
|
86
|
-
stream.on("close", (code, signal) => {
|
|
87
|
-
conn.end();
|
|
88
|
-
if (stderr) {
|
|
89
|
-
reject(new McpError(ErrorCode.InternalError, `Error (code ${code}):
|
|
90
|
-
${stderr}`));
|
|
91
|
-
} else {
|
|
92
|
-
resolve({
|
|
93
|
-
content: [{
|
|
94
|
-
type: "text",
|
|
95
|
-
text: stdout
|
|
96
|
-
}]
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
stream.on("data", (data) => {
|
|
101
|
-
stdout += data.toString();
|
|
102
|
-
});
|
|
103
|
-
stream.stderr.on("data", (data) => {
|
|
104
|
-
stderr += data.toString();
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
conn.on("error", (err) => {
|
|
109
|
-
reject(new McpError(ErrorCode.InternalError, `SSH connection error: ${err.message}`));
|
|
110
|
-
});
|
|
111
|
-
conn.connect(sshConfig);
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
async function main() {
|
|
115
|
-
const transport = new StdioServerTransport();
|
|
116
|
-
await server.connect(transport);
|
|
117
|
-
console.error("SSH MCP Server running on stdio");
|
|
118
|
-
}
|
|
119
|
-
main().catch((error) => {
|
|
120
|
-
console.error("Fatal error in main():", error);
|
|
121
|
-
process.exit(1);
|
|
122
|
-
});
|
|
2
|
+
import{Left as e,List as t,Option as n,Right as r}from"functype";import{UserError as i,createServer as a}from"somamcp";import{Client as o}from"ssh2";import{z as s}from"zod";import{Fs as c,Path as l,Platform as u}from"functype-os";const d=e=>t(e).fold({},(e,t)=>{let n=t.match(/^--([^=]+)=(.*)$/);return n?{...e,[n[1]]:n[2]}:e}),f=e=>n(e.user).or(u.userInfo().map(e=>e.username)),p=i=>{let a=t.of(i.host?n.none():n(`Missing required --host`),f(i).fold(()=>n(`Missing --user (and OS user unavailable)`),e=>n.none()),i.port&&isNaN(Number(i.port))?n(`Invalid --port`):n.none()).flatMap(e=>e.toList());return a.isEmpty?r(void 0):e(`Configuration error:\n${a.toArray().join(`
|
|
3
|
+
`)}`)},m=async(t,n)=>{if(t.isSome())return r({password:t.value});if(n.isSome()){let t=l.expand(n.value);if(t.isLeft())return e(`Invalid SSH key path ${n.value}: ${t.value.message}`);let i=t.value;return(await c.readFile(i)).fold(t=>e(`Failed to read SSH key ${i}: ${t.message}`),e=>r({privateKey:e}))}return r({})},h=(e,t)=>new Promise((n,r)=>{let a=new o;a.on(`ready`,()=>{a.exec(t,(e,t)=>{if(e){r(new i(`SSH exec error: ${e.message}`)),a.end();return}let o=[],s=[];t.on(`close`,e=>{a.end();let t=Buffer.concat(o).toString(),c=Buffer.concat(s).toString();c?r(new i(`Error (code ${e}):\n${c}`)):n(t)}),t.on(`data`,e=>{o.push(e)}),t.stderr.on(`data`,e=>{s.push(e)})})}),a.on(`error`,e=>{r(new i(`SSH connection error: ${e.message}`))}),a.connect(e)});async function g(){let e=d(process.argv.slice(2));p(e).fold(e=>{console.error(e),process.exit(1)},()=>void 0);let{host:t}=e,r=f(e).orThrow(Error(`user unavailable after validation`)),i={host:t,port:n(e.port).map(Number).orElse(22),username:r,...(await m(n(e.password),n(e.key))).fold(e=>{console.error(e),process.exit(1)},e=>e)},o=a({name:`ssh-client-mcp-server`,version:`1.2.0`,instructions:`Execute shell commands on a remote host over SSH.`});o.addTool({name:`exec`,description:`Execute a shell command on the remote SSH server and return the output.`,parameters:s.object({command:s.string().min(1).describe(`Shell command to execute on the remote SSH server`)}),execute:async({command:e})=>h(i,e)}),await o.start({transportType:`stdio`}),console.error(`SSH MCP Server running on stdio`);let c=async()=>{await o.stop(),process.exit(0)};process.on(`SIGINT`,()=>void c()),process.on(`SIGTERM`,()=>void c())}g().catch(e=>{console.error(`Fatal error in main():`,e),process.exit(1)});export{};
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["SSHClient"],"sources":["../src/config.ts","../src/index.ts"],"sourcesContent":["import { type Either, Left, List, Option, Right } from \"functype\"\nimport { Fs, Path, Platform } from \"functype-os\"\nimport { type ConnectConfig } from \"ssh2\"\n\nexport type ArgvConfig = Readonly<Record<string, string>>\n\nexport const parseArgv = (args: ReadonlyArray<string>): ArgvConfig =>\n List(args).fold<Record<string, string>>({}, (acc, arg) => {\n const match = arg.match(/^--([^=]+)=(.*)$/)\n return match ? { ...acc, [match[1]]: match[2] } : acc\n })\n\n// If --user is omitted, fall back to the OS-reported username (`whoami`-style).\nexport const effectiveUser = (argv: ArgvConfig): Option<string> =>\n Option(argv.user).or(Platform.userInfo().map((info) => info.username))\n\nexport const validateConfig = (config: ArgvConfig): Either<string, void> => {\n const errors = List.of(\n config.host ? Option.none<string>() : Option(\"Missing required --host\"),\n effectiveUser(config).fold(\n () => Option(\"Missing --user (and OS user unavailable)\"),\n (_) => Option.none<string>(),\n ),\n config.port && isNaN(Number(config.port)) ? Option(\"Invalid --port\") : Option.none<string>(),\n ).flatMap((o) => o.toList())\n\n return errors.isEmpty\n ? Right<string, void>(undefined)\n : Left<string, void>(`Configuration error:\\n${errors.toArray().join(\"\\n\")}`)\n}\n\nexport const resolveAuth = async (\n password: Option<string>,\n keyPath: Option<string>,\n): Promise<Either<string, Partial<ConnectConfig>>> => {\n if (password.isSome()) {\n return Right<string, Partial<ConnectConfig>>({ password: password.value })\n }\n if (keyPath.isSome()) {\n const expandResult = Path.expand(keyPath.value)\n if (expandResult.isLeft()) {\n return Left<string, Partial<ConnectConfig>>(\n `Invalid SSH key path ${keyPath.value}: ${expandResult.value.message}`,\n )\n }\n const expanded = expandResult.value\n const result = await Fs.readFile(expanded)\n return result.fold<Either<string, Partial<ConnectConfig>>>(\n (err) => Left<string, Partial<ConnectConfig>>(`Failed to read SSH key ${expanded}: ${err.message}`),\n (contents) => Right<string, Partial<ConnectConfig>>({ privateKey: contents }),\n )\n }\n return Right<string, Partial<ConnectConfig>>({})\n}\n","#!/usr/bin/env node\n\nimport { Option } from \"functype\"\nimport { createServer, UserError } from \"somamcp\"\nimport { Client as SSHClient, type ConnectConfig } from \"ssh2\"\nimport { z } from \"zod\"\n\nimport { effectiveUser, parseArgv, resolveAuth, validateConfig } from \"./config.js\"\n\n// Example: node dist/index.js --host=1.2.3.4 --port=22 --user=root --password=pass --key=~/.ssh/id_rsa\n\nconst execSshCommand = (sshConfig: ConnectConfig, command: string): Promise<string> =>\n new Promise((resolve, reject) => {\n const conn = new SSHClient()\n conn.on(\"ready\", () => {\n conn.exec(command, (err, stream) => {\n if (err) {\n reject(new UserError(`SSH exec error: ${err.message}`))\n conn.end()\n return\n }\n const stdoutChunks: Buffer[] = []\n const stderrChunks: Buffer[] = []\n stream.on(\"close\", (code: number) => {\n conn.end()\n const stdout = Buffer.concat(stdoutChunks).toString()\n const stderr = Buffer.concat(stderrChunks).toString()\n if (stderr) {\n reject(new UserError(`Error (code ${code}):\\n${stderr}`))\n } else {\n resolve(stdout)\n }\n })\n stream.on(\"data\", (data: Buffer) => {\n stdoutChunks.push(data)\n })\n stream.stderr.on(\"data\", (data: Buffer) => {\n stderrChunks.push(data)\n })\n })\n })\n conn.on(\"error\", (err) => {\n reject(new UserError(`SSH connection error: ${err.message}`))\n })\n conn.connect(sshConfig)\n })\n\nasync function main() {\n const argv = parseArgv(process.argv.slice(2))\n\n validateConfig(argv).fold(\n (err) => {\n console.error(err)\n process.exit(1)\n },\n () => undefined,\n )\n\n const { host } = argv\n const user = effectiveUser(argv).orThrow(new Error(\"user unavailable after validation\"))\n const port = Option(argv.port).map(Number).orElse(22)\n const password = Option(argv.password)\n const keyPath = Option(argv.key)\n\n const authResult = await resolveAuth(password, keyPath)\n const authConfig = authResult.fold<Partial<ConnectConfig>>(\n (err) => {\n console.error(err)\n process.exit(1)\n },\n (cfg) => cfg,\n )\n\n const sshConfig: ConnectConfig = { host, port, username: user, ...authConfig }\n\n const server = createServer({\n name: \"ssh-client-mcp-server\",\n version: \"1.2.0\",\n instructions: \"Execute shell commands on a remote host over SSH.\",\n })\n\n server.addTool({\n name: \"exec\",\n description: \"Execute a shell command on the remote SSH server and return the output.\",\n parameters: z.object({\n command: z.string().min(1).describe(\"Shell command to execute on the remote SSH server\"),\n }),\n execute: async ({ command }) => execSshCommand(sshConfig, command),\n })\n\n await server.start({ transportType: \"stdio\" })\n console.error(\"SSH MCP Server running on stdio\")\n\n const shutdown = async () => {\n await server.stop()\n process.exit(0)\n }\n process.on(\"SIGINT\", () => void shutdown())\n process.on(\"SIGTERM\", () => void shutdown())\n}\n\nmain().catch((error) => {\n console.error(\"Fatal error in main():\", error)\n process.exit(1)\n})\n"],"mappings":";sOAMA,MAAa,EAAa,GACxB,EAAK,EAAK,CAAC,KAA6B,EAAE,EAAG,EAAK,IAAQ,CACxD,IAAM,EAAQ,EAAI,MAAM,mBAAmB,CAC3C,OAAO,EAAQ,CAAE,GAAG,GAAM,EAAM,IAAK,EAAM,GAAI,CAAG,GAClD,CAGS,EAAiB,GAC5B,EAAO,EAAK,KAAK,CAAC,GAAG,EAAS,UAAU,CAAC,IAAK,GAAS,EAAK,SAAS,CAAC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Ae,QAAS,CAAC,CAC9C,QAAQ,MAAM,kCAAkC,CAEhD,IAAM,EAAW,SAAY,CAC3B,MAAM,EAAO,MAAM,CACnB,QAAQ,KAAK,EAAE,EAEjB,QAAQ,GAAG,aAAgB,KAAK,GAAU,CAAC,CAC3C,QAAQ,GAAG,cAAiB,KAAK,GAAU,CAAC,CAG9C,GAAM,CAAC,MAAO,GAAU,CACtB,QAAQ,MAAM,yBAA0B,EAAM,CAC9C,QAAQ,KAAK,EAAE,EACf"}
|
package/package.json
CHANGED
|
@@ -1,30 +1,85 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ssh-client-mcp-server",
|
|
3
3
|
"license": "MIT",
|
|
4
|
-
"version": "1.1
|
|
5
|
-
"description": "
|
|
4
|
+
"version": "1.3.1",
|
|
5
|
+
"description": "MCP server that exposes SSH command execution to LLMs. Built on SomaMCP with functional config parsing (functype), path expansion (~, $VAR), and OS-user fallback.",
|
|
6
6
|
"author": "Jordan Burke <jordan.burke@gmail.com>",
|
|
7
|
+
"homepage": "https://github.com/jordanburke/ssh-client-mcp-server#readme",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/jordanburke/ssh-client-mcp-server.git"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/jordanburke/ssh-client-mcp-server/issues"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"mcp",
|
|
17
|
+
"ssh",
|
|
18
|
+
"ssh2",
|
|
19
|
+
"model-context-protocol",
|
|
20
|
+
"claude",
|
|
21
|
+
"anthropic",
|
|
22
|
+
"llm",
|
|
23
|
+
"remote-shell",
|
|
24
|
+
"somamcp",
|
|
25
|
+
"fastmcp",
|
|
26
|
+
"functype",
|
|
27
|
+
"typescript",
|
|
28
|
+
"cli"
|
|
29
|
+
],
|
|
30
|
+
"mcpName": "io.github.jordanburke/ssh-client-mcp-server",
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=22"
|
|
33
|
+
},
|
|
7
34
|
"type": "module",
|
|
35
|
+
"main": "./dist/index.js",
|
|
36
|
+
"module": "./dist/index.js",
|
|
37
|
+
"types": "./dist/index.d.ts",
|
|
38
|
+
"exports": {
|
|
39
|
+
".": {
|
|
40
|
+
"types": "./dist/index.d.ts",
|
|
41
|
+
"import": "./dist/index.js",
|
|
42
|
+
"default": "./dist/index.js"
|
|
43
|
+
}
|
|
44
|
+
},
|
|
8
45
|
"bin": {
|
|
9
46
|
"ssh-client-mcp-server": "dist/index.js"
|
|
10
47
|
},
|
|
11
48
|
"files": [
|
|
49
|
+
"lib",
|
|
12
50
|
"dist"
|
|
13
51
|
],
|
|
52
|
+
"scripts": {
|
|
53
|
+
"validate": "ts-builds validate",
|
|
54
|
+
"format": "ts-builds format",
|
|
55
|
+
"format:check": "ts-builds format:check",
|
|
56
|
+
"lint": "ts-builds lint",
|
|
57
|
+
"lint:check": "ts-builds lint:check",
|
|
58
|
+
"typecheck": "ts-builds typecheck",
|
|
59
|
+
"test": "ts-builds test",
|
|
60
|
+
"test:watch": "ts-builds test:watch",
|
|
61
|
+
"test:coverage": "ts-builds test:coverage",
|
|
62
|
+
"test:ui": "ts-builds test:ui",
|
|
63
|
+
"build": "ts-builds build",
|
|
64
|
+
"dev": "ts-builds dev",
|
|
65
|
+
"inspect": "pnpm build && npx @modelcontextprotocol/inspector dist/index.js",
|
|
66
|
+
"check:versions": "tsx scripts/check-versions.ts",
|
|
67
|
+
"prepublishOnly": "pnpm check:versions && pnpm validate"
|
|
68
|
+
},
|
|
69
|
+
"prettier": "ts-builds/prettier",
|
|
14
70
|
"dependencies": {
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
71
|
+
"functype": "^0.60.3",
|
|
72
|
+
"functype-os": "^0.60.0",
|
|
73
|
+
"somamcp": "^1.0.6",
|
|
74
|
+
"ssh2": "^1.17.0",
|
|
75
|
+
"zod": "^4.4.3"
|
|
18
76
|
},
|
|
19
77
|
"devDependencies": {
|
|
20
|
-
"@types/node": "^
|
|
78
|
+
"@types/node": "^24.12.2",
|
|
21
79
|
"@types/ssh2": "^1.15.5",
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
80
|
+
"ts-builds": "^2.7.2",
|
|
81
|
+
"tsdown": "^0.21.10",
|
|
82
|
+
"tsx": "^4.21.0"
|
|
25
83
|
},
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
"inspect": "pnpx @modelcontextprotocol/inspector node dist/index.js"
|
|
29
|
-
}
|
|
30
|
-
}
|
|
84
|
+
"packageManager": "pnpm@10.33.3+sha512.a19744364a7e248b92657a4ca5973f9354d21caf982579674b1c539f32c7420c47138ad8b1254df07aba9bc782d9b3029e3db34d5dbff974326eb74dac8ff489"
|
|
85
|
+
}
|