enterprise-ssh-mcp-server 0.3.1 → 0.3.3
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/CHANGELOG.md +19 -0
- package/README.md +112 -0
- package/dist/app/create-app.d.ts +4 -0
- package/dist/app/create-app.js +38 -0
- package/dist/app/create-app.js.map +1 -0
- package/dist/app/tool-context.d.ts +258 -0
- package/dist/app/tool-context.js +683 -0
- package/dist/app/tool-context.js.map +1 -0
- package/dist/env-profiles.d.ts +1 -0
- package/dist/env-profiles.js +6 -2
- package/dist/env-profiles.js.map +1 -1
- package/dist/env-reload.d.ts +36 -0
- package/dist/env-reload.js +65 -0
- package/dist/env-reload.js.map +1 -0
- package/dist/host-ca-trust-config.d.ts +10 -0
- package/dist/host-ca-trust-config.js +43 -0
- package/dist/host-ca-trust-config.js.map +1 -0
- package/dist/index.js +5 -1798
- package/dist/index.js.map +1 -1
- package/dist/openssh-command.d.ts +34 -0
- package/dist/openssh-command.js +217 -0
- package/dist/openssh-command.js.map +1 -0
- package/dist/openssh-temporary.d.ts +24 -0
- package/dist/openssh-temporary.js +82 -0
- package/dist/openssh-temporary.js.map +1 -0
- package/dist/openssh-trust.d.ts +15 -0
- package/dist/openssh-trust.js +91 -0
- package/dist/openssh-trust.js.map +1 -0
- package/dist/runtime-config.d.ts +1 -0
- package/dist/runtime-config.js +10 -1
- package/dist/runtime-config.js.map +1 -1
- package/dist/ssh-host-key.d.ts +27 -0
- package/dist/ssh-host-key.js +235 -0
- package/dist/ssh-host-key.js.map +1 -0
- package/dist/ssh-session.js +7 -3
- package/dist/ssh-session.js.map +1 -1
- package/dist/ssh-target.d.ts +19 -0
- package/dist/ssh-target.js +58 -0
- package/dist/ssh-target.js.map +1 -0
- package/dist/tools/register-config-profile-tools.d.ts +2 -0
- package/dist/tools/register-config-profile-tools.js +179 -0
- package/dist/tools/register-config-profile-tools.js.map +1 -0
- package/dist/tools/register-project-tools.d.ts +2 -0
- package/dist/tools/register-project-tools.js +377 -0
- package/dist/tools/register-project-tools.js.map +1 -0
- package/dist/tools/register-session-tools.d.ts +2 -0
- package/dist/tools/register-session-tools.js +297 -0
- package/dist/tools/register-session-tools.js.map +1 -0
- package/dist/tools/register-sftp-tools.d.ts +2 -0
- package/dist/tools/register-sftp-tools.js +172 -0
- package/dist/tools/register-sftp-tools.js.map +1 -0
- package/dist/tools/register-transfer-tools.d.ts +2 -0
- package/dist/tools/register-transfer-tools.js +167 -0
- package/dist/tools/register-transfer-tools.js.map +1 -0
- package/dist/tools/register-tunnel-tools.d.ts +2 -0
- package/dist/tools/register-tunnel-tools.js +55 -0
- package/dist/tools/register-tunnel-tools.js.map +1 -0
- package/dist/tools/tool-metadata.d.ts +18 -0
- package/dist/tools/tool-metadata.js +222 -0
- package/dist/tools/tool-metadata.js.map +1 -0
- package/package.json +5 -3
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
export function registerTransferTools(ctx) {
|
|
2
|
+
const { z, assertNonEmpty, toToolResult, runtimeConfig, sessions, transfers, sessionIdSchema, registerTool, connectProfileSession } = ctx;
|
|
3
|
+
registerTool("sftp_upload_start", {
|
|
4
|
+
title: "Start large upload",
|
|
5
|
+
description: "Start a background SFTP upload job with progress, cancellation, and resume support.",
|
|
6
|
+
inputSchema: {
|
|
7
|
+
sessionId: sessionIdSchema,
|
|
8
|
+
localPath: z.string().min(1),
|
|
9
|
+
remotePath: z.string().min(1),
|
|
10
|
+
resume: z.boolean().optional(),
|
|
11
|
+
overwrite: z.boolean().optional(),
|
|
12
|
+
atomic: z.boolean().optional(),
|
|
13
|
+
remoteTempPath: z.string().min(1).optional(),
|
|
14
|
+
mode: z.number().int().min(0).max(0o7777).optional(),
|
|
15
|
+
chunkSizeBytes: z.number().int().min(16 * 1024).max(16 * 1024 * 1024).optional(),
|
|
16
|
+
},
|
|
17
|
+
}, async (args) => toToolResult(async () => {
|
|
18
|
+
assertNonEmpty(args.localPath, "localPath");
|
|
19
|
+
assertNonEmpty(args.remotePath, "remotePath");
|
|
20
|
+
const session = sessions.get(args.sessionId);
|
|
21
|
+
const config = runtimeConfig.get();
|
|
22
|
+
return {
|
|
23
|
+
ok: true,
|
|
24
|
+
transfer: transfers.startUpload(session, {
|
|
25
|
+
sessionId: args.sessionId,
|
|
26
|
+
localPath: args.localPath,
|
|
27
|
+
remotePath: args.remotePath,
|
|
28
|
+
resume: args.resume ?? config.defaultTransferResume,
|
|
29
|
+
overwrite: args.overwrite ?? config.defaultTransferOverwrite,
|
|
30
|
+
atomic: args.atomic ?? config.defaultTransferAtomic,
|
|
31
|
+
chunkSizeBytes: args.chunkSizeBytes ?? config.defaultTransferChunkSizeBytes,
|
|
32
|
+
...(args.remoteTempPath === undefined ? {} : { remoteTempPath: args.remoteTempPath }),
|
|
33
|
+
...(args.mode === undefined ? {} : { mode: args.mode }),
|
|
34
|
+
}),
|
|
35
|
+
};
|
|
36
|
+
}));
|
|
37
|
+
registerTool("sftp_upload_profile", {
|
|
38
|
+
title: "Upload to SSH profile",
|
|
39
|
+
description: "Agent-friendly upload: connect to a named profile and start a resumable background SFTP upload job.",
|
|
40
|
+
inputSchema: {
|
|
41
|
+
profileName: z.string().min(1),
|
|
42
|
+
localPath: z.string().min(1),
|
|
43
|
+
remotePath: z.string().min(1),
|
|
44
|
+
resume: z.boolean().optional(),
|
|
45
|
+
overwrite: z.boolean().optional(),
|
|
46
|
+
atomic: z.boolean().optional(),
|
|
47
|
+
remoteTempPath: z.string().min(1).optional(),
|
|
48
|
+
mode: z.number().int().min(0).max(0o7777).optional(),
|
|
49
|
+
chunkSizeBytes: z.number().int().min(16 * 1024).max(16 * 1024 * 1024).optional(),
|
|
50
|
+
},
|
|
51
|
+
}, async (args) => toToolResult(async () => {
|
|
52
|
+
assertNonEmpty(args.localPath, "localPath");
|
|
53
|
+
assertNonEmpty(args.remotePath, "remotePath");
|
|
54
|
+
const config = runtimeConfig.get();
|
|
55
|
+
const connected = await connectProfileSession({
|
|
56
|
+
profileName: args.profileName,
|
|
57
|
+
keyboardResponses: [],
|
|
58
|
+
strictVendor: true,
|
|
59
|
+
debug: false,
|
|
60
|
+
});
|
|
61
|
+
const session = sessions.get(connected.session.id);
|
|
62
|
+
return {
|
|
63
|
+
ok: true,
|
|
64
|
+
profile: connected.profile,
|
|
65
|
+
session: connected.session,
|
|
66
|
+
transfer: transfers.startUpload(session, {
|
|
67
|
+
sessionId: connected.session.id,
|
|
68
|
+
localPath: args.localPath,
|
|
69
|
+
remotePath: args.remotePath,
|
|
70
|
+
resume: args.resume ?? config.defaultTransferResume,
|
|
71
|
+
overwrite: args.overwrite ?? config.defaultTransferOverwrite,
|
|
72
|
+
atomic: args.atomic ?? config.defaultTransferAtomic,
|
|
73
|
+
chunkSizeBytes: args.chunkSizeBytes ?? config.defaultTransferChunkSizeBytes,
|
|
74
|
+
...(args.remoteTempPath === undefined ? {} : { remoteTempPath: args.remoteTempPath }),
|
|
75
|
+
...(args.mode === undefined ? {} : { mode: args.mode }),
|
|
76
|
+
}),
|
|
77
|
+
};
|
|
78
|
+
}));
|
|
79
|
+
registerTool("sftp_download_start", {
|
|
80
|
+
title: "Start large download",
|
|
81
|
+
description: "Start a background SFTP download job with progress, cancellation, and resume support.",
|
|
82
|
+
inputSchema: {
|
|
83
|
+
sessionId: sessionIdSchema,
|
|
84
|
+
remotePath: z.string().min(1),
|
|
85
|
+
localPath: z.string().min(1),
|
|
86
|
+
resume: z.boolean().optional(),
|
|
87
|
+
overwrite: z.boolean().optional(),
|
|
88
|
+
atomic: z.boolean().optional(),
|
|
89
|
+
localTempPath: z.string().min(1).optional(),
|
|
90
|
+
chunkSizeBytes: z.number().int().min(16 * 1024).max(16 * 1024 * 1024).optional(),
|
|
91
|
+
},
|
|
92
|
+
}, async (args) => toToolResult(async () => {
|
|
93
|
+
assertNonEmpty(args.localPath, "localPath");
|
|
94
|
+
assertNonEmpty(args.remotePath, "remotePath");
|
|
95
|
+
const session = sessions.get(args.sessionId);
|
|
96
|
+
const config = runtimeConfig.get();
|
|
97
|
+
return {
|
|
98
|
+
ok: true,
|
|
99
|
+
transfer: transfers.startDownload(session, {
|
|
100
|
+
sessionId: args.sessionId,
|
|
101
|
+
remotePath: args.remotePath,
|
|
102
|
+
localPath: args.localPath,
|
|
103
|
+
resume: args.resume ?? config.defaultTransferResume,
|
|
104
|
+
overwrite: args.overwrite ?? config.defaultTransferOverwrite,
|
|
105
|
+
atomic: args.atomic ?? config.defaultTransferAtomic,
|
|
106
|
+
chunkSizeBytes: args.chunkSizeBytes ?? config.defaultTransferChunkSizeBytes,
|
|
107
|
+
...(args.localTempPath === undefined ? {} : { localTempPath: args.localTempPath }),
|
|
108
|
+
}),
|
|
109
|
+
};
|
|
110
|
+
}));
|
|
111
|
+
registerTool("sftp_download_profile", {
|
|
112
|
+
title: "Download from SSH profile",
|
|
113
|
+
description: "Agent-friendly download: connect to a named profile and start a resumable background SFTP download job.",
|
|
114
|
+
inputSchema: {
|
|
115
|
+
profileName: z.string().min(1),
|
|
116
|
+
remotePath: z.string().min(1),
|
|
117
|
+
localPath: z.string().min(1),
|
|
118
|
+
resume: z.boolean().optional(),
|
|
119
|
+
overwrite: z.boolean().optional(),
|
|
120
|
+
atomic: z.boolean().optional(),
|
|
121
|
+
localTempPath: z.string().min(1).optional(),
|
|
122
|
+
chunkSizeBytes: z.number().int().min(16 * 1024).max(16 * 1024 * 1024).optional(),
|
|
123
|
+
},
|
|
124
|
+
}, async (args) => toToolResult(async () => {
|
|
125
|
+
assertNonEmpty(args.localPath, "localPath");
|
|
126
|
+
assertNonEmpty(args.remotePath, "remotePath");
|
|
127
|
+
const config = runtimeConfig.get();
|
|
128
|
+
const connected = await connectProfileSession({
|
|
129
|
+
profileName: args.profileName,
|
|
130
|
+
keyboardResponses: [],
|
|
131
|
+
strictVendor: true,
|
|
132
|
+
debug: false,
|
|
133
|
+
});
|
|
134
|
+
const session = sessions.get(connected.session.id);
|
|
135
|
+
return {
|
|
136
|
+
ok: true,
|
|
137
|
+
profile: connected.profile,
|
|
138
|
+
session: connected.session,
|
|
139
|
+
transfer: transfers.startDownload(session, {
|
|
140
|
+
sessionId: connected.session.id,
|
|
141
|
+
remotePath: args.remotePath,
|
|
142
|
+
localPath: args.localPath,
|
|
143
|
+
resume: args.resume ?? config.defaultTransferResume,
|
|
144
|
+
overwrite: args.overwrite ?? config.defaultTransferOverwrite,
|
|
145
|
+
atomic: args.atomic ?? config.defaultTransferAtomic,
|
|
146
|
+
chunkSizeBytes: args.chunkSizeBytes ?? config.defaultTransferChunkSizeBytes,
|
|
147
|
+
...(args.localTempPath === undefined ? {} : { localTempPath: args.localTempPath }),
|
|
148
|
+
}),
|
|
149
|
+
};
|
|
150
|
+
}));
|
|
151
|
+
registerTool("sftp_transfer_status", {
|
|
152
|
+
title: "Get transfer status",
|
|
153
|
+
description: "Get progress, ETA, and final state for a background upload/download job.",
|
|
154
|
+
inputSchema: { transferId: z.string().min(1) },
|
|
155
|
+
}, async (args) => toToolResult(async () => ({ ok: true, transfer: transfers.get(args.transferId) })));
|
|
156
|
+
registerTool("sftp_transfer_list", {
|
|
157
|
+
title: "List transfers",
|
|
158
|
+
description: "List background transfer jobs, optionally filtered by SSH session.",
|
|
159
|
+
inputSchema: { sessionId: sessionIdSchema.optional() },
|
|
160
|
+
}, async (args) => toToolResult(async () => ({ ok: true, transfers: transfers.list(args.sessionId) })));
|
|
161
|
+
registerTool("sftp_transfer_cancel", {
|
|
162
|
+
title: "Cancel transfer",
|
|
163
|
+
description: "Cancel a running or queued background transfer job.",
|
|
164
|
+
inputSchema: { transferId: z.string().min(1) },
|
|
165
|
+
}, async (args) => toToolResult(async () => ({ ok: true, transfer: transfers.cancel(args.transferId) })));
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=register-transfer-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register-transfer-tools.js","sourceRoot":"","sources":["../../src/tools/register-transfer-tools.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU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G,CAAC;IAEF,YAAY,CACV,oBAAoB,EACpB;QACE,KAAK,EAAE,gBAAgB;QACvB,WAAW,EAAE,oEAAoE;QACjF,WAAW,EAAE,EAAE,SAAS,EAAE,eAAe,CAAC,QAAQ,EAAE,EAAE;KACvD,EACD,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,YAAY,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CACpG,CAAC;IAEF,YAAY,CACV,sBAAsB,EACtB;QACE,KAAK,EAAE,iBAAiB;QACxB,WAAW,EAAE,qDAAqD;QAClE,WAAW,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;KAC/C,EACD,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,YAAY,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,CACtG,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export function registerTunnelTools(ctx) {
|
|
2
|
+
const { z, toToolResult, runtimeConfig, sessions, sessionIdSchema, positivePortSchema, registerTool } = ctx;
|
|
3
|
+
registerTool("ssh_tunnel_local_start", {
|
|
4
|
+
title: "Start local port forward",
|
|
5
|
+
description: "Listen locally and forward accepted TCP connections through SSH to a remote target.",
|
|
6
|
+
inputSchema: {
|
|
7
|
+
sessionId: sessionIdSchema,
|
|
8
|
+
localHost: z.string().min(1).optional(),
|
|
9
|
+
localPort: positivePortSchema.default(0),
|
|
10
|
+
targetHost: z.string().min(1),
|
|
11
|
+
targetPort: z.number().int().min(1).max(65_535),
|
|
12
|
+
},
|
|
13
|
+
}, async (args) => toToolResult(async () => ({
|
|
14
|
+
ok: true,
|
|
15
|
+
tunnel: await sessions.get(args.sessionId).startLocalForward({
|
|
16
|
+
localHost: args.localHost ?? runtimeConfig.get().defaultLocalTunnelHost,
|
|
17
|
+
localPort: args.localPort,
|
|
18
|
+
targetHost: args.targetHost,
|
|
19
|
+
targetPort: args.targetPort,
|
|
20
|
+
}),
|
|
21
|
+
})));
|
|
22
|
+
registerTool("ssh_tunnel_remote_start", {
|
|
23
|
+
title: "Start remote port forward",
|
|
24
|
+
description: "Bind a remote TCP port through SSH and forward incoming connections to a local target.",
|
|
25
|
+
inputSchema: {
|
|
26
|
+
sessionId: sessionIdSchema,
|
|
27
|
+
remoteHost: z.string().min(1).optional(),
|
|
28
|
+
remotePort: positivePortSchema.default(0),
|
|
29
|
+
targetHost: z.string().min(1),
|
|
30
|
+
targetPort: z.number().int().min(1).max(65_535),
|
|
31
|
+
},
|
|
32
|
+
}, async (args) => toToolResult(async () => ({
|
|
33
|
+
ok: true,
|
|
34
|
+
tunnel: await sessions.get(args.sessionId).startRemoteForward({
|
|
35
|
+
remoteHost: args.remoteHost ?? runtimeConfig.get().defaultRemoteTunnelHost,
|
|
36
|
+
remotePort: args.remotePort,
|
|
37
|
+
targetHost: args.targetHost,
|
|
38
|
+
targetPort: args.targetPort,
|
|
39
|
+
}),
|
|
40
|
+
})));
|
|
41
|
+
registerTool("ssh_tunnel_list", {
|
|
42
|
+
title: "List SSH tunnels",
|
|
43
|
+
description: "List local and remote port forwards for one SSH session.",
|
|
44
|
+
inputSchema: { sessionId: sessionIdSchema },
|
|
45
|
+
}, async (args) => toToolResult(async () => ({ ok: true, tunnels: sessions.get(args.sessionId).listTunnels() })));
|
|
46
|
+
registerTool("ssh_tunnel_stop", {
|
|
47
|
+
title: "Stop SSH tunnel",
|
|
48
|
+
description: "Stop a local or remote port forward.",
|
|
49
|
+
inputSchema: { sessionId: sessionIdSchema, tunnelId: z.string().min(1) },
|
|
50
|
+
}, async (args) => toToolResult(async () => ({
|
|
51
|
+
ok: true,
|
|
52
|
+
tunnel: await sessions.get(args.sessionId).stopTunnel(args.tunnelId),
|
|
53
|
+
})));
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=register-tunnel-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register-tunnel-tools.js","sourceRoot":"","sources":["../../src/tools/register-tunnel-tools.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,mBAAmB,CAAC,GAAuI;IACzK,MAAM,EAAE,CAAC,EAAE,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,eAAe,EAAE,kBAAkB,EAAE,YAAY,EAAE,GAAG,GAAG,CAAC;IAE5G,YAAY,CACV,wBAAwB,EACxB;QACE,KAAK,EAAE,0BAA0B;QACjC,WAAW,EAAE,qFAAqF;QAClG,WAAW,EAAE;YACX,SAAS,EAAE,eAAe;YAC1B,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;YACvC,SAAS,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC;YACxC,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;YAC7B,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC;SAChD;KACF,EACD,KAAK,EAAE,IAAI,EAAE,EAAE,CACb,YAAY,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;QACxB,EAAE,EAAE,IAAI;QACR,MAAM,EAAE,MAAM,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,iBAAiB,CAAC;YAC3D,SAAS,EAAE,IAAI,CAAC,SAAS,IAAI,aAAa,CAAC,GAAG,EAAE,CAAC,sBAAsB;YACvE,SAAS,EAAE,IAAI,CAAC,SAAS;YACz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AAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,CAC9G,CAAC;IAEF,YAAY,CACV,iBAAiB,EACjB;QACE,KAAK,EAAE,iBAAiB;QACxB,WAAW,EAAE,sCAAsC;QACnD,WAAW,EAAE,EAAE,SAAS,EAAE,eAAe,EAAE,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;KACzE,EACD,KAAK,EAAE,IAAI,EAAE,EAAE,CACb,YAAY,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;QACxB,EAAE,EAAE,IAAI;QACR,MAAM,EAAE,MAAM,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC;KACrE,CAAC,CAAC,CACN,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ToolAnnotations } from "@modelcontextprotocol/sdk/types.js";
|
|
2
|
+
export type ToolRisk = "read-only" | "stateful" | "write" | "destructive";
|
|
3
|
+
export declare const TOOL_NAMES: readonly ["ssh_get_config", "ssh_reload_config", "ssh_list_profiles", "ssh_reload_profiles", "ssh_connect_profile", "ssh_run_profile", "ssh_check_profile", "ssh_project_open", "ssh_project_tree", "ssh_project_search", "ssh_project_stat", "ssh_file_read", "ssh_file_patch", "ssh_project_validate_patch", "ssh_project_apply_patch", "ssh_file_write", "ssh_file_delete", "ssh_file_move", "ssh_project_diff", "ssh_project_run_checks", "ssh_edit_history", "ssh_edit_rollback", "ssh_run_openssh_temporary", "ssh_trust_host_ca", "ssh_run_openssh", "ssh_probe_host_key", "ssh_connect", "ssh_list_sessions", "ssh_disconnect", "ssh_disconnect_all", "ssh_exec", "ssh_rekey", "ssh_shell_open", "ssh_shell_list", "ssh_shell_write", "ssh_shell_read", "ssh_shell_resize", "ssh_shell_close", "sftp_list", "sftp_stat", "sftp_read_file", "sftp_write_file", "sftp_mkdir", "sftp_rm", "sftp_rename", "sftp_chmod", "sftp_chown", "sftp_touch", "sftp_symlink", "sftp_readlink", "sftp_realpath", "sftp_upload_start", "sftp_upload_profile", "sftp_download_start", "sftp_download_profile", "sftp_transfer_status", "sftp_transfer_list", "sftp_transfer_cancel", "ssh_tunnel_local_start", "ssh_tunnel_remote_start", "ssh_tunnel_list", "ssh_tunnel_stop"];
|
|
4
|
+
export type ToolName = (typeof TOOL_NAMES)[number];
|
|
5
|
+
export declare const AGENT_TOOL_NAMES: Set<string>;
|
|
6
|
+
/**
|
|
7
|
+
* Tool exposure gating retained for backwards compatibility. This set controls
|
|
8
|
+
* which tools are hidden unless explicitly enabled; it is not the execution
|
|
9
|
+
* authorization policy and must not be treated as one.
|
|
10
|
+
*/
|
|
11
|
+
export declare const DANGEROUS_TOOL_NAMES: Set<string>;
|
|
12
|
+
export declare const LOCAL_ONLY_TOOL_NAMES: Set<string>;
|
|
13
|
+
/**
|
|
14
|
+
* Every registered tool has an explicit risk category. MCP annotations are
|
|
15
|
+
* client hints only; actual execution policy must be enforced separately.
|
|
16
|
+
*/
|
|
17
|
+
export declare const TOOL_RISK: Record<ToolName, ToolRisk>;
|
|
18
|
+
export declare function resolveToolAnnotations(name: string, overrides: ToolAnnotations | undefined): ToolAnnotations;
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
export const TOOL_NAMES = [
|
|
2
|
+
"ssh_get_config",
|
|
3
|
+
"ssh_reload_config",
|
|
4
|
+
"ssh_list_profiles",
|
|
5
|
+
"ssh_reload_profiles",
|
|
6
|
+
"ssh_connect_profile",
|
|
7
|
+
"ssh_run_profile",
|
|
8
|
+
"ssh_check_profile",
|
|
9
|
+
"ssh_project_open",
|
|
10
|
+
"ssh_project_tree",
|
|
11
|
+
"ssh_project_search",
|
|
12
|
+
"ssh_project_stat",
|
|
13
|
+
"ssh_file_read",
|
|
14
|
+
"ssh_file_patch",
|
|
15
|
+
"ssh_project_validate_patch",
|
|
16
|
+
"ssh_project_apply_patch",
|
|
17
|
+
"ssh_file_write",
|
|
18
|
+
"ssh_file_delete",
|
|
19
|
+
"ssh_file_move",
|
|
20
|
+
"ssh_project_diff",
|
|
21
|
+
"ssh_project_run_checks",
|
|
22
|
+
"ssh_edit_history",
|
|
23
|
+
"ssh_edit_rollback",
|
|
24
|
+
"ssh_run_openssh_temporary",
|
|
25
|
+
"ssh_trust_host_ca",
|
|
26
|
+
"ssh_run_openssh",
|
|
27
|
+
"ssh_probe_host_key",
|
|
28
|
+
"ssh_connect",
|
|
29
|
+
"ssh_list_sessions",
|
|
30
|
+
"ssh_disconnect",
|
|
31
|
+
"ssh_disconnect_all",
|
|
32
|
+
"ssh_exec",
|
|
33
|
+
"ssh_rekey",
|
|
34
|
+
"ssh_shell_open",
|
|
35
|
+
"ssh_shell_list",
|
|
36
|
+
"ssh_shell_write",
|
|
37
|
+
"ssh_shell_read",
|
|
38
|
+
"ssh_shell_resize",
|
|
39
|
+
"ssh_shell_close",
|
|
40
|
+
"sftp_list",
|
|
41
|
+
"sftp_stat",
|
|
42
|
+
"sftp_read_file",
|
|
43
|
+
"sftp_write_file",
|
|
44
|
+
"sftp_mkdir",
|
|
45
|
+
"sftp_rm",
|
|
46
|
+
"sftp_rename",
|
|
47
|
+
"sftp_chmod",
|
|
48
|
+
"sftp_chown",
|
|
49
|
+
"sftp_touch",
|
|
50
|
+
"sftp_symlink",
|
|
51
|
+
"sftp_readlink",
|
|
52
|
+
"sftp_realpath",
|
|
53
|
+
"sftp_upload_start",
|
|
54
|
+
"sftp_upload_profile",
|
|
55
|
+
"sftp_download_start",
|
|
56
|
+
"sftp_download_profile",
|
|
57
|
+
"sftp_transfer_status",
|
|
58
|
+
"sftp_transfer_list",
|
|
59
|
+
"sftp_transfer_cancel",
|
|
60
|
+
"ssh_tunnel_local_start",
|
|
61
|
+
"ssh_tunnel_remote_start",
|
|
62
|
+
"ssh_tunnel_list",
|
|
63
|
+
"ssh_tunnel_stop",
|
|
64
|
+
];
|
|
65
|
+
export const AGENT_TOOL_NAMES = new Set([
|
|
66
|
+
"ssh_get_config",
|
|
67
|
+
"ssh_reload_config",
|
|
68
|
+
"ssh_list_profiles",
|
|
69
|
+
"ssh_reload_profiles",
|
|
70
|
+
"ssh_connect_profile",
|
|
71
|
+
"ssh_check_profile",
|
|
72
|
+
"ssh_run_profile",
|
|
73
|
+
"ssh_project_open",
|
|
74
|
+
"ssh_project_tree",
|
|
75
|
+
"ssh_project_search",
|
|
76
|
+
"ssh_project_diff",
|
|
77
|
+
"ssh_project_run_checks",
|
|
78
|
+
"ssh_project_validate_patch",
|
|
79
|
+
"ssh_project_apply_patch",
|
|
80
|
+
"ssh_project_stat",
|
|
81
|
+
"ssh_file_read",
|
|
82
|
+
"ssh_file_patch",
|
|
83
|
+
"ssh_edit_history",
|
|
84
|
+
"ssh_edit_rollback",
|
|
85
|
+
"ssh_run_openssh_temporary",
|
|
86
|
+
"ssh_list_sessions",
|
|
87
|
+
"ssh_trust_host_ca",
|
|
88
|
+
"ssh_run_openssh",
|
|
89
|
+
"ssh_probe_host_key",
|
|
90
|
+
"ssh_disconnect",
|
|
91
|
+
"ssh_exec",
|
|
92
|
+
"ssh_shell_open",
|
|
93
|
+
"ssh_shell_write",
|
|
94
|
+
"ssh_shell_read",
|
|
95
|
+
"ssh_shell_close",
|
|
96
|
+
"sftp_list",
|
|
97
|
+
"sftp_stat",
|
|
98
|
+
"sftp_read_file",
|
|
99
|
+
"sftp_download_start",
|
|
100
|
+
"sftp_download_profile",
|
|
101
|
+
"sftp_transfer_status",
|
|
102
|
+
"sftp_transfer_list",
|
|
103
|
+
"sftp_transfer_cancel",
|
|
104
|
+
]);
|
|
105
|
+
/**
|
|
106
|
+
* Tool exposure gating retained for backwards compatibility. This set controls
|
|
107
|
+
* which tools are hidden unless explicitly enabled; it is not the execution
|
|
108
|
+
* authorization policy and must not be treated as one.
|
|
109
|
+
*/
|
|
110
|
+
export const DANGEROUS_TOOL_NAMES = new Set([
|
|
111
|
+
"ssh_disconnect_all",
|
|
112
|
+
"ssh_tunnel_local_start",
|
|
113
|
+
"ssh_tunnel_remote_start",
|
|
114
|
+
"ssh_tunnel_stop",
|
|
115
|
+
"sftp_rm",
|
|
116
|
+
"sftp_write_file",
|
|
117
|
+
"sftp_mkdir",
|
|
118
|
+
"sftp_rename",
|
|
119
|
+
"sftp_chmod",
|
|
120
|
+
"sftp_chown",
|
|
121
|
+
"sftp_touch",
|
|
122
|
+
"sftp_symlink",
|
|
123
|
+
"sftp_upload_start",
|
|
124
|
+
"sftp_upload_profile",
|
|
125
|
+
"ssh_file_write",
|
|
126
|
+
"ssh_file_delete",
|
|
127
|
+
"ssh_file_move",
|
|
128
|
+
]);
|
|
129
|
+
export const LOCAL_ONLY_TOOL_NAMES = new Set([
|
|
130
|
+
"ssh_get_config",
|
|
131
|
+
"ssh_reload_config",
|
|
132
|
+
"ssh_list_profiles",
|
|
133
|
+
"ssh_reload_profiles",
|
|
134
|
+
"ssh_edit_history",
|
|
135
|
+
"ssh_list_sessions",
|
|
136
|
+
"ssh_shell_list",
|
|
137
|
+
"sftp_transfer_status",
|
|
138
|
+
"sftp_transfer_list",
|
|
139
|
+
"ssh_tunnel_list",
|
|
140
|
+
]);
|
|
141
|
+
/**
|
|
142
|
+
* Every registered tool has an explicit risk category. MCP annotations are
|
|
143
|
+
* client hints only; actual execution policy must be enforced separately.
|
|
144
|
+
*/
|
|
145
|
+
export const TOOL_RISK = {
|
|
146
|
+
ssh_get_config: "read-only",
|
|
147
|
+
ssh_reload_config: "stateful",
|
|
148
|
+
ssh_list_profiles: "read-only",
|
|
149
|
+
ssh_reload_profiles: "stateful",
|
|
150
|
+
ssh_connect_profile: "stateful",
|
|
151
|
+
ssh_run_profile: "destructive",
|
|
152
|
+
ssh_check_profile: "read-only",
|
|
153
|
+
ssh_project_open: "read-only",
|
|
154
|
+
ssh_project_tree: "read-only",
|
|
155
|
+
ssh_project_search: "read-only",
|
|
156
|
+
ssh_project_stat: "read-only",
|
|
157
|
+
ssh_file_read: "read-only",
|
|
158
|
+
ssh_file_patch: "destructive",
|
|
159
|
+
ssh_project_validate_patch: "read-only",
|
|
160
|
+
ssh_project_apply_patch: "destructive",
|
|
161
|
+
ssh_file_write: "destructive",
|
|
162
|
+
ssh_file_delete: "destructive",
|
|
163
|
+
ssh_file_move: "destructive",
|
|
164
|
+
ssh_project_diff: "read-only",
|
|
165
|
+
ssh_project_run_checks: "destructive",
|
|
166
|
+
ssh_edit_history: "read-only",
|
|
167
|
+
ssh_edit_rollback: "destructive",
|
|
168
|
+
ssh_run_openssh_temporary: "destructive",
|
|
169
|
+
ssh_trust_host_ca: "stateful",
|
|
170
|
+
ssh_run_openssh: "destructive",
|
|
171
|
+
ssh_probe_host_key: "read-only",
|
|
172
|
+
ssh_connect: "stateful",
|
|
173
|
+
ssh_list_sessions: "read-only",
|
|
174
|
+
ssh_disconnect: "stateful",
|
|
175
|
+
ssh_disconnect_all: "stateful",
|
|
176
|
+
ssh_exec: "destructive",
|
|
177
|
+
ssh_rekey: "stateful",
|
|
178
|
+
ssh_shell_open: "stateful",
|
|
179
|
+
ssh_shell_list: "read-only",
|
|
180
|
+
ssh_shell_write: "destructive",
|
|
181
|
+
ssh_shell_read: "read-only",
|
|
182
|
+
ssh_shell_resize: "stateful",
|
|
183
|
+
ssh_shell_close: "stateful",
|
|
184
|
+
sftp_list: "read-only",
|
|
185
|
+
sftp_stat: "read-only",
|
|
186
|
+
sftp_read_file: "read-only",
|
|
187
|
+
sftp_write_file: "destructive",
|
|
188
|
+
sftp_mkdir: "write",
|
|
189
|
+
sftp_rm: "destructive",
|
|
190
|
+
sftp_rename: "destructive",
|
|
191
|
+
sftp_chmod: "destructive",
|
|
192
|
+
sftp_chown: "destructive",
|
|
193
|
+
sftp_touch: "write",
|
|
194
|
+
sftp_symlink: "write",
|
|
195
|
+
sftp_readlink: "read-only",
|
|
196
|
+
sftp_realpath: "read-only",
|
|
197
|
+
sftp_upload_start: "destructive",
|
|
198
|
+
sftp_upload_profile: "destructive",
|
|
199
|
+
sftp_download_start: "destructive",
|
|
200
|
+
sftp_download_profile: "destructive",
|
|
201
|
+
sftp_transfer_status: "read-only",
|
|
202
|
+
sftp_transfer_list: "read-only",
|
|
203
|
+
sftp_transfer_cancel: "stateful",
|
|
204
|
+
ssh_tunnel_local_start: "stateful",
|
|
205
|
+
ssh_tunnel_remote_start: "stateful",
|
|
206
|
+
ssh_tunnel_list: "read-only",
|
|
207
|
+
ssh_tunnel_stop: "stateful",
|
|
208
|
+
};
|
|
209
|
+
export function resolveToolAnnotations(name, overrides) {
|
|
210
|
+
if (!Object.prototype.hasOwnProperty.call(TOOL_RISK, name)) {
|
|
211
|
+
throw new Error(`Missing explicit risk metadata for MCP tool "${name}"`);
|
|
212
|
+
}
|
|
213
|
+
const risk = TOOL_RISK[name];
|
|
214
|
+
return {
|
|
215
|
+
readOnlyHint: risk === "read-only",
|
|
216
|
+
destructiveHint: risk === "destructive",
|
|
217
|
+
idempotentHint: risk === "read-only",
|
|
218
|
+
openWorldHint: !LOCAL_ONLY_TOOL_NAMES.has(name),
|
|
219
|
+
...overrides,
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
//# sourceMappingURL=tool-metadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-metadata.js","sourceRoot":"","sources":["../../src/tools/tool-metadata.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,gBAAgB;IAChB,mBAAmB;IACnB,mBAAmB;IACnB,qBAAqB;IACrB,qBAAqB;IACrB,iBAAiB;IACjB,mBAAmB;IACnB,kBAAkB;IAClB,kBAAkB;IAClB,oBAAoB;IACpB,kBAAkB;IAClB,eAAe;IACf,gBAAgB;IAChB,4BAA4B;IAC5B,yBAAyB;IACzB,gBAAgB;IAChB,iBAAiB;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IAAgB,CAAC,CAAC;IACzC,OAAO;QACL,YAAY,EAAE,IAAI,KAAK,WAAW;QAClC,eAAe,EAAE,IAAI,KAAK,aAAa;QACvC,cAAc,EAAE,IAAI,KAAK,WAAW;QACpC,aAAa,EAAE,CAAC,qBAAqB,CAAC,GAAG,CAAC,IAAI,CAAC;QAC/C,GAAG,SAAS;KACb,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "enterprise-ssh-mcp-server",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "Enterprise SSH/SFTP MCP server with persistent sessions, interactive shells, transfer jobs, and port forwarding.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
},
|
|
23
23
|
"files": [
|
|
24
24
|
"dist",
|
|
25
|
-
"README.md"
|
|
25
|
+
"README.md",
|
|
26
|
+
"CHANGELOG.md"
|
|
26
27
|
],
|
|
27
28
|
"scripts": {
|
|
28
29
|
"clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\"",
|
|
@@ -31,7 +32,8 @@
|
|
|
31
32
|
"test": "vitest run",
|
|
32
33
|
"prepublishOnly": "npm run typecheck && npm test && npm run build",
|
|
33
34
|
"start": "node dist/index.js",
|
|
34
|
-
"dev": "tsx src/index.ts"
|
|
35
|
+
"dev": "tsx src/index.ts",
|
|
36
|
+
"dev:watch": "tsx watch src/index.ts"
|
|
35
37
|
},
|
|
36
38
|
"dependencies": {
|
|
37
39
|
"@modelcontextprotocol/sdk": "^1.29.0",
|