integram-mcp 0.7.36 → 0.7.39
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 +4 -4
- package/activation-memory.js +50 -0
- package/index.js +6 -29
- package/orphan-watchdog.js +74 -0
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ claude mcp add integram \
|
|
|
15
15
|
-e INTEGRAM_URL=https://ai2o.online \
|
|
16
16
|
-e INTEGRAM_EMAIL=you@example.com \
|
|
17
17
|
-e INTEGRAM_PASSWORD=secret \
|
|
18
|
-
-- npx -y integram-mcp@0.7.
|
|
18
|
+
-- npx -y integram-mcp@0.7.39
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
Ставить ничего не нужно: `npx` скачает пакет сам.
|
|
@@ -43,7 +43,7 @@ claude mcp add integram \
|
|
|
43
43
|
-e INTEGRAM_URL=http://localhost:8081 \
|
|
44
44
|
-e INTEGRAM_EMAIL=you@example.com \
|
|
45
45
|
-e INTEGRAM_PASSWORD=secret \
|
|
46
|
-
-- npx -y integram-mcp@0.7.
|
|
46
|
+
-- npx -y integram-mcp@0.7.39
|
|
47
47
|
```
|
|
48
48
|
|
|
49
49
|
Удалить: `claude mcp remove integram`
|
|
@@ -57,7 +57,7 @@ claude mcp add integram \
|
|
|
57
57
|
"mcpServers": {
|
|
58
58
|
"integram": {
|
|
59
59
|
"command": "npx",
|
|
60
|
-
"args": ["-y", "integram-mcp@0.7.
|
|
60
|
+
"args": ["-y", "integram-mcp@0.7.39"],
|
|
61
61
|
"env": {
|
|
62
62
|
"INTEGRAM_URL": "https://ai2o.online",
|
|
63
63
|
"INTEGRAM_EMAIL": "you@example.com",
|
|
@@ -77,7 +77,7 @@ claude mcp add integram \
|
|
|
77
77
|
"mcpServers": {
|
|
78
78
|
"integram": {
|
|
79
79
|
"command": "npx",
|
|
80
|
-
"args": ["-y", "integram-mcp@0.7.
|
|
80
|
+
"args": ["-y", "integram-mcp@0.7.39"],
|
|
81
81
|
"env": {
|
|
82
82
|
"INTEGRAM_URL": "https://ai2o.online",
|
|
83
83
|
"INTEGRAM_EMAIL": "you@example.com",
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Память активации инструментов по воркспейсу.
|
|
3
|
+
*
|
|
4
|
+
* Инцидент 05.09.2026: switch_workspace субагента делал activeTools.clear()
|
|
5
|
+
* + core-only — сброс был ГЛОБАЛЬНЫМ (activeTools — Map на весь процесс
|
|
6
|
+
* сервера), и неядерная активация пропадала у всех сеансов разом. Фикс:
|
|
7
|
+
* переключение воркспейса запоминает неядерную активацию уходящего воркспейса
|
|
8
|
+
* и восстанавливает активацию целевого. Сброс до ядра остаётся только там,
|
|
9
|
+
* где памяти о воркспейсе нет (первое посещение).
|
|
10
|
+
*
|
|
11
|
+
* Чистые функции без зависимостей от сервера: index.js зовёт их со своим
|
|
12
|
+
* Map (slug → Set имён), списком активных имён и списком выкачанных
|
|
13
|
+
* дефиниций инструментов. Проверяются tests/activation-memory.test.js.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/** Неядерные имена из перечня активных: built-in живут всегда отдельно. */
|
|
17
|
+
export function nonCoreNames(activeNames, builtInNames) {
|
|
18
|
+
const builtIn = new Set(builtInNames);
|
|
19
|
+
return activeNames.filter((n) => !builtIn.has(n));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Запомнить текущую неядерную активацию под слагом. Пустой слаг игнорируется. */
|
|
23
|
+
export function rememberActivation(map, slug, activeNames, builtInNames) {
|
|
24
|
+
if (!slug) return;
|
|
25
|
+
map.set(slug, new Set(nonCoreNames(activeNames, builtInNames)));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Забыть воркспейс (удаление): сохранённая активация мёртвого не нужна. */
|
|
29
|
+
export function forgetActivation(map, slug) {
|
|
30
|
+
map.delete(slug);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Восстановить сохранённую активацию целевого воркспейса: для каждой
|
|
35
|
+
* выкачанной дефиниции, чьё имя сохранено, звать setActive. Возвращает число
|
|
36
|
+
* восстановленных. Имена, которых в выкачке нет (инструмент исчез из
|
|
37
|
+
* воркспейса), молча пропускаются — их всё равно нечем исполнить.
|
|
38
|
+
*/
|
|
39
|
+
export function applyActivation(map, slug, availableTools, setActive) {
|
|
40
|
+
const saved = map.get(slug);
|
|
41
|
+
if (!saved?.size) return 0;
|
|
42
|
+
let restored = 0;
|
|
43
|
+
for (const t of availableTools) {
|
|
44
|
+
if (saved.has(t.name)) {
|
|
45
|
+
setActive(t);
|
|
46
|
+
restored += 1;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return restored;
|
|
50
|
+
}
|
package/index.js
CHANGED
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
} from '@modelcontextprotocol/sdk/types.js';
|
|
25
25
|
import { createRequire } from 'module';
|
|
26
26
|
import { rememberActivation as rememberActivationIn, applyActivation, forgetActivation } from './activation-memory.js';
|
|
27
|
+
import { startOrphanWatchdog } from './orphan-watchdog.js';
|
|
27
28
|
|
|
28
29
|
// Own identity — read from package.json, never hardcoded: a hardcoded copy drifts
|
|
29
30
|
// (it sat at 0.5.0 through the 0.6.0 and 0.7.0 releases).
|
|
@@ -730,7 +731,7 @@ Event-driven rules: when X happens → check condition → do Y. Activate via se
|
|
|
730
731
|
|
|
731
732
|
create_automation({ name, trigger: { type, typeId }, active?, condition, actions: [{ type, config }] })
|
|
732
733
|
- active: false — создать выключенной (по умолчанию включена; выключенная не встаёт в расписание и не срабатывает)
|
|
733
|
-
- Trigger types: on_create, on_update, on_delete, on_deadline, on_webhook, on_form_submit, schedule, manual, ai_analysis, on_metric_threshold, on_metric_silence, on_document, on_telegram_command, on_telegram_message, on_telegram_pre_checkout, on_telegram_shipping, on_telegram_payment, on_telegram_inline, on_telegram_join_request, on_telegram_business_connection, on_telegram_business_message, on_bot_chat_member, pm_deadline, on_issue_commented, on_issue_updated
|
|
734
|
+
- Trigger types: on_create, on_update, on_delete, on_deadline, on_webhook, on_form_submit, schedule, manual, ai_analysis, on_metric_threshold, on_metric_silence, on_document, on_ncl_run_completed, on_ncl_requirement_created, on_ncl_evidence_stale, on_telegram_command, on_telegram_message, on_telegram_pre_checkout, on_telegram_shipping, on_telegram_payment, on_telegram_inline, on_telegram_join_request, on_telegram_business_connection, on_telegram_business_message, on_bot_chat_member, pm_deadline, on_issue_commented, on_issue_updated, on_issue_created, on_issue_status_changed, on_sprint_started, on_sprint_completed
|
|
734
735
|
pm_deadline: { days: N (за сколько дней до due_date PM-задачи, default 1), hour: 0-23 (час UTC ежедневного скана, default 7) }; в действиях доступны {{pm_title}}, {{pm_number}}, {{pm_due_date}}, {{pm_assignee_email}} (send_notification адресуйте username: '{{pm_assignee_email}}')
|
|
735
736
|
on_issue_commented / on_issue_updated: событие PM-задачи (комментарий / правка полей), pm-переменные те же
|
|
736
737
|
- Actions: send_notification, send_notification_to_group, update_field, create_object, delete_object, fire_webhook, run_ai_agent, run_script, run_server_function, send_telegram, run_connector, send_email, update_related_records, set_requisite, update_related, http_request, if_else, switch, transform, wait_delay, request_approval, delegate_to_agent, invoke_agent, send_invoice, telegram_forward, answer_inline_query, telegram_ban, telegram_unban, telegram_restrict, telegram_promote, telegram_approve_join, telegram_decline_join, telegram_pin, telegram_unpin, telegram_get_chat, telegram_post_story, answer_shipping, telegram_business_reply, create_issue, update_issue
|
|
@@ -2248,34 +2249,10 @@ async function main() {
|
|
|
2248
2249
|
// закрытии сессии — известная проблема экосистемы (anthropics/claude-code#22612):
|
|
2249
2250
|
// пары «npm exec + node» остаются жить сутками с токенами доступа внутри
|
|
2250
2251
|
// (замер от юзер-репорта 01.09.2026: 96 процессов, 2,88 ГБ RSS). Клиентский баг
|
|
2251
|
-
// нам не подвластен — завершаемся
|
|
2252
|
-
//
|
|
2253
|
-
//
|
|
2254
|
-
//
|
|
2255
|
-
// Живой клиент переносит смерть сервера безболезненно: stdio-сервер
|
|
2256
|
-
// перезапускается по требованию при следующем вызове.
|
|
2257
|
-
//
|
|
2258
|
-
// ВЫХОД ТОЛЬКО ПО СИРОТСТВУ (ppid сменился — родитель умер). Условие «час без
|
|
2259
|
-
// завершённых вызовов» здесь жить не должно: инцидент 03.09.2026 — живая
|
|
2260
|
-
// сессия не звала integram-инструменты час, сторож тихо сделал exit(0),
|
|
2261
|
-
// у клиента «MCP error», потребовался ручной reconnect. Простой живой сессии —
|
|
2262
|
-
// не признак сиротства; смерть родителя ловит проверка ppid, смерть клиента —
|
|
2263
|
-
// stdin end/close.
|
|
2264
|
-
let ppid0 = process.ppid;
|
|
2265
|
-
const ORPHAN_WATCHDOG_MS = 30_000;
|
|
2266
|
-
|
|
2267
|
-
function startOrphanWatchdog() {
|
|
2268
|
-
process.stdin.on('end', () => process.exit(0));
|
|
2269
|
-
process.stdin.on('close', () => process.exit(0));
|
|
2270
|
-
// SIGTERM/SIGINT: юзер-репорт 55 назвал прямо — «эти процессы не берёт».
|
|
2271
|
-
// node с хендлерами SDK глотает сигналы и висит; здесь — явный выход.
|
|
2272
|
-
process.on('SIGTERM', () => process.exit(0));
|
|
2273
|
-
process.on('SIGINT', () => process.exit(0));
|
|
2274
|
-
const timer = setInterval(() => {
|
|
2275
|
-
if (process.ppid !== ppid0) process.exit(0);
|
|
2276
|
-
}, ORPHAN_WATCHDOG_MS);
|
|
2277
|
-
timer.unref();
|
|
2278
|
-
}
|
|
2252
|
+
// нам не подвластен — завершаемся сами; механизмы и их история — в модуле
|
|
2253
|
+
// orphan-watchdog.js. ВЫХОД ТОЛЬКО ПО СИРОТСТВУ, не по простою: инцидент
|
|
2254
|
+
// 03.09.2026 — живая сессия не звала integram-инструменты час, сторож тихо
|
|
2255
|
+
// сделал exit(0), у клиента «MCP error», потребовался ручной reconnect.
|
|
2279
2256
|
|
|
2280
2257
|
// Run only when executed as a program, not when imported. The guard test imports
|
|
2281
2258
|
// `selectTools` from this file; without this check the import would log in, open a
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Самозавершение осиротевшего MCP-сервера. См. комментарий в index.js перед
|
|
3
|
+
* вызовом startOrphanWatchdog: клиенты (Claude Code, Cursor) не всегда убивают
|
|
4
|
+
* процессы при закрытии сессии (anthropics/claude-code#22612).
|
|
5
|
+
*
|
|
6
|
+
* Четыре независимых механизма:
|
|
7
|
+
* 1. stdin закрылся — клиент мёртв (для stdio-транспорта это канал жизни);
|
|
8
|
+
* 2. ppid сменился — родитель умер, сироту переусыновил init;
|
|
9
|
+
* 3. ppid РОДИТЕЛЯ сменился («дедушка») — обёртка npm exec осиротела.
|
|
10
|
+
* Случай юзер-репорта 05.09.2026: клиент запускает `npx integram-mcp`,
|
|
11
|
+
* пара «npm exec + node» переусыновляется init'ом ЦЕЛИКОМ — у node ppid
|
|
12
|
+
* не меняется (родитель — npm exec, он жив), stdin не закрывается
|
|
13
|
+
* (обёртка трубу ребёнку не пробрасывает). Смерть настоящего клиента
|
|
14
|
+
* видна только на уровень выше: родитель осиротел, его родителем стал
|
|
15
|
+
* init. Linux-only (читаем /proc), на других платформах проверка
|
|
16
|
+
* молча пропускается;
|
|
17
|
+
*
|
|
18
|
+
* ВАЖНО: `process.ppid` в Node кэшируется на старте и после смерти родителя
|
|
19
|
+
* НЕ меняется (замер 05.09.2026: дочерний процесс после SIGKILL родителя
|
|
20
|
+
* печатает прежний ppid каждые 200 мс). Прежний механизм 2 в index.js,
|
|
21
|
+
* сравнивавший process.ppid с исходным, был мёртвым кодом. Живой ppid
|
|
22
|
+
* читаем из /proc/<pid>/stat на каждом тике.
|
|
23
|
+
* 4. SIGTERM/SIGINT — явный выход (node с хендлерами SDK глотает сигналы).
|
|
24
|
+
*
|
|
25
|
+
* Живой клиент переносит смерть сервера безболезненно: stdio-сервер
|
|
26
|
+
* перезапускается по требованию при следующем вызове.
|
|
27
|
+
*/
|
|
28
|
+
import { readFileSync } from 'fs';
|
|
29
|
+
|
|
30
|
+
/** Поле 4 из /proc/<pid>/stat — ppid. comm в скобках может содержать пробелы,
|
|
31
|
+
* поэтому режем по последнему ')'. Процесс отсутствует → null. */
|
|
32
|
+
export function readPpid(pid) {
|
|
33
|
+
try {
|
|
34
|
+
const stat = readFileSync(`/proc/${pid}/stat`, 'utf8');
|
|
35
|
+
return Number(stat.slice(stat.lastIndexOf(')') + 2).trim().split(' ')[1]);
|
|
36
|
+
} catch {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @param {object} [opts]
|
|
43
|
+
* @param {boolean} [opts.watchStdin=true] — в тестах stdin бывает уже закрыт;
|
|
44
|
+
* false отключает механизмы 1 и 4-частично (SIGTERM/SIGINT остаются).
|
|
45
|
+
* @param {number} [opts.intervalMs=30000]
|
|
46
|
+
*/
|
|
47
|
+
export function startOrphanWatchdog({ watchStdin = true, intervalMs = 30_000 } = {}) {
|
|
48
|
+
const ppid0 = readPpid(process.pid) ?? process.ppid;
|
|
49
|
+
// ppid нашего родителя («дедушка») на старте. null — не Linux или родитель
|
|
50
|
+
// уже исчез; тогда остаётся кэшированный process.ppid и stdin.
|
|
51
|
+
const gp0 = readPpid(ppid0);
|
|
52
|
+
|
|
53
|
+
if (watchStdin) {
|
|
54
|
+
process.stdin.on('end', () => process.exit(0));
|
|
55
|
+
process.stdin.on('close', () => process.exit(0));
|
|
56
|
+
process.on('SIGTERM', () => process.exit(0));
|
|
57
|
+
process.on('SIGINT', () => process.exit(0));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const timer = setInterval(() => {
|
|
61
|
+
const ppid = readPpid(process.pid);
|
|
62
|
+
if (ppid === null) {
|
|
63
|
+
// Не Linux (/proc нет) — остаётся кэшированная копия, хуже не стало.
|
|
64
|
+
if (process.ppid !== ppid0) process.exit(0);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (ppid !== ppid0) process.exit(0);
|
|
68
|
+
// Родитель переусыновлён (его родителем стал init) или исчез между
|
|
69
|
+
// проверками — пара осиротела вместе.
|
|
70
|
+
if (gp0 !== null && readPpid(ppid) !== gp0) process.exit(0);
|
|
71
|
+
}, intervalMs);
|
|
72
|
+
timer.unref();
|
|
73
|
+
return timer;
|
|
74
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "integram-mcp",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.39",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "MCP server for Integram — connect AI assistants to your workspace via Model Context Protocol",
|
|
6
6
|
"mcpName": "io.github.judas-priest/integram",
|
|
@@ -24,7 +24,9 @@
|
|
|
24
24
|
"prepublishOnly": "node scripts/check-versions.mjs"
|
|
25
25
|
},
|
|
26
26
|
"files": [
|
|
27
|
-
"index.js"
|
|
27
|
+
"index.js",
|
|
28
|
+
"activation-memory.js",
|
|
29
|
+
"orphan-watchdog.js"
|
|
28
30
|
],
|
|
29
31
|
"dependencies": {
|
|
30
32
|
"@modelcontextprotocol/sdk": "^1.12.1",
|