integram-mcp 0.7.71 → 0.7.77

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.
Files changed (3) hide show
  1. package/README.md +8 -4
  2. package/index.js +53 -5
  3. package/package.json +1 -1
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.71
18
+ -- npx -y integram-mcp@0.7.77
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.71
46
+ -- npx -y integram-mcp@0.7.77
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.71"],
60
+ "args": ["-y", "integram-mcp@0.7.77"],
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.71"],
80
+ "args": ["-y", "integram-mcp@0.7.77"],
81
81
  "env": {
82
82
  "INTEGRAM_URL": "https://ai2o.online",
83
83
  "INTEGRAM_EMAIL": "you@example.com",
@@ -111,6 +111,10 @@ claude mcp add integram -e INTEGRAM_URL=... -e INTEGRAM_EMAIL=... -e INTEGRAM_PA
111
111
 
112
112
  Чего здесь намеренно нет: пакета `update-notifier` — он печатает в `stdout` и только при TTY, то есть под stdio-транспортом не сработает и сломает протокол; и протокольного `notifications/message` — он объявлен устаревшим в версии протокола `2026-07-28`, а отправка до `initialize` ломает строгие клиенты.
113
113
 
114
+ ## Уведомления
115
+
116
+ - On startup the server checks unread notifications across workspaces and appends a summary to the first tool response.
117
+
114
118
  ## Переменные окружения
115
119
 
116
120
  | Переменная | Обязательна | По умолчанию | Описание |
package/index.js CHANGED
@@ -206,10 +206,54 @@ async function checkForUpdate() {
206
206
  // Приписывает сигнал к КАЖДОМУ ответу инструмента, пока юзер не обновится:
207
207
  // одноразовая приписка в длинной сессии теряется, а устаревшая сборка — это
208
208
  // дыра против юзера (нет новых тулов и фиксов до ручного обновления).
209
- function withUpdateNotice(result) {
210
- if (!updateNotice) return result;
209
+ export function withUpdateNotice(result) {
211
210
  if (!result || !Array.isArray(result.content)) return result;
212
- return { ...result, content: [...result.content, { type: 'text', text: updateNotice }] };
211
+ let extra = [];
212
+ if (updateNotice) extra.push(updateNotice);
213
+ if (unreadNotice) { extra.push(unreadNotice); unreadNotice = null; }
214
+ if (!extra.length) return result;
215
+ return { ...result, content: [...result.content, { type: 'text', text: extra.join('\n') }] };
216
+ }
217
+
218
+ // ─── Сводка непрочитанных при старте ────────────────────────────────────────
219
+ //
220
+ // Канал «сервер MCP → модель → пользователь» без подписок из спецификации
221
+ // 2026-07-28 (в Claude Code их ещё нет): приписка к ответу инструмента.
222
+ // Одноразовая — сводка в каждом ответе была бы спамом (сигнал обновления
223
+ // приписывается ДО ОБНОВЛЕНИЯ к каждому — там одноразовость вредна).
224
+
225
+ let unreadNotice = null;
226
+
227
+ export function setUnreadNotice(text) { unreadNotice = text; }
228
+
229
+ export function buildUnreadNoticeText(data) {
230
+ if (!data || !Array.isArray(data.items)) return null;
231
+ const busy = data.items.filter((i) => i.count > 0);
232
+ if (!busy.length) return null;
233
+ return [
234
+ `🔔 Непрочитанные уведомления: ${busy.map((i) => `${i.workspace} — ${i.count}`).join(', ')}.`,
235
+ 'Скажи пользователю, где висит непрочитанное. Прочитать: switch_workspace на воркспейс и list_notifications.',
236
+ ].join(' ');
237
+ }
238
+
239
+ async function checkUnreadNotifications() {
240
+ try {
241
+ await ensureAuth();
242
+ let db = workspace;
243
+ if (!db) {
244
+ const list = await apiFetch('/api/v2/workspaces');
245
+ const first = (list.data || list)[0];
246
+ if (!first?.slug) return;
247
+ db = first.slug;
248
+ }
249
+ const data = await apiFetch(`/api/v2/${db}/notifications/across-workspaces`);
250
+ const payload = data.data || data;
251
+ const text = buildUnreadNoticeText(payload);
252
+ if (text) {
253
+ setUnreadNotice(text);
254
+ log(text);
255
+ }
256
+ } catch { /* нет сети, бэкенд недоступен — работе сервера не мешает */ }
213
257
  }
214
258
 
215
259
  // ─── Tool definitions cache ──────────────────────────────────────────────────
@@ -865,6 +909,7 @@ query_audit(type?, actor?, dateFrom?, dateTo?, action?, objectId?, typeId?, repo
865
909
  - get_notification_count() — number of unread notifications for current user
866
910
  - get_unread_across_workspaces() — unread counts across all user's workspaces
867
911
  - notification_action(notifId, actionKey) — execute action on a notification (e.g. approve/reject a suspended automation). Requires confirmation.
912
+ - On startup the server may append an unread-notifications summary to the first tool response — surface it to the user once, then drop it.
868
913
 
869
914
  ## Workspace admin
870
915
 
@@ -893,7 +938,7 @@ Client-facing portal management. Activate via search_tools("portal"); for @kit b
893
938
 
894
939
  **Configuration:**
895
940
  - get_portal_config() — current portal config (branding, pages, modules, auth, chat, SEO)
896
- - set_portal_config(config, active, custom_domain, merge?) — create/replace full config. With \`merge: true\` — deep-merge partial config into existing (no need to send entire config; only changed fields). Arrays are NOT merged — a partial \`pages[]\` replaces every page; for a one-module change use update_portal_module. **Requires confirmation.**
941
+ - set_portal_config(config, active, custom_domain, merge?) — create/replace full config. For \`custom_domain\`: omit it to keep the current value; \`null\` or empty string clears it. With \`merge: true\` — deep-merge partial config into existing (no need to send entire config; only changed fields). Arrays are NOT merged — a partial \`pages[]\` replaces every page; for a one-module change use update_portal_module. **Requires confirmation.**
897
942
  - update_portal_module(slug, config, moduleIndex) — update one module without overwriting others. Shallow merge into modules[moduleIndex ?? 0].config — keys you pass replace, keys you omit survive. If the MCP tool call cannot be issued, the equivalent REST is workspace-admin JWT → POST /api/v2/:db/portal/api/config (same upsertConfig + cache invalidation). Both writers validate references: custom_code repo/file and bindings table:N must exist in THIS workspace, otherwise the save is rejected (REPO_NOT_IN_WORKSPACE / FILE_NOT_IN_REPO / TABLE_NOT_IN_WORKSPACE; defects already present in the previous config do not block the edit). Every save snapshots the previous config to history: GET /api/v2/:db/portal/api/config/history lists snapshots, POST .../config/restore {historyId} rolls back (REST, admin JWT).
898
943
  - portal_preview() — get preview URL
899
944
  - portal_publish(active) — publish (true) or unpublish (false). **Requires confirmation.**
@@ -1949,7 +1994,7 @@ const EN_DESCRIPTIONS = {
1949
1994
  portal_preview: 'Get the portal preview URL.',
1950
1995
  portal_publish: 'Enable (active=true) or disable (active=false) the portal. Requires confirmation.',
1951
1996
  // Telegram management
1952
- list_telegram_bots: 'List workspace Telegram bots. Returns ID, name, username, enabled, webhook_secret, config.',
1997
+ list_telegram_bots: 'List workspace Telegram bots. Returns ID, name, username, enabled, config.',
1953
1998
  create_telegram_bot: 'Create a new Telegram bot. Registers the webhook automatically. name — display name, username — the @username of the bot in Telegram, token — the token from @BotFather. config.commands — array of commands: [{command:"/status", description:"Status", action:"reply", replyText:"Your order..."}]. Requires confirmation.',
1954
1999
  update_telegram_bot: 'Update a Telegram bot. If token changes, the webhook is re-registered. Requires confirmation.',
1955
2000
  delete_telegram_bot: 'Delete a Telegram bot. Irreversible. Requires HITL confirmation.',
@@ -3083,6 +3128,9 @@ async function main() {
3083
3128
  // 1. Login
3084
3129
  await login();
3085
3130
 
3131
+ // Сводка непрочитанных — fire-and-forget: старт не должен зависеть от бэкенда.
3132
+ checkUnreadNotifications();
3133
+
3086
3134
  // 2. Fetch tool definitions (if workspace is set)
3087
3135
  if (workspace) {
3088
3136
  const tools = await fetchTools();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "integram-mcp",
3
- "version": "0.7.71",
3
+ "version": "0.7.77",
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",