schemeog-mcp 3.0.1 → 3.1.1

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 +28 -3
  2. package/index.js +117 -19
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # SchemeOG MCP Server v2.9
1
+ # SchemeOG MCP Server v3.1
2
2
 
3
3
  MCP server for [Diagrams.love](https://diagrams.love) — create diagrams and flowcharts with AI.
4
4
 
@@ -8,6 +8,8 @@ MCP server for [Diagrams.love](https://diagrams.love) — create diagrams and fl
8
8
  - **Auto-refresh**: Browser automatically reloads when MCP updates schema
9
9
  - **Smart positioning**: Existing elements keep their positions, new elements get auto-layout
10
10
  - **No coordinate conflicts**: MCP ignores x/y to prevent overlapping cards
11
+ - **Shared links support**: Open schemas via public `/shared/` URLs (read-only)
12
+ - **Large schema handling**: Automatic detection and preview for schemas >100 elements
11
13
 
12
14
  ## 17 Commands
13
15
 
@@ -248,15 +250,38 @@ When you edit a schema via MCP while viewing it in the browser:
248
250
  You can open any schema by URL using `get_schema_by_url`:
249
251
 
250
252
  ```
251
- # Canvas URL (основной формат)
253
+ # Canvas URL (main format) — full access
252
254
  https://diagrams.love/canvas?schema=abc123
253
255
 
254
- # Shared link
256
+ # Shared link — read-only access
255
257
  https://diagrams.love/shared/xyz789
256
258
  ```
257
259
 
258
260
  Just paste the URL and the MCP will extract the schema ID automatically.
259
261
 
262
+ ### Shared Links (Read-Only)
263
+
264
+ When you open a schema via `/shared/` URL:
265
+ - ✅ You can **view** the schema content
266
+ - ✅ You can **analyze** the structure
267
+ - ✅ You can **count** elements and connections
268
+ - ❌ You **cannot edit** — need access to original schema
269
+
270
+ This is useful for:
271
+ - Analyzing schemas shared by others
272
+ - Answering questions about schema structure
273
+ - Getting inspiration for your own diagrams
274
+
275
+ ## Large Schema Handling
276
+
277
+ For schemas with >100 elements or >50KB data:
278
+
279
+ - `get_schema` shows first 5 elements as preview
280
+ - `get_schema_by_url` shows statistics only
281
+ - Full data available via `export_schema_to_json`
282
+
283
+ This prevents context overflow in Claude Code when working with large diagrams.
284
+
260
285
  ## Schema Methodology
261
286
 
262
287
  Schema = complete tree of **ACTIONS** and **CONSEQUENCES**:
package/index.js CHANGED
@@ -560,8 +560,11 @@ const TOOLS = [
560
560
  - https://diagrams.love/canvas?schema=ID (основной формат)
561
561
  - diagrams.love/canvas?schema=ID
562
562
  - https://diagrams.love/canvas?id=ID (устаревший)
563
+ - https://diagrams.love/shared/TOKEN (публичная ссылка)
564
+ - https://scheme.smartlaunchhub.com/... (старый домен)
563
565
 
564
566
  Автоматически извлекает ID схемы из URL и проверяет доступ.
567
+ Для публичных ссылок (/shared/) использует специальный API эндпоинт.
565
568
  Если у пользователя есть доступ к схеме — возвращает полные данные.
566
569
  Если доступа нет — возвращает ошибку.
567
570
 
@@ -1150,6 +1153,10 @@ Claude урезает большие параметры, но file_path чита
1150
1153
  * - https://diagrams.love/canvas?schema=ID (основной)
1151
1154
  * - diagrams.love/canvas?schema=ID
1152
1155
  * - https://diagrams.love/canvas?id=ID (устаревший)
1156
+ * - https://diagrams.love/shared/TOKEN (публичная ссылка)
1157
+ * - https://scheme.smartlaunchhub.com/... (старый домен)
1158
+ *
1159
+ * Возвращает: { id, type } где type = "schema" | "shared"
1153
1160
  */
1154
1161
  function extractSchemaIdFromUrl(url) {
1155
1162
  if (!url || typeof url !== "string") return null;
@@ -1165,18 +1172,39 @@ function extractSchemaIdFromUrl(url) {
1165
1172
 
1166
1173
  // Проверяем что это наш домен
1167
1174
  if (!urlObj.hostname.includes("diagrams.love") &&
1175
+ !urlObj.hostname.includes("smartlaunchhub.com") &&
1168
1176
  !urlObj.hostname.includes("localhost")) {
1169
1177
  return null;
1170
1178
  }
1171
1179
 
1180
+ // Формат /shared/TOKEN — публичная ссылка
1181
+ const sharedMatch = urlObj.pathname.match(/^\/shared\/([a-zA-Z0-9_-]+)/);
1182
+ if (sharedMatch) {
1183
+ return { id: sharedMatch[1], type: "shared" };
1184
+ }
1185
+
1172
1186
  // Извлекаем ID из query параметров
1173
1187
  const schemaId = urlObj.searchParams.get("schema") || urlObj.searchParams.get("id");
1174
1188
 
1175
- return schemaId || null;
1189
+ if (schemaId) {
1190
+ return { id: schemaId, type: "schema" };
1191
+ }
1192
+
1193
+ return null;
1176
1194
  } catch (e) {
1177
- // Пробуем простой regex для извлечения
1178
- const match = url.match(/[?&](schema|id)=([a-zA-Z0-9_-]+)/);
1179
- return match ? match[2] : null;
1195
+ // Пробуем regex для /shared/ формата
1196
+ const sharedMatch = url.match(/\/shared\/([a-zA-Z0-9_-]+)/);
1197
+ if (sharedMatch) {
1198
+ return { id: sharedMatch[1], type: "shared" };
1199
+ }
1200
+
1201
+ // Пробуем простой regex для query параметров
1202
+ const queryMatch = url.match(/[?&](schema|id)=([a-zA-Z0-9_-]+)/);
1203
+ if (queryMatch) {
1204
+ return { id: queryMatch[2], type: "schema" };
1205
+ }
1206
+
1207
+ return null;
1180
1208
  }
1181
1209
  }
1182
1210
 
@@ -1302,6 +1330,38 @@ async function handleTool(name, args) {
1302
1330
 
1303
1331
  const schema = result.schema;
1304
1332
 
1333
+ // Проверяем размер данных для предупреждения о больших схемах
1334
+ const elementsCount = schema.data?.elements?.length || 0;
1335
+ const connectionsCount = schema.data?.connections?.length || 0;
1336
+ const dataSize = JSON.stringify(schema.data || {}).length;
1337
+ const isLargeSchema = dataSize > 50000 || elementsCount > 100;
1338
+
1339
+ // Формируем вывод в зависимости от размера
1340
+ let elementsText, connectionsText, sizeWarning;
1341
+
1342
+ if (isLargeSchema) {
1343
+ // Большая схема — выводим только краткую статистику и первые элементы
1344
+ const previewElements = (schema.data?.elements || []).slice(0, 5);
1345
+ elementsText = `⚠️ БОЛЬШАЯ СХЕМА: ${elementsCount} элементов, ~${Math.round(dataSize / 1024)}KB
1346
+
1347
+ Первые 5 элементов (для предпросмотра):
1348
+ ${JSON.stringify(previewElements, null, 2)}
1349
+
1350
+ Для получения полных данных используй:
1351
+ • export_schema_to_json с format="compact" — выгрузит JSON
1352
+ • export_schema_to_json с format="elements_only" — только элементы`;
1353
+
1354
+ connectionsText = `[${connectionsCount} связей — используй export_schema_to_json для полного списка]`;
1355
+
1356
+ sizeWarning = `\n\n⚠️ ВНИМАНИЕ: Схема содержит ${elementsCount} элементов (~${Math.round(dataSize / 1024)}KB).
1357
+ Полный вывод может переполнить контекст!
1358
+ Для работы с большими схемами рекомендуется использовать export_schema_to_json.`;
1359
+ } else {
1360
+ elementsText = JSON.stringify(schema.data?.elements || [], null, 2);
1361
+ connectionsText = JSON.stringify(schema.data?.connections || [], null, 2);
1362
+ sizeWarning = "";
1363
+ }
1364
+
1305
1365
  return {
1306
1366
  content: [{
1307
1367
  type: "text",
@@ -1310,15 +1370,16 @@ async function handleTool(name, args) {
1310
1370
  ID: ${schema.id}
1311
1371
  Описание: ${schema.description || "(нет)"}
1312
1372
  Проект: ${schema.project?.name || "Общие"}
1313
- Элементов: ${schema.data?.elements?.length || 0}
1314
- Связей: ${schema.data?.connections?.length || 0}
1315
- URL: ${API_BASE_URL}/canvas?schema=${schema.id}
1373
+ Элементов: ${elementsCount}
1374
+ Связей: ${connectionsCount}
1375
+ Размер данных: ~${Math.round(dataSize / 1024)}KB
1376
+ URL: ${API_BASE_URL}/canvas?schema=${schema.id}${sizeWarning}
1316
1377
 
1317
1378
  Элементы:
1318
- ${JSON.stringify(schema.data?.elements || [], null, 2)}
1379
+ ${elementsText}
1319
1380
 
1320
1381
  Связи:
1321
- ${JSON.stringify(schema.data?.connections || [], null, 2)}`,
1382
+ ${connectionsText}`,
1322
1383
  }],
1323
1384
  };
1324
1385
  }
@@ -1327,20 +1388,56 @@ ${JSON.stringify(schema.data?.connections || [], null, 2)}`,
1327
1388
  const { url } = args;
1328
1389
 
1329
1390
  // Извлекаем ID из URL
1330
- const schemaId = extractSchemaIdFromUrl(url);
1391
+ const urlInfo = extractSchemaIdFromUrl(url);
1331
1392
 
1332
- if (!schemaId) {
1393
+ if (!urlInfo) {
1333
1394
  const error = createError(
1334
1395
  ErrorCodes.VALIDATION_ERROR,
1335
- `Не удалось извлечь ID схемы из URL: "${url}"\n\nПоддерживаемые форматы:\n• https://diagrams.love/canvas?schema=ID\n• https://diagrams.love/canvas?id=ID`
1396
+ `Не удалось извлечь ID схемы из URL: "${url}"\n\nПоддерживаемые форматы:\n• https://diagrams.love/canvas?schema=ID\n• https://diagrams.love/canvas?id=ID\n• https://diagrams.love/shared/TOKEN`
1336
1397
  );
1337
1398
  throw new Error(error.message);
1338
1399
  }
1339
1400
 
1340
- // Получаем схему по ID (проверка доступа происходит на сервере)
1341
- const result = await apiRequest(`/schemas/${schemaId}`);
1401
+ let result;
1402
+ let isSharedLink = false;
1403
+
1404
+ if (urlInfo.type === "shared") {
1405
+ // Публичная ссылка — используем специальный API эндпоинт
1406
+ result = await apiRequest(`/schemas/shared/${urlInfo.id}`);
1407
+ isSharedLink = true;
1408
+ } else {
1409
+ // Обычная ссылка — получаем схему по ID
1410
+ result = await apiRequest(`/schemas/${urlInfo.id}`);
1411
+ }
1412
+
1342
1413
  const schema = result.schema;
1343
1414
 
1415
+ // Проверяем размер данных для предупреждения о больших схемах
1416
+ const elementsCount = schema.data?.elements?.length || 0;
1417
+ const connectionsCount = schema.data?.connections?.length || 0;
1418
+ const dataSize = JSON.stringify(schema.data || {}).length;
1419
+ const isLargeSchema = dataSize > 50000 || elementsCount > 100;
1420
+
1421
+ // Формируем вывод в зависимости от размера
1422
+ let elementsText, connectionsText;
1423
+
1424
+ if (isLargeSchema) {
1425
+ // Большая схема — выводим только краткую статистику
1426
+ elementsText = `[Схема слишком большая для полного вывода: ${elementsCount} элементов, ~${Math.round(dataSize / 1024)}KB]
1427
+
1428
+ Для работы с большой схемой используй:
1429
+ • export_schema_to_json с format="compact" для получения данных в файл
1430
+ • Редактируй отдельные элементы через replace_schema`;
1431
+ connectionsText = `[${connectionsCount} связей]`;
1432
+ } else {
1433
+ elementsText = JSON.stringify(schema.data?.elements || [], null, 2);
1434
+ connectionsText = JSON.stringify(schema.data?.connections || [], null, 2);
1435
+ }
1436
+
1437
+ const accessNote = isSharedLink
1438
+ ? "\n⚠️ Это публичная ссылка. Для редактирования нужен доступ к оригинальной схеме."
1439
+ : "";
1440
+
1344
1441
  return {
1345
1442
  content: [{
1346
1443
  type: "text",
@@ -1351,15 +1448,16 @@ ${JSON.stringify(schema.data?.connections || [], null, 2)}`,
1351
1448
  ID: ${schema.id}
1352
1449
  Описание: ${schema.description || "(нет)"}
1353
1450
  Проект: ${schema.project?.name || "Общие"}
1354
- Элементов: ${schema.data?.elements?.length || 0}
1355
- Связей: ${schema.data?.connections?.length || 0}
1356
- URL: ${API_BASE_URL}/canvas?schema=${schema.id}
1451
+ Элементов: ${elementsCount}
1452
+ Связей: ${connectionsCount}
1453
+ Размер данных: ~${Math.round(dataSize / 1024)}KB
1454
+ URL: ${API_BASE_URL}/canvas?schema=${schema.id}${accessNote}
1357
1455
 
1358
1456
  Элементы:
1359
- ${JSON.stringify(schema.data?.elements || [], null, 2)}
1457
+ ${elementsText}
1360
1458
 
1361
1459
  Связи:
1362
- ${JSON.stringify(schema.data?.connections || [], null, 2)}
1460
+ ${connectionsText}
1363
1461
 
1364
1462
  Теперь ты можешь:
1365
1463
  • Редактировать схему с помощью replace_schema (schema_id: "${schema.id}")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "schemeog-mcp",
3
- "version": "3.0.1",
3
+ "version": "3.1.1",
4
4
  "description": "MCP Server for Diagrams.love - Create and manage visual diagrams and flowcharts with AI assistance",
5
5
  "type": "module",
6
6
  "main": "index.js",