@imenam/mcp-github 1.1.45

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.
@@ -0,0 +1,53 @@
1
+ import { NodeSSH } from "node-ssh";
2
+ import fs from "fs";
3
+ import { getConfig } from "./config.js";
4
+ import { logToFile } from "../logger.js";
5
+ /**
6
+ * Vérifie que toutes les variables SSH sont définies et que la clé existe sur disque.
7
+ * Lève une erreur explicite avec le nom de la variable manquante.
8
+ */
9
+ export function assertSshConfig() {
10
+ const config = getConfig();
11
+ if (!config.SSH_HOST)
12
+ throw new Error("SSH_HOST est manquant dans le .env");
13
+ if (!config.SSH_USER)
14
+ throw new Error("SSH_USER est manquant dans le .env");
15
+ if (!config.SSH_KEY_PATH)
16
+ throw new Error("SSH_KEY_PATH est manquant dans le .env");
17
+ if (!config.SSH_REMOTE_PATH)
18
+ throw new Error("SSH_REMOTE_PATH est manquant dans le .env");
19
+ if (!fs.existsSync(config.SSH_KEY_PATH)) {
20
+ throw new Error(`Clé SSH introuvable : ${config.SSH_KEY_PATH}`);
21
+ }
22
+ }
23
+ /**
24
+ * Ouvre une connexion SSH, exécute `command` dans SSH_REMOTE_PATH, ferme.
25
+ * Ne lève pas d'exception si exit code != 0 — c'est à l'appelant de décider.
26
+ */
27
+ export async function execRemote(command) {
28
+ const config = getConfig();
29
+ const ssh = new NodeSSH();
30
+ const keyFileName = config.SSH_KEY_PATH.split(/[\\/]/).pop();
31
+ logToFile(`[SSH] Connecting to ${config.SSH_USER}@${config.SSH_HOST}:${config.SSH_PORT} (key: ${keyFileName})`);
32
+ logToFile(`[SSH] Executing: ${command}`);
33
+ try {
34
+ await ssh.connect({
35
+ host: config.SSH_HOST,
36
+ username: config.SSH_USER,
37
+ port: config.SSH_PORT,
38
+ privateKeyPath: config.SSH_KEY_PATH,
39
+ });
40
+ const result = await ssh.execCommand(command, { cwd: config.SSH_REMOTE_PATH });
41
+ logToFile(`[SSH] Exit code: ${result.code}`);
42
+ const stripAnsi = (s) => s.replace(/\x1B\[[0-9;]*m/g, "");
43
+ return {
44
+ stdout: stripAnsi(result.stdout),
45
+ stderr: stripAnsi(result.stderr),
46
+ code: result.code,
47
+ };
48
+ }
49
+ finally {
50
+ ssh.dispose();
51
+ }
52
+ }
53
+ //# sourceMappingURL=ssh.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ssh.js","sourceRoot":"","sources":["../../src/utils/ssh.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAQzC;;;GAGG;AACH,MAAM,UAAU,eAAe;IAC7B,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAE3B,IAAI,CAAC,MAAM,CAAC,QAAQ;QAAE,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;IAC5E,IAAI,CAAC,MAAM,CAAC,QAAQ;QAAE,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;IAC5E,IAAI,CAAC,MAAM,CAAC,YAAY;QAAE,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IACpF,IAAI,CAAC,MAAM,CAAC,eAAe;QAAE,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;IAE1F,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,yBAAyB,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC;IAClE,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,OAAe;IAC9C,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,MAAM,GAAG,GAAG,IAAI,OAAO,EAAE,C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in": "dist/index.js",
13
+ "scripts": {
14
+ "start": "tsx src/index.ts",
15
+ "dev": "tsx src/index.ts",
16
+ "build": "tsc",
17
+ "test": "echo \"Error: no test specified\" && exit 1",
18
+ "inspect": "mcp-inspector npx tsx src/index.ts",
19
+ "inspect:dev": "mcp-inspector --config mcp-config.json",
20
+ "inspect:no-auth": "mcp-inspector -e DANGEROUSLY_OMIT_AUTH=true --config mcp-config.json",
21
+ "release": "npm version patch && npm run build && npm publish --access public && git push origin main --follow-tags"
22
+ },
23
+ "keywords": [],
24
+ "author": "",
25
+ "license": "ISC",
26
+ "description": "Un serveur MCP GitHub contrôlé et sécurisé pour les agents IA.",
27
+ "dependencies": {
28
+ "@modelcontextprotocol/sdk": "^1.25.3",
29
+ "dotenv": "^17.2.3",
30
+ "express": "^5.2.1",
31
+ "node-ssh": "^13.2.1",
32
+ "octokit": "^5.0.5"
33
+ },
34
+ "devDependencies": {
35
+ "@modelcontextprotocol/inspector": "^0.19.0",
36
+ "@types/express": "^5.0.6",
37
+ "@types/node": "^25.0.10",
38
+ "tsx": "^4.21.0",
39
+ "typescript": "^5.9.3"
40
+ }
41
+ }