integram-mcp 0.7.8 → 0.7.13
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/LICENSE +21 -0
- package/README.md +32 -25
- package/index.js +259 -42
- package/package.json +1 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Integram
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/integram-mcp)
|
|
4
4
|
|
|
5
|
-
MCP-сервер для Integram — даёт доступ к
|
|
5
|
+
MCP-сервер для Integram — даёт доступ к 609 инструментам (таблицы, документы, отчёты, автоматизации, портал, Telegram-боты, граф знаний и т.д.) из Claude Code, Claude Desktop и Cursor.
|
|
6
6
|
|
|
7
7
|
Работает с облачным Integram на **ai2o.online** или с локальным сервером.
|
|
8
8
|
|
|
@@ -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.13
|
|
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.13
|
|
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.13"],
|
|
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.13"],
|
|
81
81
|
"env": {
|
|
82
82
|
"INTEGRAM_URL": "https://ai2o.online",
|
|
83
83
|
"INTEGRAM_EMAIL": "you@example.com",
|
|
@@ -157,30 +157,37 @@ claude mcp add integram -e INTEGRAM_URL=... -e INTEGRAM_EMAIL=... -e INTEGRAM_PA
|
|
|
157
157
|
|
|
158
158
|
## Группы инструментов
|
|
159
159
|
|
|
160
|
+
<!-- BEGIN:tool-groups — генерируется backend/scripts/sync-tool-counts.mjs, руками не править -->
|
|
160
161
|
| Группа | Что делает | Кол-во |
|
|
161
162
|
|---|---|---|
|
|
162
|
-
| **
|
|
163
|
-
| **
|
|
164
|
-
| **
|
|
165
|
-
| **
|
|
166
|
-
| **
|
|
167
|
-
| **
|
|
168
|
-
| **
|
|
169
|
-
| **
|
|
170
|
-
| **
|
|
171
|
-
| **
|
|
172
|
-
| **
|
|
173
|
-
| **
|
|
163
|
+
| **workspace** | Файлы, коннекторы, участники, бэкапы, дашборды, вью, аудит, нормализатор, автоматизации, вебхуки, формы | 121 |
|
|
164
|
+
| **pm** | Управление проектами: задачи, спринты, доски, бэклог, диаграммы | 53 |
|
|
165
|
+
| **docs** | Документы, блоки, версии, шаринг, папки, теги, шаблоны, PDF | 50 |
|
|
166
|
+
| **portal** | Портал: конфиг, каталог, корзины, заказы, тикеты, KB, метрики, Telegram-боты | 46 |
|
|
167
|
+
| **nightcall** | Нормативная спецификация и проверяемая генерация: требования, обязательства, свидетельства, базовые линии | 42 |
|
|
168
|
+
| **teamchat** | Сообщения, решения, метрики агентов, W-матрица, топики | 42 |
|
|
169
|
+
| **codespace** | Git-репозитории: ветки, коммиты, файлы, точечная правка (`patch_file`), pull requests; запись с `baseCommit` сливается с чужими изменениями вместо перезаписи | 30 |
|
|
170
|
+
| **schema** | Таблицы, колонки, кнопки (AI/HTTP/script), вычисляемые колонки, валидация | 30 |
|
|
171
|
+
| **memory** | Память агента, инсайты, процедуры, противоречия | 22 |
|
|
172
|
+
| **meta-kb** | Дебаты: параллельные эксперты, LLM-синтез, курирование знаний | 22 |
|
|
173
|
+
| **objects** | Перемещение, дублирование, переупорядочивание записей, корзина, обратные ссылки | 17 |
|
|
174
|
+
| **core** | CRUD объектов, поиск, граф, комментарии, bulk-операции | 16 |
|
|
175
|
+
| **reports** | Отчёты: CRUD, колонки, JOIN, фильтры, экспорт | 16 |
|
|
176
|
+
| **grants** | Роли, гранты, row-level правила (только admin) | 13 |
|
|
177
|
+
| **graph** | Граф данных: запросы, окрестности, кратчайший путь | 13 |
|
|
178
|
+
| **orgs** | Организации: участники, области, приглашения | 13 |
|
|
179
|
+
| **kag** | Граф знаний: поиск, обход, вопрос-ответ, ввоз сущностей и связей | 12 |
|
|
180
|
+
| **agents** | Реестр внешних AI-агентов, делегирование | 11 |
|
|
181
|
+
| **advisor** | Советы эксперта, возможности платформы | 6 |
|
|
174
182
|
| **comments** | Комментарии и реакции к записям | 6 |
|
|
175
|
-
| **
|
|
183
|
+
| **automations** | Детали автоматизации, лог доставки вебхуков | 5 |
|
|
184
|
+
| **workspace-tools** | Инструменты уровня области: регистрация, правка, ввоз наборов | 5 |
|
|
176
185
|
| **bulk** | Массовые операции: создание, обновление, удаление, AI-batch | 4 |
|
|
177
|
-
| **
|
|
186
|
+
| **ai** | Синтез речи (TTS): озвучка текста, список голосов | 3 |
|
|
187
|
+
| **normalizer** | Разбор документов: запуск, состояние, подтверждение сопоставления | 3 |
|
|
178
188
|
| **timeseries** | Временные ряды: запись, запрос, список источников | 3 |
|
|
179
|
-
| **automations** | Детали автоматизации, лог доставки вебхуков | 3 |
|
|
180
|
-
| **advisor** | Советы эксперта, возможности платформы | 2 |
|
|
181
|
-
| **ai** | Синтез речи (TTS): озвучка текста, список голосов | 2 |
|
|
182
|
-
| **agents** | Реестр внешних AI-агентов, делегирование | 2 |
|
|
183
|
-
| **lookups** | Справочники: варианты для dropdown/ref | 2 |
|
|
184
189
|
| **history** | История изменений объектов, откат | 2 |
|
|
190
|
+
| **lookups** | Справочники: варианты для dropdown/ref | 2 |
|
|
191
|
+
<!-- END:tool-groups -->
|
|
185
192
|
|
|
186
|
-
Core активна сразу (
|
|
193
|
+
Core активна сразу (16 tools). Остальные — через `search_tools`.
|
package/index.js
CHANGED
|
@@ -234,7 +234,7 @@ async function fetchTools() {
|
|
|
234
234
|
|
|
235
235
|
// ─── MCP Server (low-level — we pass raw JSON Schema, not Zod) ──────────────
|
|
236
236
|
|
|
237
|
-
const INSTRUCTIONS = `Integram — workspace-based platform: tables, documents, reports, automations, permissions, forms, webhooks, files, knowledge graph.
|
|
237
|
+
export const INSTRUCTIONS = `Integram — workspace-based platform: tables, documents, reports, automations, permissions, forms, webhooks, files, knowledge graph.
|
|
238
238
|
Server: ${BASE_URL}
|
|
239
239
|
|
|
240
240
|
## Getting started
|
|
@@ -683,7 +683,7 @@ Block-based documents (like Notion). Activate via search_tools("documents").
|
|
|
683
683
|
- Versions: list_doc_versions, get_doc_version(docId, versionId), restore_doc_version
|
|
684
684
|
- Block history: get_block_history(docId, blockId, limit?, offset?)
|
|
685
685
|
- Purge: purge_document(docId) — permanently delete trashed doc (requires confirmation)
|
|
686
|
-
- Sharing: list_doc_sharing, grant_doc_access(docId,
|
|
686
|
+
- Sharing: list_doc_sharing, grant_doc_access(docId, targetUserId, role: viewer|editor|admin), revoke_doc_access
|
|
687
687
|
|
|
688
688
|
## Automations
|
|
689
689
|
|
|
@@ -744,7 +744,7 @@ create_form(typeId, config, expiresAt) — generates a public URL for external u
|
|
|
744
744
|
## Bulk operations
|
|
745
745
|
|
|
746
746
|
Activate via search_tools("bulk").
|
|
747
|
-
- bulk_create(typeId,
|
|
747
|
+
- bulk_create(typeId, rows, parentId?) — create many records at once
|
|
748
748
|
- bulk_update(updates: [{ objId, fields }]) — update many records
|
|
749
749
|
- bulk_delete(objIds) — delete many records (requires confirmation)
|
|
750
750
|
- autofill_batch(typeId, reqId, objectIds) — run AI autofill on multiple rows
|
|
@@ -759,7 +759,7 @@ Activate via search_tools("workspace").
|
|
|
759
759
|
## Dashboards
|
|
760
760
|
|
|
761
761
|
Visual dashboards with widgets. Activate via search_tools("workspace").
|
|
762
|
-
- list_dashboards, get_dashboard(id), create_dashboard(
|
|
762
|
+
- list_dashboards, get_dashboard(id), create_dashboard(title, widgets, layouts?), update_dashboard, delete_dashboard
|
|
763
763
|
|
|
764
764
|
## Workspace invitations
|
|
765
765
|
|
|
@@ -789,7 +789,7 @@ External data integrations. Activate via search_tools("workspace").
|
|
|
789
789
|
## Comments & reactions
|
|
790
790
|
|
|
791
791
|
Activate via search_tools("comments").
|
|
792
|
-
- list_comments(objId), create_comment(objId,
|
|
792
|
+
- list_comments(objId), create_comment(objId, body, parentCommentId?), update_comment, delete_comment
|
|
793
793
|
- add_reaction(commentId, emoji), remove_reaction
|
|
794
794
|
|
|
795
795
|
## History & rollback
|
|
@@ -1696,6 +1696,71 @@ async function handleDeleteWorkspace(slug) {
|
|
|
1696
1696
|
|
|
1697
1697
|
// ─── clone_workspace handler ──────────────────────────────────────────────────
|
|
1698
1698
|
|
|
1699
|
+
/**
|
|
1700
|
+
* Чего в клоне нет ПО УСТРОЙСТВУ — одной строкой и без потерь.
|
|
1701
|
+
*
|
|
1702
|
+
* Перечень отдаёт реестр платформы (registry/workspace-carry.js) записями вида
|
|
1703
|
+
* {table, kind, home, why} — 54 штуки. Печатать их подряд нельзя: в простыне из
|
|
1704
|
+
* 54 имён тонет ровно то, ради чего перечень и нужен. Печатать усечённо — тоже
|
|
1705
|
+
* нельзя: «Not carried by design: …» читается как ПОЛНЫЙ перечень, и раньше он
|
|
1706
|
+
* им не был (13 имён из 54).
|
|
1707
|
+
*
|
|
1708
|
+
* Отсюда деление по роду. Числом — журналы и выводимое: у клона своя жизнь с
|
|
1709
|
+
* чистого листа, а выводимое он отстроит сам; знать, что их 46 и 3, достаточно.
|
|
1710
|
+
* ВСЁ ОСТАЛЬНОЕ — поимённо: это не след прошедшего, а отсутствие того, чем
|
|
1711
|
+
* область пользовалась, и узнать об этом хозяин клона обязан из ответа, а не из
|
|
1712
|
+
* пустого раздела через неделю.
|
|
1713
|
+
*
|
|
1714
|
+
* ПОЧЕМУ ЗАШИТ ТОЛЬКО СВОРАЧИВАЕМЫЙ ПЕРЕЧЕНЬ. Реестр рода объявляет на сервере
|
|
1715
|
+
* (registry/workspace-carry.js, KINDS), а пакет выложен в npm и живёт дольше
|
|
1716
|
+
* сервера, к которому подключён: спросить у реестра ему нечем, новый род приедет
|
|
1717
|
+
* в ответе раньше обновления. Перечень называемых поимённо здесь стоял тоже — и
|
|
1718
|
+
* незнакомый род молча выпадал из печати, оставаясь в числе заголовка: замер
|
|
1719
|
+
* 20.08.2026, запись {kind:'право'} давала «(55)» и ни одного упоминания имени.
|
|
1720
|
+
* Это ровно тот изъян, против которого печать и писалась. Теперь называется
|
|
1721
|
+
* ВСЁ, кроме двух названных родов: отстанет этот перечень — незнакомое станет
|
|
1722
|
+
* многословным, а не пропадёт. Направление ошибки выбрано, а не оставлено.
|
|
1723
|
+
*/
|
|
1724
|
+
function notCarriedLine(list) {
|
|
1725
|
+
// Сервер прежней выкладки отдаёт имена строками: рода у них нет, и такая
|
|
1726
|
+
// запись называется поимённо — свернуть неизвестное числом значит потерять его.
|
|
1727
|
+
const items = list.map(x => (typeof x === 'string' ? { table: x, kind: null } : x));
|
|
1728
|
+
|
|
1729
|
+
// Единственное зашитое знание о родах: что вправе свернуться числом.
|
|
1730
|
+
const FOLD = { 'журнал': 'logs', 'выводимое': 'derived tables' };
|
|
1731
|
+
// Подписи родов, называемых поимённо. Незнакомый род печатается своим именем —
|
|
1732
|
+
// отсутствие подписи не повод не назвать записи.
|
|
1733
|
+
const LABEL = { 'секрет': 'secrets', 'содержимое': 'content', 'настройка': 'settings' };
|
|
1734
|
+
const ORDER = ['secrets', 'content', 'settings'];
|
|
1735
|
+
|
|
1736
|
+
const named = new Map(); // подпись рода → имена таблиц
|
|
1737
|
+
const folded = new Map(); // подпись рода → счёт
|
|
1738
|
+
for (const item of items) {
|
|
1739
|
+
const kind = item.kind || null;
|
|
1740
|
+
if (kind && FOLD[kind]) {
|
|
1741
|
+
folded.set(FOLD[kind], (folded.get(FOLD[kind]) || 0) + 1);
|
|
1742
|
+
continue;
|
|
1743
|
+
}
|
|
1744
|
+
// Пустой ключ — записи без рода (сервер прежней выкладки): подписывать нечем.
|
|
1745
|
+
const label = kind ? (LABEL[kind] || kind) : '';
|
|
1746
|
+
if (!named.has(label)) named.set(label, []);
|
|
1747
|
+
named.get(label).push(item.table);
|
|
1748
|
+
}
|
|
1749
|
+
|
|
1750
|
+
// Порядок: известные рода как прежде, следом незнакомые, последними —
|
|
1751
|
+
// безродные. Внутри рода — порядок реестра.
|
|
1752
|
+
const rank = (label) => (label === '' ? 2 : ORDER.indexOf(label) === -1 ? 1 : 0);
|
|
1753
|
+
const parts = [...named.entries()]
|
|
1754
|
+
.sort((a, b) => rank(a[0]) - rank(b[0])
|
|
1755
|
+
|| (rank(a[0]) === 0 ? ORDER.indexOf(a[0]) - ORDER.indexOf(b[0]) : a[0].localeCompare(b[0])))
|
|
1756
|
+
.map(([label, names]) => (label ? `${label} — ${names.join(', ')}` : names.join(', ')));
|
|
1757
|
+
|
|
1758
|
+
const tail = [...folded.entries()].map(([label, n]) => `${n} ${label}`);
|
|
1759
|
+
if (tail.length) parts.push(`plus ${tail.join(' and ')} (source history and data the clone rebuilds itself)`);
|
|
1760
|
+
|
|
1761
|
+
return `Not carried by design (${items.length}): ${parts.join('; ')}.`;
|
|
1762
|
+
}
|
|
1763
|
+
|
|
1699
1764
|
async function handleCloneWorkspace({ sourceSlug, name, slug, includeDocuments, includeMembers }) {
|
|
1700
1765
|
if (!sourceSlug || !name || !slug) {
|
|
1701
1766
|
return { content: [{ type: 'text', text: 'Error: sourceSlug, name, and slug are required' }], isError: true };
|
|
@@ -1703,8 +1768,11 @@ async function handleCloneWorkspace({ sourceSlug, name, slug, includeDocuments,
|
|
|
1703
1768
|
try {
|
|
1704
1769
|
await ensureAuth();
|
|
1705
1770
|
const body = { name, slug };
|
|
1706
|
-
|
|
1707
|
-
|
|
1771
|
+
// Имена полей — те, что объявляет маршрут (include_documents / include_members).
|
|
1772
|
+
// Zod срезает неизвестные поля молча: в camelCase клон уезжал без документов
|
|
1773
|
+
// и без участников, а вызов при этом выглядел успешным.
|
|
1774
|
+
if (includeDocuments !== undefined) body.include_documents = includeDocuments;
|
|
1775
|
+
if (includeMembers !== undefined) body.include_members = includeMembers;
|
|
1708
1776
|
const data = await apiFetch(`/api/v2/workspaces/${sourceSlug}/clone`, {
|
|
1709
1777
|
method: 'POST',
|
|
1710
1778
|
body: JSON.stringify(body),
|
|
@@ -1723,8 +1791,20 @@ async function handleCloneWorkspace({ sourceSlug, name, slug, includeDocuments,
|
|
|
1723
1791
|
}
|
|
1724
1792
|
await server.sendToolListChanged();
|
|
1725
1793
|
|
|
1794
|
+
// Чего в клоне НЕТ — обязано быть сказано словами. Отсутствующее опаснее
|
|
1795
|
+
// пустого: пустой раздел зритель видит, отсутствующий — нет.
|
|
1796
|
+
const gaps = [];
|
|
1797
|
+
if (ws.notCarried?.length) gaps.push(notCarriedLine(ws.notCarried));
|
|
1798
|
+
if (ws.carryFailed?.length) {
|
|
1799
|
+
gaps.push(`Failed to carry: ${ws.carryFailed.map(f => `${f.table} (${f.reason})`).join('; ')}.`);
|
|
1800
|
+
}
|
|
1801
|
+
if (ws.carryPartial?.length) {
|
|
1802
|
+
gaps.push(`Carried partially: ${ws.carryPartial
|
|
1803
|
+
.map(p => `${p.table} (columns missing in target: ${[...p.missing, ...p.unsafe].join(', ')})`).join('; ')}.`);
|
|
1804
|
+
}
|
|
1805
|
+
|
|
1726
1806
|
return {
|
|
1727
|
-
content: [{ type: 'text', text: `Workspace "${sourceSlug}" cloned into "${ws.name}" (slug: ${ws.slug}). Automatically switched to it. ${activeTools.size} core tools loaded
|
|
1807
|
+
content: [{ type: 'text', text: `Workspace "${sourceSlug}" cloned into "${ws.name}" (slug: ${ws.slug}). Automatically switched to it. ${activeTools.size} core tools loaded.${gaps.length ? ' ' + gaps.join(' ') : ''}` }],
|
|
1728
1808
|
};
|
|
1729
1809
|
} catch (err) {
|
|
1730
1810
|
return { content: [{ type: 'text', text: `Error cloning workspace: ${err.message}` }], isError: true };
|
|
@@ -1747,13 +1827,28 @@ const BUILT_IN_TOOL_DEFS = [
|
|
|
1747
1827
|
// Group alias map — maps Russian/English SYNONYMS to TOOL_DEFS group names.
|
|
1748
1828
|
// Exact group names are matched dynamically against the live catalog (allTools),
|
|
1749
1829
|
// so a new backend group is picked up automatically — add here only synonyms.
|
|
1830
|
+
//
|
|
1831
|
+
// A value may be an ARRAY when one word honestly names two groups. That is not a
|
|
1832
|
+
// convenience: `automations` is the name of a 5-tool group (run details, webhook
|
|
1833
|
+
// delivery log) AND the everyday word for editing automations, which lives in
|
|
1834
|
+
// `workspace`. Sending the word to one group only silently hid the other half —
|
|
1835
|
+
// the prompt said `search_tools("automations")` and then named `create_automation`,
|
|
1836
|
+
// which the query could never activate. Same shape for connectors and forms.
|
|
1750
1837
|
const GROUP_ALIASES = {
|
|
1751
1838
|
документ: 'docs', документы: 'docs', docs: 'docs', doc: 'docs',
|
|
1752
1839
|
отчёт: 'reports', отчеты: 'reports', отчёты: 'reports', report: 'reports', reports: 'reports',
|
|
1753
1840
|
схема: 'schema', таблица: 'schema', колонк: 'schema', schema: 'schema',
|
|
1754
1841
|
права: 'grants', роли: 'grants', доступ: 'grants', grants: 'grants',
|
|
1755
|
-
|
|
1756
|
-
|
|
1842
|
+
permissions: 'grants', permission: 'grants', acl: 'grants', role: 'grants', member: 'grants',
|
|
1843
|
+
автоматизац: ['workspace', 'automations'], коннектор: 'workspace', форм: 'workspace',
|
|
1844
|
+
// Вебхук заведён в `workspace`, а журнал его доставки (`get_webhook_deliveries`,
|
|
1845
|
+
// `retry_webhook_delivery`) — в `automations`. Раздел подсказки называет и то и другое.
|
|
1846
|
+
вебхук: ['workspace', 'automations'],
|
|
1847
|
+
webhook: ['workspace', 'automations'], webhooks: ['workspace', 'automations'],
|
|
1848
|
+
form: 'workspace', forms: 'workspace',
|
|
1849
|
+
connector: 'workspace', connectors: 'workspace', dashboard: 'workspace', dashboards: 'workspace',
|
|
1850
|
+
invitation: 'workspace', invitations: 'workspace', backup: 'workspace', audit: 'workspace',
|
|
1851
|
+
файл: 'workspace', файлы: 'workspace', file: 'workspace', files: 'workspace',
|
|
1757
1852
|
портал: 'portal', телеграм: 'portal', telegram: 'portal', portal: 'portal',
|
|
1758
1853
|
граф: 'graph', связи: 'graph', graph: 'graph',
|
|
1759
1854
|
память: 'memory', memory: 'memory', запомни: 'memory',
|
|
@@ -1767,8 +1862,9 @@ const GROUP_ALIASES = {
|
|
|
1767
1862
|
advisor: 'advisor', совет: 'advisor', консультант: 'advisor',
|
|
1768
1863
|
agents: 'agents', агент: 'agents', делегир: 'agents',
|
|
1769
1864
|
orgs: 'orgs', организаци: 'orgs', org: 'orgs',
|
|
1770
|
-
automations: 'automations', automation: 'automations',
|
|
1771
|
-
|
|
1865
|
+
automations: ['automations', 'workspace'], automation: ['automations', 'workspace'],
|
|
1866
|
+
// Раздел «History & rollback» называет и `get_object_backlinks`, а оно в `objects`.
|
|
1867
|
+
history: ['history', 'objects'], истори: ['history', 'objects'],
|
|
1772
1868
|
lookups: 'lookups', lookup: 'lookups', справочник: 'lookups',
|
|
1773
1869
|
'meta-kb': 'meta-kb', metakb: 'meta-kb', дебат: 'meta-kb', дискусси: 'meta-kb',
|
|
1774
1870
|
pm: 'pm', проект: 'pm', задач: 'pm', спринт: 'pm', канбан: 'pm', бэклог: 'pm', issue: 'pm', sprint: 'pm', backlog: 'pm', board: 'pm',
|
|
@@ -1776,15 +1872,24 @@ const GROUP_ALIASES = {
|
|
|
1776
1872
|
формализ: 'nightcall', formaliz: 'nightcall', governance: 'nightcall', evidence: 'nightcall',
|
|
1777
1873
|
};
|
|
1778
1874
|
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1875
|
+
/**
|
|
1876
|
+
* Pure selection step of search_tools — exported so the guard test can run the REAL
|
|
1877
|
+
* matcher over the REAL catalog instead of a copy of it. A copied matcher is how the
|
|
1878
|
+
* prompt drifted away from what activation actually returns in the first place.
|
|
1879
|
+
*
|
|
1880
|
+
* @param {string} query
|
|
1881
|
+
* @param {Array<{name:string,description?:string,group?:string}>} catalog
|
|
1882
|
+
* @param {(t:object)=>boolean} available
|
|
1883
|
+
* @returns {{matched:Array<object>, groupExact:number, total:number, droppedByGroup:Object<string,number>}}
|
|
1884
|
+
*/
|
|
1885
|
+
export function selectTools(query, catalog, available = () => true) {
|
|
1886
|
+
const q = String(query).toLowerCase();
|
|
1887
|
+
const words = q.split(/\s+/).filter(Boolean);
|
|
1888
|
+
// Live group catalog — single source of truth, new backend groups appear automatically
|
|
1889
|
+
const knownGroups = [...new Set(catalog.map(t => t.group).filter(g => g && g !== 'core'))];
|
|
1890
|
+
const toolText = t => `${t.name} ${t.description || ''} ${t.group || ''}`.toLowerCase();
|
|
1891
|
+
const allTools = catalog;
|
|
1892
|
+
{
|
|
1788
1893
|
|
|
1789
1894
|
// Phase 1: group-based match — if any query word names a group (exact, or prefix
|
|
1790
1895
|
// when at least 4 chars to avoid short-name false hits) or hits a synonym alias,
|
|
@@ -1796,13 +1901,22 @@ async function handleSearchTools(query) {
|
|
|
1796
1901
|
if (w === g || (minLen >= 4 && (g.startsWith(w) || w.startsWith(g)))) matchedGroups.add(g);
|
|
1797
1902
|
}
|
|
1798
1903
|
for (const [alias, group] of Object.entries(GROUP_ALIASES)) {
|
|
1799
|
-
if (alias.startsWith(w) || w.startsWith(alias))
|
|
1904
|
+
if (alias.startsWith(w) || w.startsWith(alias)) {
|
|
1905
|
+
for (const g of Array.isArray(group) ? group : [group]) matchedGroups.add(g);
|
|
1906
|
+
}
|
|
1800
1907
|
}
|
|
1801
1908
|
}
|
|
1802
1909
|
|
|
1803
1910
|
let matched;
|
|
1911
|
+
// Tools that came in because the query NAMED their group. These are exempt from
|
|
1912
|
+
// the result cap below: asking for a group and getting an unannounced 30-tool
|
|
1913
|
+
// prefix of it makes activation-by-name meaningless — `workspace` is 121 tools,
|
|
1914
|
+
// and the prompt names tools that sit past position 30 in every one of them.
|
|
1915
|
+
// A vague query is still capped; an explicit group request is honoured in full.
|
|
1916
|
+
let groupExact = 0;
|
|
1804
1917
|
if (matchedGroups.size > 0) {
|
|
1805
1918
|
matched = allTools.filter(t => available(t) && matchedGroups.has(t.group));
|
|
1919
|
+
groupExact = matched.length;
|
|
1806
1920
|
// Also include tools from other groups where ALL words match
|
|
1807
1921
|
const groupSet = new Set(matched.map(t => t.name));
|
|
1808
1922
|
const extra = allTools.filter(t =>
|
|
@@ -1842,8 +1956,85 @@ async function handleSearchTools(query) {
|
|
|
1842
1956
|
}
|
|
1843
1957
|
}
|
|
1844
1958
|
|
|
1845
|
-
// Cap at 30
|
|
1846
|
-
|
|
1959
|
+
// Cap at 30 — but SAY SO. Six groups are larger than the cap (`workspace` is
|
|
1960
|
+
// 121 tools), so activating one by name used to answer "Activated 30 tools: …"
|
|
1961
|
+
// and drop the rest without a word. The model read that as the whole group and
|
|
1962
|
+
// called a tool it had never been given. A cap is right — dumping 121 defs into
|
|
1963
|
+
// the tool list is worse — but a silent one turns absence into a lie.
|
|
1964
|
+
const RESULT_CAP = 30;
|
|
1965
|
+
const keep = Math.max(RESULT_CAP, groupExact);
|
|
1966
|
+
const totalMatched = matched.length;
|
|
1967
|
+
const droppedByGroup = {};
|
|
1968
|
+
if (totalMatched > keep) {
|
|
1969
|
+
for (const t of matched.slice(keep)) {
|
|
1970
|
+
const g = t.group || '(no group)';
|
|
1971
|
+
droppedByGroup[g] = (droppedByGroup[g] || 0) + 1;
|
|
1972
|
+
}
|
|
1973
|
+
}
|
|
1974
|
+
matched = matched.slice(0, keep);
|
|
1975
|
+
|
|
1976
|
+
return { matched, groupExact, total: totalMatched, droppedByGroup, knownGroups, words, RESULT_CAP };
|
|
1977
|
+
}
|
|
1978
|
+
}
|
|
1979
|
+
|
|
1980
|
+
/**
|
|
1981
|
+
* Текст ответа `search_tools` — отдельно от побочных действий, чтобы его можно было
|
|
1982
|
+
* проверить, не поднимая сервер.
|
|
1983
|
+
*
|
|
1984
|
+
* Пустой ответ бывает ДВУХ родов, и раньше они звучали одинаково: «ничего не совпало» и
|
|
1985
|
+
* «всё совпавшее уже активно». Второе — не отказ, а сообщение об успехе, сказанное
|
|
1986
|
+
* словами отказа: модель читала «not found», переставала верить имени группы и начинала
|
|
1987
|
+
* подбирать синонимы, имея все её инструменты на руках. Замер 23.08.2026: третий подряд
|
|
1988
|
+
* `search_tools("pm")` отвечал `No tools found matching "pm"` и в той же строке
|
|
1989
|
+
* перечислял `pm` среди доступных групп.
|
|
1990
|
+
*
|
|
1991
|
+
* @param {object} p
|
|
1992
|
+
* @param {string} p.query исходный запрос
|
|
1993
|
+
* @param {string[]} p.activatedNames что активировано этим вызовом
|
|
1994
|
+
* @param {number} p.totalMatched сколько совпало ДО потолка (с учётом предиката)
|
|
1995
|
+
* @param {Object<string,number>} p.droppedByGroup срезано потолком, по группам
|
|
1996
|
+
* @param {number} p.resultCap сам потолок
|
|
1997
|
+
* @param {string[]} p.builtinNames совпавшие встроенные — они и так доступны
|
|
1998
|
+
* @param {string[]} p.alreadyActiveNames совпавшие, но активированные РАНЬШЕ
|
|
1999
|
+
* @param {string[]} p.knownGroups живой перечень групп каталога
|
|
2000
|
+
* @returns {string}
|
|
2001
|
+
*/
|
|
2002
|
+
export function buildSearchToolsText(p) {
|
|
2003
|
+
const parts = [];
|
|
2004
|
+
if (p.activatedNames.length) {
|
|
2005
|
+
parts.push(`Activated ${p.activatedNames.length} tools: ${p.activatedNames.join(', ')}.`);
|
|
2006
|
+
}
|
|
2007
|
+
if (p.totalMatched > p.activatedNames.length) {
|
|
2008
|
+
const rest = Object.entries(p.droppedByGroup)
|
|
2009
|
+
.sort((a, b) => b[1] - a[1])
|
|
2010
|
+
.map(([g, n]) => `${g} +${n}`)
|
|
2011
|
+
.join(', ');
|
|
2012
|
+
parts.push(
|
|
2013
|
+
`NOT activated: ${p.totalMatched - p.activatedNames.length} more matched but were cut at the ${p.resultCap}-tool limit (${rest}). ` +
|
|
2014
|
+
`They are NOT available — narrow the query to reach them, e.g. search_tools("${p.query} <what you need>").`
|
|
2015
|
+
);
|
|
2016
|
+
}
|
|
2017
|
+
if (p.builtinNames.length) {
|
|
2018
|
+
parts.push(`Already available (built-in): ${p.builtinNames.join(', ')}.`);
|
|
2019
|
+
}
|
|
2020
|
+
if (parts.length) return parts.join(' ');
|
|
2021
|
+
|
|
2022
|
+
// Ничего не активировано. Разбираем, почему именно.
|
|
2023
|
+
if (p.alreadyActiveNames.length) {
|
|
2024
|
+
return `Nothing new: all ${p.alreadyActiveNames.length} tools matching "${p.query}" are already active ` +
|
|
2025
|
+
`(${p.alreadyActiveNames.join(', ')}). Use them directly — no further search_tools call is needed.`;
|
|
2026
|
+
}
|
|
2027
|
+
const groupsMsg = p.knownGroups.length
|
|
2028
|
+
? p.knownGroups.slice().sort().join(', ')
|
|
2029
|
+
: '(no tools loaded — select a workspace first)';
|
|
2030
|
+
return `No tools found matching "${p.query}". Available groups: ${groupsMsg}`;
|
|
2031
|
+
}
|
|
2032
|
+
|
|
2033
|
+
async function handleSearchTools(query) {
|
|
2034
|
+
try {
|
|
2035
|
+
const available = t => !activeTools.has(t.name) && !BUILT_IN_NAMES.has(t.name);
|
|
2036
|
+
const { matched, total: totalMatched, droppedByGroup, knownGroups, words, RESULT_CAP } =
|
|
2037
|
+
selectTools(query, allTools, available);
|
|
1847
2038
|
|
|
1848
2039
|
// Search built-in tools (always available, just inform)
|
|
1849
2040
|
const matchedBuiltins = BUILT_IN_TOOL_DEFS.filter(t => {
|
|
@@ -1860,20 +2051,29 @@ async function handleSearchTools(query) {
|
|
|
1860
2051
|
await server.sendToolListChanged();
|
|
1861
2052
|
}
|
|
1862
2053
|
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
2054
|
+
// Совпавшие, но активированные РАНЬШЕ. Второй прогон отбора без предиката
|
|
2055
|
+
// доступности — единственный способ это узнать: предикат уходит внутрь отбора и
|
|
2056
|
+
// делает «нет совпадений» неотличимым от «всё уже активно». Прогон чистый и идёт
|
|
2057
|
+
// по памяти, так что второй раз он стоит дёшево, и делается только когда
|
|
2058
|
+
// активировать оказалось нечего.
|
|
2059
|
+
const alreadyActiveNames = matched.length
|
|
2060
|
+
? []
|
|
2061
|
+
: selectTools(query, allTools)
|
|
2062
|
+
.matched
|
|
2063
|
+
.filter(t => activeTools.has(t.name))
|
|
2064
|
+
.map(t => t.name);
|
|
2065
|
+
|
|
2066
|
+
const text = buildSearchToolsText({
|
|
2067
|
+
query,
|
|
2068
|
+
activatedNames: matched.map(t => t.name),
|
|
2069
|
+
totalMatched,
|
|
2070
|
+
droppedByGroup,
|
|
2071
|
+
resultCap: RESULT_CAP,
|
|
2072
|
+
builtinNames: matchedBuiltins.map(t => t.name),
|
|
2073
|
+
alreadyActiveNames,
|
|
2074
|
+
knownGroups,
|
|
2075
|
+
});
|
|
2076
|
+
return { content: [{ type: 'text', text }] };
|
|
1877
2077
|
} catch (err) {
|
|
1878
2078
|
return { content: [{ type: 'text', text: `Error: ${err.message}` }], isError: true };
|
|
1879
2079
|
}
|
|
@@ -1937,6 +2137,7 @@ async function handleSwitchWorkspace(input) {
|
|
|
1937
2137
|
// ─── Auto-update from git ────────────────────────────────────────────────────
|
|
1938
2138
|
|
|
1939
2139
|
import { execSync } from 'child_process';
|
|
2140
|
+
import { realpathSync } from 'fs';
|
|
1940
2141
|
import { dirname } from 'path';
|
|
1941
2142
|
import { fileURLToPath } from 'url';
|
|
1942
2143
|
|
|
@@ -1991,7 +2192,23 @@ async function main() {
|
|
|
1991
2192
|
log('MCP server running on stdio');
|
|
1992
2193
|
}
|
|
1993
2194
|
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
2195
|
+
// Run only when executed as a program, not when imported. The guard test imports
|
|
2196
|
+
// `selectTools` from this file; without this check the import would log in, open a
|
|
2197
|
+
// stdio transport and hang the run. realpathSync is required, not decoration: npm
|
|
2198
|
+
// installs the bin as a SYMLINK, so process.argv[1] is the link path while
|
|
2199
|
+
// import.meta.url is the real one, and a naive comparison would make `npx
|
|
2200
|
+
// integram-mcp` start nothing at all.
|
|
2201
|
+
const isProgram = (() => {
|
|
2202
|
+
try {
|
|
2203
|
+
return process.argv[1] && realpathSync(process.argv[1]) === fileURLToPath(import.meta.url);
|
|
2204
|
+
} catch {
|
|
2205
|
+
return false;
|
|
2206
|
+
}
|
|
2207
|
+
})();
|
|
2208
|
+
|
|
2209
|
+
if (isProgram) {
|
|
2210
|
+
main().catch(err => {
|
|
2211
|
+
process.stderr.write(`[integram-mcp] Fatal: ${err.message}\n`);
|
|
2212
|
+
process.exit(1);
|
|
2213
|
+
});
|
|
2214
|
+
}
|
package/package.json
CHANGED