integram-mcp 0.7.169 → 0.7.172
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/index.js +74 -10
- 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.
|
|
18
|
+
-- npx -y integram-mcp@0.7.172
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
Ставить ничего не нужно: `npx` скачает пакет сам.
|
|
@@ -49,7 +49,7 @@ claude mcp add integram \
|
|
|
49
49
|
-e INTEGRAM_URL=http://localhost:8081 \
|
|
50
50
|
-e INTEGRAM_EMAIL=you@example.com \
|
|
51
51
|
-e INTEGRAM_PASSWORD=secret \
|
|
52
|
-
-- npx -y integram-mcp@0.7.
|
|
52
|
+
-- npx -y integram-mcp@0.7.172
|
|
53
53
|
```
|
|
54
54
|
|
|
55
55
|
Удалить: `claude mcp remove integram`
|
|
@@ -63,7 +63,7 @@ claude mcp add integram \
|
|
|
63
63
|
"mcpServers": {
|
|
64
64
|
"integram": {
|
|
65
65
|
"command": "npx",
|
|
66
|
-
"args": ["-y", "integram-mcp@0.7.
|
|
66
|
+
"args": ["-y", "integram-mcp@0.7.172"],
|
|
67
67
|
"env": {
|
|
68
68
|
"INTEGRAM_URL": "https://ai2o.online",
|
|
69
69
|
"INTEGRAM_EMAIL": "you@example.com",
|
|
@@ -83,7 +83,7 @@ claude mcp add integram \
|
|
|
83
83
|
"mcpServers": {
|
|
84
84
|
"integram": {
|
|
85
85
|
"command": "npx",
|
|
86
|
-
"args": ["-y", "integram-mcp@0.7.
|
|
86
|
+
"args": ["-y", "integram-mcp@0.7.172"],
|
|
87
87
|
"env": {
|
|
88
88
|
"INTEGRAM_URL": "https://ai2o.online",
|
|
89
89
|
"INTEGRAM_EMAIL": "you@example.com",
|
package/index.js
CHANGED
|
@@ -419,7 +419,8 @@ async function loadWorkspaceTools(slug) {
|
|
|
419
419
|
}
|
|
420
420
|
|
|
421
421
|
// Built-in MCP tools handled locally — never load from backend to avoid duplicates
|
|
422
|
-
|
|
422
|
+
// PM-948: экспорт — built-ins участвуют в каталоге did-you-mean подсказок.
|
|
423
|
+
export const BUILT_IN_NAMES = new Set([
|
|
423
424
|
'list_workspaces', 'switch_workspace', 'create_workspace',
|
|
424
425
|
'delete_workspace', 'clone_workspace', 'search_tools', 'confirm_action',
|
|
425
426
|
]);
|
|
@@ -1615,8 +1616,10 @@ async function dispatchTool(request) {
|
|
|
1615
1616
|
// Regular tool call → proxy to backend
|
|
1616
1617
|
if (!activeTools.has(name)) {
|
|
1617
1618
|
// PM-164: называем похожие инструменты, чтобы модель не подменяла имя.
|
|
1618
|
-
|
|
1619
|
-
|
|
1619
|
+
// PM-948: built-ins тоже в каталоге; для ветки unknown они считаются
|
|
1620
|
+
// активными (всегда перехватываются раньше и до сюда не доходят точными именами).
|
|
1621
|
+
const catalog = buildSuggestionCatalog(allTools);
|
|
1622
|
+
const text = buildNotActiveText(name, catalog, [...activeTools, ...BUILT_IN_NAMES]);
|
|
1620
1623
|
return { content: [{ type: 'text', text }], isError: true };
|
|
1621
1624
|
}
|
|
1622
1625
|
|
|
@@ -2235,12 +2238,44 @@ export function buildSearchToolsText(p) {
|
|
|
2235
2238
|
|
|
2236
2239
|
// ─── PM-164: similar-name guard ──────────────────────────────────────────────
|
|
2237
2240
|
|
|
2241
|
+
// PM-948: каталог для did-you-mean — built-ins прокси + backend-тулы.
|
|
2242
|
+
// Опечатка «create_workspce» должна подсказывать create_workspace, а не пустоту.
|
|
2243
|
+
export function buildSuggestionCatalog(allTools) {
|
|
2244
|
+
return [
|
|
2245
|
+
...[...BUILT_IN_NAMES].map((n) => ({ name: n, group: 'builtin', description: '' })),
|
|
2246
|
+
...(allTools || []).map((t) => ({ name: t.name, group: t.group, description: t.description })),
|
|
2247
|
+
];
|
|
2248
|
+
}
|
|
2249
|
+
|
|
2238
2250
|
/**
|
|
2239
|
-
*
|
|
2240
|
-
*
|
|
2251
|
+
* PM-948: нормированная похожесть Левенштейна, формула difflib
|
|
2252
|
+
* (m + n − dist) / (m + n). На подстановках чуть щедрее difflib
|
|
2253
|
+
* (замена стоит 1, а не 2) — порог 0.6 компенсирует консервативно.
|
|
2254
|
+
*/
|
|
2255
|
+
function editSimilarity(a, b) {
|
|
2256
|
+
const m = a.length;
|
|
2257
|
+
const n = b.length;
|
|
2258
|
+
if (!m || !n) return 0;
|
|
2259
|
+
let prev = Array.from({ length: n + 1 }, (_, j) => j);
|
|
2260
|
+
for (let i = 1; i <= m; i++) {
|
|
2261
|
+
const cur = [i];
|
|
2262
|
+
for (let j = 1; j <= n; j++) {
|
|
2263
|
+
cur[j] = Math.min(prev[j] + 1, cur[j - 1] + 1, prev[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1));
|
|
2264
|
+
}
|
|
2265
|
+
prev = cur;
|
|
2266
|
+
}
|
|
2267
|
+
return (m + n - prev[n]) / (m + n);
|
|
2268
|
+
}
|
|
2269
|
+
|
|
2270
|
+
const EDIT_SIMILARITY_THRESHOLD = 0.6;
|
|
2271
|
+
|
|
2272
|
+
/**
|
|
2273
|
+
* Детерминированный поиск похожих имён: общие токены (по '_'), подстрока
|
|
2274
|
+
* или edit-похожесть ≥ 0.6 (PM-948). Сам запрошенный тул не предлагается.
|
|
2275
|
+
* Сортировка: токен-совпадения (score ≥ 100) выше чисто edit-совпадений.
|
|
2241
2276
|
*/
|
|
2242
2277
|
export function findSimilarTools(name, catalog, limit = 3) {
|
|
2243
|
-
const tokens = (n) => n.split('_').filter(Boolean);
|
|
2278
|
+
const tokens = (n) => String(n ?? '').split('_').filter(Boolean);
|
|
2244
2279
|
const nameToks = new Set(tokens(name));
|
|
2245
2280
|
const scored = [];
|
|
2246
2281
|
for (const t of catalog) {
|
|
@@ -2250,8 +2285,10 @@ export function findSimilarTools(name, catalog, limit = 3) {
|
|
|
2250
2285
|
if (nameToks.has(tok)) shared += 1;
|
|
2251
2286
|
else if (t.name.includes(name) || name.includes(t.name)) shared += 1;
|
|
2252
2287
|
}
|
|
2253
|
-
|
|
2254
|
-
|
|
2288
|
+
const edit = editSimilarity(String(name ?? ''), String(t.name ?? ''));
|
|
2289
|
+
if (shared === 0 && edit < EDIT_SIMILARITY_THRESHOLD) continue;
|
|
2290
|
+
const score = shared > 0 ? shared * 100 + Math.round(edit * 10) : Math.round(edit * 10);
|
|
2291
|
+
scored.push({ tool: t, score });
|
|
2255
2292
|
}
|
|
2256
2293
|
scored.sort((a, b) => b.score - a.score || a.tool.name.localeCompare(b.tool.name));
|
|
2257
2294
|
return scored.slice(0, limit).map((s) => s.tool);
|
|
@@ -2264,10 +2301,37 @@ export function findSimilarTools(name, catalog, limit = 3) {
|
|
|
2264
2301
|
export function buildNotActiveText(name, catalog, activeNames) {
|
|
2265
2302
|
// PM-103: имени нет в каталоге — это не «не активен», а «такого тула нет».
|
|
2266
2303
|
// Общий текст «is not active» модель читает как «имя неверное, попробую соседнее».
|
|
2304
|
+
// PM-948: неизвестное имя не отменяет близости — добавляем did-you-mean,
|
|
2305
|
+
// чтобы эмиссия самоисправлялась вместо перебора соседних тулов.
|
|
2267
2306
|
const known = catalog.some((t) => t.name === name);
|
|
2268
2307
|
if (!known) {
|
|
2269
|
-
|
|
2270
|
-
`Do NOT call a different tool instead
|
|
2308
|
+
const base = `Error: Unknown tool "${name}" — no such tool in the integram catalog. ` +
|
|
2309
|
+
`Do NOT call a different tool instead.`;
|
|
2310
|
+
const similar = name ? findSimilarTools(String(name), catalog) : [];
|
|
2311
|
+
if (!similar.length) {
|
|
2312
|
+
return base + ` Check the name, or use search_tools to discover the right one.`;
|
|
2313
|
+
}
|
|
2314
|
+
const label = (t) => (t.group ? `"${t.name}" (group "${t.group}")` : `"${t.name}"`);
|
|
2315
|
+
const activeSet = new Set(activeNames);
|
|
2316
|
+
const lines = [base];
|
|
2317
|
+
const activeHits = similar.filter((t) => activeSet.has(t.name));
|
|
2318
|
+
const inactiveHits = similar.filter((t) => !activeSet.has(t.name));
|
|
2319
|
+
if (activeHits.length) {
|
|
2320
|
+
lines.push(
|
|
2321
|
+
`Did you mean: ${activeHits.map(label).join(', ')}? ` +
|
|
2322
|
+
`It IS ACTIVE — if that is what you meant, call it by its exact name. Do NOT guess other tools.`,
|
|
2323
|
+
);
|
|
2324
|
+
}
|
|
2325
|
+
if (inactiveHits.length) {
|
|
2326
|
+
const groups = [...new Set(inactiveHits.map((t) => t.group).filter(Boolean))];
|
|
2327
|
+
lines.push(
|
|
2328
|
+
`Did you mean: ${inactiveHits.map(label).join(', ')}? ` +
|
|
2329
|
+
`If one of these is what you meant, activate its group first: ` +
|
|
2330
|
+
groups.map((g) => `search_tools("${g}")`).join(' or ') +
|
|
2331
|
+
` — then call the tool by its exact name.`,
|
|
2332
|
+
);
|
|
2333
|
+
}
|
|
2334
|
+
return lines.join('\n');
|
|
2271
2335
|
}
|
|
2272
2336
|
const similar = findSimilarTools(name, catalog);
|
|
2273
2337
|
if (!similar.length) {
|
package/package.json
CHANGED