@consilium108/mcp-module-devops 0.0.0-stage → 1.1.0

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,120 @@
1
+ #!/usr/bin/env node
2
+ // generated by Claude (Opus 5.5), 2026-11-23; Konsilium: the deploy runner of @consilium108/mcp-module-devops — a SEPARATE
3
+ // long-running service (systemd), never inside the MCP process. It executes only requests a person approved (✅ in the bot);
4
+ // the commands come from this host's config, never from the server. Node built-ins only (no MCP SDK needed).
5
+ import { readFileSync } from 'node:fs';
6
+ import { dirname, resolve } from 'node:path';
7
+ import { fileURLToPath } from 'node:url';
8
+ import {
9
+ acquireLock,
10
+ createClient,
11
+ createLogger,
12
+ createRunner,
13
+ createState,
14
+ defaultPath,
15
+ doctor,
16
+ exampleConfig,
17
+ formatDoctor,
18
+ installSteps,
19
+ loadConfig,
20
+ tick,
21
+ unitText,
22
+ } from '../src/runner/index.js';
23
+
24
+ const PKG = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
25
+ const BIN = fileURLToPath(import.meta.url);
26
+
27
+ const USAGE = `consilium-devops-runner — Konsilium deploy runner (${PKG.name} ${PKG.version})
28
+
29
+ consilium-devops-runner run the service: heartbeat → claim approved requests → run → result
30
+ consilium-devops-runner once one tick (heartbeat, claim, run if there is an approved request)
31
+ consilium-devops-runner doctor [--heartbeat] [--no-docker] check this host (changes nothing; --heartbeat sends one)
32
+ consilium-devops-runner install --print [--user] [--repo <dir>] [--target <key>] PRINT the systemd unit and steps
33
+ consilium-devops-runner unit --print [--user] [--repo <dir>] PRINT only the unit
34
+ consilium-devops-runner config --print [--repo <dir>] [--target <key>] PRINT an example config (no secret)
35
+ consilium-devops-runner --version | --help
36
+
37
+ Options: --config <file>
38
+
39
+ Config (outside the repository, chmod 600): $CONSILIUM_DEVOPS_RUNNER_CONFIG, else ~/.config/consilium-devops-runner/config.json,
40
+ else /etc/consilium-devops-runner/config.json.
41
+ Environment: CONSILIUM_RUNNER_TOKEN (the target's kdr_ token, instead of tokenFile), KONSILIUM_API_URL, CONSILIUM_RUNNER_PATH,
42
+ CONSILIUM_RUNNER_STATE_DIR, CONSILIUM_RUNNER_LOG_FORMAT (json|text), CONSILIUM_RUNNER_TELEGRAM_TOKEN (the watchdog).
43
+ Nothing here installs a service: install/unit only print.`;
44
+
45
+ const argv = process.argv.slice(2);
46
+ const has = (f) => argv.includes(f);
47
+ const opt = (name) => {
48
+ const i = argv.indexOf(name);
49
+ return i >= 0 && argv[i + 1] && !argv[i + 1].startsWith('--') ? argv[i + 1] : null;
50
+ };
51
+ const VALUED = new Set(['--config', '--repo', '--target']);
52
+ const cmd = argv.find((a, i) => !a.startsWith('-') && !VALUED.has(argv[i - 1])) ?? 'help';
53
+ const out = (s) => process.stdout.write(s.endsWith('\n') ? s : `${s}\n`);
54
+ const fail = (e, code = 1) => {
55
+ process.stderr.write(`consilium-devops-runner: ${e.code ? `${e.code}: ` : ''}${e.message ?? e}\n`);
56
+ process.exit(code);
57
+ };
58
+ const repoGuess = () => resolve(dirname(BIN), '..', '..', '..');
59
+
60
+ async function main() {
61
+ if (has('--version') || cmd === 'version') return out(PKG.version);
62
+ if (has('--help') || has('-h') || cmd === 'help') return out(USAGE);
63
+ const configFile = opt('--config');
64
+
65
+ if (cmd === 'config') {
66
+ if (!has('--print')) return fail({ message: 'config writes nothing; use: config --print > <file>' }, 2);
67
+ return out(JSON.stringify(exampleConfig({ repoDir: opt('--repo') ?? repoGuess(), target: opt('--target') ?? 'konsilium-prod' }), null, 2));
68
+ }
69
+ if (cmd === 'install' || cmd === 'unit') {
70
+ if (!has('--print')) return fail({ message: `${cmd} installs nothing; use: ${cmd} --print (and run the printed commands yourself)` }, 2);
71
+ const mode = has('--user') ? 'user' : 'system';
72
+ const repoDir = opt('--repo') ?? repoGuess();
73
+ if (cmd === 'unit') return out(unitText({ mode, bin: BIN, repoDir, path: defaultPath() }));
74
+ return out(installSteps({ mode, repoDir, target: opt('--target') ?? 'konsilium-prod', bin: BIN }));
75
+ }
76
+ if (cmd === 'doctor') {
77
+ const r = await doctor({ file: configFile, heartbeat: has('--heartbeat'), docker: !has('--no-docker') });
78
+ out(formatDoctor(r));
79
+ process.exit(r.ok ? 0 : 1);
80
+ }
81
+ if (cmd === 'run' || cmd === 'once') {
82
+ let config;
83
+ try {
84
+ config = loadConfig({ file: configFile });
85
+ } catch (e) {
86
+ return fail(e, 78); // EX_CONFIG: systemd's Restart=on-failure retries; the journal says why
87
+ }
88
+ const log = createLogger({ format: config.logFormat });
89
+ if (!config.token) return fail({ code: 'token_missing', message: `no runner token (CONSILIUM_RUNNER_TOKEN, "tokenFile" or "token" in ${config.file}); the owner creates a target with /deploytarget` }, 78);
90
+ let lock;
91
+ try {
92
+ lock = acquireLock(config.stateDir);
93
+ } catch (e) {
94
+ return fail(e, 75);
95
+ }
96
+ const client = createClient({ server: config.server, token: config.token, userAgent: `consilium-devops-runner/${PKG.version}` });
97
+ const state = createState(config.stateDir);
98
+ if (cmd === 'once') {
99
+ try {
100
+ const done = await tick(config, client, { state, log });
101
+ log.info(done ? 'once: done' : 'once: no approved request', done ? { deploy_id: done.id, exit: done.exitCode, health: done.health } : {});
102
+ } catch (e) {
103
+ log.error('once failed', { code: e.code ?? 'error', error: e.message });
104
+ process.exitCode = 1;
105
+ } finally {
106
+ lock.release();
107
+ }
108
+ return;
109
+ }
110
+ const runner = createRunner(config, { client, state, log, lock });
111
+ const onSignal = (sig) => runner.stop(sig);
112
+ process.on('SIGTERM', onSignal);
113
+ process.on('SIGINT', onSignal);
114
+ await runner.start();
115
+ return;
116
+ }
117
+ fail({ message: `unknown command «${cmd}» (--help)` }, 2);
118
+ }
119
+
120
+ main().catch((e) => fail(e));
package/i18n/en.json ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "tools": {}
3
+ }
package/i18n/ru.json ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "tools": {}
3
+ }
package/i18n/th.json ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "tools": {}
3
+ }
package/i18n/zh.json ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "tools": {}
3
+ }
package/package.json CHANGED
@@ -1,6 +1,50 @@
1
1
  {
2
2
  "name": "@consilium108/mcp-module-devops",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.1.0",
4
+ "description": "DevOps module of the Konsilium MCP (#442): Deploy requests by button and their status; debug reports of apps. Loaded by the host @consilium108/mcp; also runs on its own (bin consilium-devops-mcp, #482); the deploy runner service (bin consilium-devops-runner).",
5
+ "license": "SEE LICENSE IN LICENSE",
6
+ "author": "NativeMind",
7
+ "homepage": "https://konsilium.nativemind.net",
8
+ "type": "module",
9
+ "engines": {
10
+ "node": ">=22.12"
11
+ },
12
+ "exports": {
13
+ ".": "./src/index.js",
14
+ "./standalone": "./src/standalone.js",
15
+ "./runner": "./src/runner/index.js",
16
+ "./package.json": "./package.json"
17
+ },
18
+ "bin": {
19
+ "mcp-module-devops": "bin/consilium-devops-mcp.js",
20
+ "consilium-devops-mcp": "bin/consilium-devops-mcp.js",
21
+ "consilium-devops-runner": "bin/consilium-devops-runner.js"
22
+ },
23
+ "files": [
24
+ "src",
25
+ "bin",
26
+ "i18n",
27
+ "README.md",
28
+ "CHANGELOG.md",
29
+ "LICENSE"
30
+ ],
31
+ "scripts": {
32
+ "test": "node --test test/*.test.js"
33
+ },
34
+ "peerDependencies": {
35
+ "@consilium108/mcp": ">=0.7.0 <1"
36
+ },
37
+ "peerDependenciesMeta": {
38
+ "@consilium108/mcp": {
39
+ "optional": true
40
+ }
41
+ },
42
+ "dependencies": {
43
+ "@modelcontextprotocol/sdk": "^1.32.2",
44
+ "@nativemind108/mcp": "^1.13.0",
45
+ "zod": "^4.6.7"
46
+ },
47
+ "publishConfig": {
48
+ "access": "public"
49
+ }
50
+ }
package/src/errors.js ADDED
@@ -0,0 +1,12 @@
1
+ // generated by Claude (Opus 5.5), 2026-11-23; Konsilium (runner in the DevOps package): the package's coded error, shared by
2
+ // the standalone MCP (src/standalone.js) and the deploy runner (src/runner/*). No dependencies — the runner imports it
3
+ // without the MCP SDK installed.
4
+
5
+ /** An error with a stable code (shown as «code: message»). */
6
+ export class DevopsMcpError extends Error {
7
+ constructor(code, message, status = null) {
8
+ super(message);
9
+ this.code = code;
10
+ this.status = status;
11
+ }
12
+ }
@@ -0,0 +1,44 @@
1
+ // generated by Claude (Opus 5.5), 2026-11-20; Konsilium #442 (SDD flows/sdd-consilium-mcp-modules, Phase 3): debug reports of apps (Job Copilot extension, #368) — moved verbatim from
2
+ // @consilium108/mcp src/core/groups/team.js (rule «extract, don't rewrite»): the same names, schemas, texts and annotations;
3
+ // handlers use only the host helpers `h` (texts, REST with the caller's credential, forms) — never credentials.
4
+
5
+ /** Tools of `DEBUG_TOOLS` (the in-process registration order). */
6
+ export const DEBUG_TOOLS = ['get_debug_report', 'list_debug_reports', 'attach_debug_capture'];
7
+
8
+ export function registerDebugTools(server, h) {
9
+ if (h.shape === 'personal') return;
10
+ const { z, M, text, fail, safe, call, P } = h;
11
+ const ro = { readOnlyHint: true, openWorldHint: false };
12
+ const id = () => P();
13
+ /** = the in-process `choose`: a choice of one of the candidates for the person. */
14
+ const choose = (code, field, title, options) => new h.NeedsInput({ code, message: title, fields: { [field]: { type: 'enum', title, options } }, fallback: null });
15
+ /** A 409 «several fit» of REST (asked with elicit: true) → the form; anything else is rethrown. */
16
+ const ambiguous = (e, title) => {
17
+ if (e?.details && Array.isArray(e.details.options)) throw choose(e.code, e.details.field, title, e.details.options);
18
+ throw e;
19
+ };
20
+ const elicit = () => (h.elicitOn() ? true : undefined);
21
+
22
+ // #368 (#F102, Job Copilot D9): debug reports from the extension; local captures by the sender's own session
23
+ server.registerTool(
24
+ 'get_debug_report',
25
+ { title: 'Debug report', description: 'A Job Copilot debug report («Send for fixing» from the extension): URL, adapter, cards, warnings, the report JSON and the local page capture if attached.', inputSchema: { id: z.number().int() }, annotations: ro },
26
+ safe(async ({ id: reportId }, ctx) => text(await call(ctx, 'GET', '/api/projects/{id}/debug-reports/{reportId}', { id: id(), reportId }))),
27
+ );
28
+ server.registerTool(
29
+ 'list_debug_reports',
30
+ { title: 'Debug reports', description: 'Job Copilot debug reports visible to you (newest first): state needs_capture (waits for the sender\'s local capture) or ready (ready for fixing), filter by site.', inputSchema: { state: z.enum(['needs_capture', 'ready']).optional(), site: z.string().max(100).optional() }, annotations: ro },
31
+ safe(async ({ state, site }, ctx) => text({ reports: (await call(ctx, 'GET', '/api/projects/{id}/debug-reports', { id: id(), state, site })).reports })),
32
+ );
33
+ server.registerTool(
34
+ 'attach_debug_capture',
35
+ {
36
+ title: 'Attach a local page capture',
37
+ description:
38
+ 'Only for the sender\'s own Claude Code session (claude-in-chrome in their browser): attach the page capture (≤ 1 MB JSON — DOM excerpts, selectors, screenshots as data URLs; never keys, cookies, form values or chat texts). The fix task becomes ready for anyone.',
39
+ inputSchema: { id: z.number().int(), capture: z.record(z.string(), z.any()) },
40
+ annotations: { readOnlyHint: false, openWorldHint: false },
41
+ },
42
+ safe(async ({ id: reportId, capture }, ctx) => text(await call(ctx, 'POST', '/api/projects/{id}/debug-reports/{reportId}/capture', { id: id(), reportId, capture }))),
43
+ );
44
+ }
@@ -0,0 +1,54 @@
1
+ // generated by Claude (Opus 5.5), 2026-11-20; Konsilium #442 (SDD flows/sdd-consilium-mcp-modules, Phase 3): deploy by button (request_deploy, deploy_status) — moved verbatim from
2
+ // @consilium108/mcp src/core/groups/teamops.js (rule «extract, don't rewrite»): the same names, schemas, texts and annotations;
3
+ // handlers use only the host helpers `h` (texts, REST with the caller's credential, forms) — never credentials.
4
+
5
+ /** Tools of `DEPLOY_TOOLS` (the in-process registration order). */
6
+ export const DEPLOY_TOOLS = ['request_deploy', 'deploy_status'];
7
+
8
+ const JOB_STATUSES = ['Queued', 'Evaluated', 'Applied', 'Responded', 'Interview', 'Offer', 'Rejected', 'Discarded', 'SKIP', 'Hired'];
9
+
10
+ export function registerDeployTools(server, h) {
11
+ if (h.shape === 'personal') return; // only the project MCP registers these (buildMcpServer)
12
+ const { z, text, fail, safe, call, P } = h;
13
+ const ro = { readOnlyHint: true, openWorldHint: false };
14
+
15
+ // ── deploytools.js
16
+ server.registerTool(
17
+ 'request_deploy',
18
+ {
19
+ title: 'Request a deploy',
20
+ description:
21
+ 'Ask the people who may deploy this project to approve a deploy of a target (they get «Deploy? ✅ / No» in the messenger; a runner on the project server does the rest and reports). Put in `summary` what changes and that tests passed. You cannot approve it yourself. Returns the request id; poll deploy_status.',
22
+ inputSchema: { target: z.string().max(41).optional().describe('Target key (e.g. konsilium-prod); optional if the project has one target.'), summary: z.string().min(3).max(2000) },
23
+ annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: true },
24
+ },
25
+ safe(async ({ target, summary }, ctx) => {
26
+ const r = await call(ctx, 'POST', '/api/projects/{id}/tool/request_deploy', { id: P(), target, summary });
27
+ return text({ ...r, next: 'Wait for a human to approve; then call deploy_status(deploy_id).' });
28
+ }),
29
+ );
30
+ server.registerTool(
31
+ 'deploy_status',
32
+ {
33
+ title: 'Deploy status',
34
+ description: 'Status of a deploy request: pending → approved → running → done | failed (or rejected / expired), exit code, health, log tail.',
35
+ inputSchema: { deploy_id: z.number().int() },
36
+ annotations: { readOnlyHint: true, openWorldHint: false },
37
+ },
38
+ safe(async ({ deploy_id }, ctx) => text(await call(ctx, 'GET', '/api/projects/{id}/deploys/{deployId}', { id: P(), deployId: deploy_id }))),
39
+ );
40
+
41
+ // ── calltools.js (the discussions right is checked here as well, with the in-process text)
42
+ const callProject = (project_id) => {
43
+ const p = project_id ?? P();
44
+ if (!p) return { error: fail('no_project: no project: pass project_id') };
45
+ if (!h.scopesFor(p).includes('discussions')) return { error: fail('forbidden: forbidden: calls need the discussions right of the project (the person changes access in Konsilium)') };
46
+ return { p };
47
+ };
48
+
49
+ // ── grouptools.js
50
+
51
+ // ── paytools.js
52
+
53
+ // ── jobtools.js (registered after the project tools: no project_id; the project rows are those of the call's project)
54
+ }
@@ -0,0 +1,125 @@
1
+ // generated by Claude (Opus 5.5), 2026-11-22; Konsilium #482 (TASK-P37-482, the standalone DevOps MCP): read tools over the
2
+ // DevOps module API — deploy targets (with the runner's last heartbeat) and the recent deploy requests of a project.
3
+ // Not a group of the module definition yet (the host @consilium108/mcp and the cloud MCP keep their catalog unchanged);
4
+ // the standalone server (src/standalone.js) registers it. Handlers use only the host-style helpers `h`.
5
+
6
+ /** Tools of `OPS_TOOLS` (the registration order). */
7
+ export const OPS_TOOLS = ['list_deploy_targets', 'list_deploys', 'runner_status', 'runner_setup'];
8
+
9
+ /** A runner polls every 10 s; no heartbeat for longer than this → offline. */
10
+ export const RUNNER_ONLINE_SEC = 120;
11
+
12
+ /** SQLite `datetime('now')` (UTC, «YYYY-MM-DD HH:MM:SS») or ISO → ms, else null. */
13
+ export function parseServerTime(s) {
14
+ if (!s) return null;
15
+ const t = Date.parse(/[zZ]|[+-]\d\d:?\d\d$/.test(s) ? s : `${String(s).replace(' ', 'T')}Z`);
16
+ return Number.isFinite(t) ? t : null;
17
+ }
18
+
19
+ /** Targets + recent deploys → the runner's status per target (pure; tested). */
20
+ export function runnerStatusOf(targets, deploys, { now = Date.now(), onlineSec = RUNNER_ONLINE_SEC } = {}) {
21
+ return (targets ?? []).map((t) => {
22
+ const seen = parseServerTime(t.lastSeenAt ?? t.last_seen_at);
23
+ const ago = seen == null ? null : Math.max(0, Math.round((now - seen) / 1000));
24
+ const mine = (deploys ?? []).filter((d) => d.target === t.key);
25
+ const running = mine.find((d) => d.status === 'running') ?? null;
26
+ const waiting = mine.filter((d) => d.status === 'approved' || d.status === 'pending');
27
+ const last = mine.find((d) => d.status === 'done' || d.status === 'failed') ?? null;
28
+ return {
29
+ key: t.key,
30
+ title: t.title ?? null,
31
+ last_seen_at: t.lastSeenAt ?? t.last_seen_at ?? null,
32
+ seconds_since_seen: ago,
33
+ online: ago != null && ago <= onlineSec,
34
+ state: ago == null ? 'never_seen' : ago <= onlineSec ? (running ? 'running' : 'idle') : 'offline',
35
+ current_job: running ? { id: running.id, kind: running.kind ?? 'deploy', started_at: running.startedAt ?? null, summary: running.summary ?? null } : null,
36
+ waiting: waiting.map((d) => ({ id: d.id, status: d.status, kind: d.kind ?? 'deploy' })),
37
+ last_finished: last ? { id: last.id, status: last.status, exit_code: last.exitCode ?? null, health: last.health ?? null, finished_at: last.finishedAt ?? null } : null,
38
+ };
39
+ });
40
+ }
41
+
42
+ export function registerOpsTools(server, h) {
43
+ if (h.shape === 'personal') return;
44
+ const { z, text, safe, call, P } = h;
45
+ const arr = (r, k) => (Array.isArray(r) ? r : (r?.[k] ?? []));
46
+ const ro = { readOnlyHint: true, openWorldHint: false };
47
+ const pid = (project_id) => project_id ?? P();
48
+
49
+ server.registerTool(
50
+ 'list_deploy_targets',
51
+ {
52
+ title: 'Deploy targets',
53
+ description:
54
+ 'Deploy targets of the project (key, title) and when the runner on the project server last called in (lastSeenAt — the runner is alive if it is recent). Only people with the deploy right of the project (owner, co-owners, granted members) see them; otherwise no_deploy_right. Targets and rights are created by a person in Konsilium (bot /deploytarget or the app), never by an AI.',
55
+ inputSchema: { project_id: z.number().int().positive().optional().describe('Project id; default — the active project.') },
56
+ annotations: ro,
57
+ },
58
+ safe(async ({ project_id }, ctx) => {
59
+ const id = pid(project_id);
60
+ const r = await call(ctx, 'GET', '/api/projects/{id}/deploy-targets', { id });
61
+ return text({ project_id: id, targets: Array.isArray(r) ? r : (r?.targets ?? r) });
62
+ }),
63
+ );
64
+ server.registerTool(
65
+ 'list_deploys',
66
+ {
67
+ title: 'Recent deploy requests',
68
+ description:
69
+ 'The last deploy requests of the project (newest first, up to 20): target, status pending → approved → running → done | failed (or rejected / expired), who asked, exit code, health. Details and the log tail of one request — deploy_status.',
70
+ inputSchema: { project_id: z.number().int().positive().optional().describe('Project id; default — the active project.') },
71
+ annotations: ro,
72
+ },
73
+ safe(async ({ project_id }, ctx) => {
74
+ const id = pid(project_id);
75
+ const r = await call(ctx, 'GET', '/api/projects/{id}/deploys', { id });
76
+ return text({ project_id: id, deploys: Array.isArray(r) ? r : (r?.deploys ?? r) });
77
+ }),
78
+ );
79
+ // generated by Claude (Opus 5.5), 2026-11-23: the runner service (bin consilium-devops-runner) seen from the MCP — status and
80
+ // the install steps as text. The MCP never runs, installs or approves anything; the runner is a separate process.
81
+ server.registerTool(
82
+ 'runner_status',
83
+ {
84
+ title: 'Deploy runner status',
85
+ description:
86
+ 'Is the deploy runner of each target alive: last heartbeat (last_seen_at, seconds ago), online / offline (no heartbeat for more than 2 minutes), the job it is running now, approved requests waiting for it, the last finished one. Needs the deploy right of the project. If a target is offline, runner_setup gives the install / restart steps for a person.',
87
+ inputSchema: { project_id: z.number().int().positive().optional().describe('Project id; default — the active project.') },
88
+ annotations: ro,
89
+ },
90
+ safe(async ({ project_id }, ctx) => {
91
+ const id = pid(project_id);
92
+ const targets = arr(await call(ctx, 'GET', '/api/projects/{id}/deploy-targets', { id }), 'targets');
93
+ const deploys = arr(await call(ctx, 'GET', '/api/projects/{id}/deploys', { id }), 'deploys');
94
+ const runners = runnerStatusOf(targets, deploys);
95
+ return text({
96
+ project_id: id,
97
+ online_window_sec: RUNNER_ONLINE_SEC,
98
+ runners,
99
+ ...(runners.some((r) => !r.online) ? { hint: 'An offline target: a person checks the service on the host (systemctl status consilium-devops-runner; journalctl -u consilium-devops-runner) — runner_setup has the steps.' } : {}),
100
+ ...(runners.length ? {} : { hint: 'No deploy targets: the owner creates one in the bot (/deploytarget <key> <title>), never an AI.' }),
101
+ });
102
+ }),
103
+ );
104
+ server.registerTool(
105
+ 'runner_setup',
106
+ {
107
+ title: 'Deploy runner: install steps',
108
+ description:
109
+ 'The exact steps for a PERSON to bring up the deploy runner on a project host (Linux, systemd): target token via /deploytarget in the bot, the config outside the repository (chmod 600), `consilium-devops-runner doctor`, the systemd unit, a trial deploy, stop and rollback. Returns text only — it installs, starts and creates nothing (no tokens).',
110
+ inputSchema: {
111
+ target: z.string().min(2).max(41).optional().describe('Target key, default konsilium-prod.'),
112
+ repo_dir: z.string().max(500).optional().describe('The checkout on the host the target deploys (cwd of the steps).'),
113
+ user: z.string().max(64).optional().describe('The host account that runs the service (in the docker group).'),
114
+ mode: z.enum(['system', 'user']).optional().describe('system service with User= (default, starts at boot) or a user service.'),
115
+ node: z.string().max(300).optional().describe('Absolute path of node on the host (default /usr/local/bin/node).'),
116
+ },
117
+ annotations: ro,
118
+ },
119
+ safe(async ({ target, repo_dir, user, mode, node }) => {
120
+ const { installSteps } = await import('../runner/install.js');
121
+ const steps = installSteps({ target: target ?? 'konsilium-prod', repoDir: repo_dir ?? '/path/to/consilium.nativemind.net', user: user ?? 'konsilium', mode: mode ?? 'system', node: node ?? '/usr/local/bin/node' });
122
+ return text({ installs_nothing: true, service: 'consilium-devops-runner', steps });
123
+ }),
124
+ );
125
+ }
package/src/index.js ADDED
@@ -0,0 +1,36 @@
1
+ // generated by Claude (Opus 5.5), 2026-11-20; Konsilium #442 (SDD flows/sdd-consilium-mcp-modules, Tasks 3.2–3.6)
2
+ // The DevOps module of the Konsilium MCP: a separately published package the host @consilium108/mcp loads
3
+ // (in 0.x the host loads all five modules, so every client keeps the same tools). A person enables or disables the
4
+ // module per connection (OAuth consent page, Konsilium → Connected apps); the server checks it on every call (the MCP
5
+ // guard, REST / GraphQL by key, events) — hiding a tool is never the protection. Rights (scopes) do not change.
6
+ import { readFileSync } from 'node:fs';
7
+ import { defineMcpModule } from '@nativemind108/mcp';
8
+ import { DEBUG_TOOLS, registerDebugTools } from './groups/debug.js';
9
+ import { DEPLOY_TOOLS, registerDeployTools } from './groups/deploy.js';
10
+
11
+ const PKG = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
12
+ const LANGS = ["en", "ru", "th", "zh"];
13
+ /** Catalog texts of the module's tools (merged into the host's catalog by its ModuleHost). */
14
+ const I18N = Object.fromEntries(LANGS.map((l) => [l, JSON.parse(readFileSync(new URL(`../i18n/${l}.json`, import.meta.url), 'utf8'))]));
15
+
16
+ export default defineMcpModule({
17
+ id: 'devops',
18
+ name: PKG.name,
19
+ version: PKG.version,
20
+ host: PKG.peerDependencies['@consilium108/mcp'],
21
+ title: {"en": "DevOps", "ru": "DevOps", "th": "DevOps", "zh": "DevOps", "ja": "DevOps"},
22
+ summary: {"en": "Deploy requests by button and their status; debug reports of apps.", "ru": "Запросы выкатки по кнопке и их статус; отчёты отладки приложений.", "th": "คำขอดีพลอยผ่านปุ่มและสถานะ; รายงานดีบักของแอป", "zh": "按按钮请求部署及其状态;应用的调试报告。", "ja": "ボタンによるデプロイ依頼とその状況、アプリのデバッグレポート。"},
23
+ groups: {
24
+ debug: { tools: DEBUG_TOOLS, register: registerDebugTools },
25
+ deploy: { tools: DEPLOY_TOOLS, register: registerDeployTools },
26
+ },
27
+ localTools: [],
28
+ prompts: ["release_prepare"],
29
+ requiresScopes: ["tasks:work"],
30
+ i18n: I18N,
31
+ aliases: {},
32
+ });
33
+
34
+ export { DEBUG_TOOLS, registerDebugTools, DEPLOY_TOOLS, registerDeployTools };
35
+ // #482 (Claude (Opus 5.5), 2026-11-22): read tools of the standalone DevOps MCP (not a group of the host catalog yet)
36
+ export { OPS_TOOLS, registerOpsTools } from './groups/ops.js';
@@ -0,0 +1,42 @@
1
+ // generated by Claude (Opus 5.5), 2026-11-23; Konsilium (deploy runner in @consilium108/mcp-module-devops). Ported from
2
+ // deploy-runner/runner.js: the runner's API client — POST /api/deploy/runner/{heartbeat,claim,:id/result} of the core with
3
+ // the target's runner token (kdr_…, never a person's key). The core proxies these to the DevOps module (MODULE_DEVOPS=remote).
4
+ // Errors are the package's coded DevopsMcpError; the token never appears in a message.
5
+ import { DevopsMcpError } from '../errors.js';
6
+
7
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
8
+
9
+ export function createClient({ server, token, fetchImpl = fetch, userAgent = 'consilium-devops-runner', timeoutMs = 30_000 }) {
10
+ const base = String(server ?? '').replace(/\/+$/, '');
11
+ const call = async (path, body) => {
12
+ let r;
13
+ try {
14
+ r = await fetchImpl(`${base}/api/deploy/runner${path}`, {
15
+ method: 'POST',
16
+ headers: { authorization: `Bearer ${token}`, 'content-type': 'application/json', 'user-agent': userAgent },
17
+ body: JSON.stringify(body ?? {}),
18
+ signal: AbortSignal.timeout(timeoutMs),
19
+ });
20
+ } catch (e) {
21
+ throw new DevopsMcpError('network_unavailable', `${path}: ${e?.cause?.code ?? e?.name ?? 'network error'}`, 0);
22
+ }
23
+ if (!r.ok) {
24
+ const code = r.status === 401 ? 'bad_runner_token' : r.status === 404 ? 'not_found' : r.status === 503 ? 'module_unavailable' : `http_${r.status}`;
25
+ throw new DevopsMcpError(code, `${path}: HTTP ${r.status}${r.status === 401 ? ' (the runner token is wrong or the target was deleted — the owner creates a target with /deploytarget)' : ''}`, r.status);
26
+ }
27
+ return r.json();
28
+ };
29
+ // #140: the app restarts during a deploy (or a rollback) — the result must survive a few 502s, else the request hangs in «running»
30
+ const result = async (id, res, { tries = 20, delayMs = 6000 } = {}) => {
31
+ const body = { exitCode: res.exitCode, logTail: res.logTail, health: res.health ?? null };
32
+ for (let i = 0; ; i++) {
33
+ try {
34
+ return await call(`/${id}/result`, body);
35
+ } catch (e) {
36
+ if (e.status === 404 || e.status === 401 || i >= tries - 1) throw e;
37
+ await sleep(delayMs);
38
+ }
39
+ }
40
+ };
41
+ return { heartbeat: () => call('/heartbeat'), claim: async () => (await call('/claim')).request, result };
42
+ }