@cachly-dev/mcp-server 0.6.1 → 0.7.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cachly-dev/mcp-server",
3
- "version": "0.6.1",
3
+ "version": "0.7.1",
4
4
  "mcpName": "io.github.cachly-dev/mcp-server",
5
5
  "description": "AI memory brain for Claude Code, Cursor, Copilot & Windsurf — persistent sessions, lessons learned, semantic search, team brain. 51 MCP tools.",
6
6
  "type": "module",
package/src/index.ts CHANGED
@@ -55,7 +55,7 @@ import { Redis } from 'ioredis';
55
55
  const API_URL = process.env.CACHLY_API_URL ?? 'https://api.cachly.dev';
56
56
  const JWT = process.env.CACHLY_JWT ?? '';
57
57
  const EMBED_MODEL = process.env.CACHLY_EMBED_MODEL ?? '';
58
- const CURRENT_VERSION = '0.6.1';
58
+ const CURRENT_VERSION = '0.7.1';
59
59
  /**
60
60
  * ┌──────────────────────────────────────────────────────────────────────┐
61
61
  * │ EMBEDDING PROVIDER — pluggable, client-side first │
@@ -3484,6 +3484,60 @@ const TOOLS = [
3484
3484
  required: ['instance_id'],
3485
3485
  },
3486
3486
  },
3487
+ // ── v0.7 Knowledge Syndication ────────────────────────────────────────────
3488
+ {
3489
+ name: 'syndicate',
3490
+ description:
3491
+ 'Contribute a verified lesson to the GLOBAL Cachly Knowledge Commons — ' +
3492
+ 'a privacy-preserving shared brain where every AI instance can learn from the discoveries ' +
3493
+ 'of every other. Your contributor identity is a one-way HMAC hash: completely anonymous. ' +
3494
+ 'The lesson is immediately searchable by any other AI using syndicate_search. ' +
3495
+ 'This is how individual knowledge becomes collective intelligence. ' +
3496
+ 'Call this AFTER every learn_from_attempts that is worth sharing universally ' +
3497
+ '(critical bugs, deployment gotchas, architecture discoveries).',
3498
+ inputSchema: {
3499
+ type: 'object',
3500
+ properties: {
3501
+ topic: { type: 'string', description: 'Topic key in category:keyword format (e.g. "fix:clickhouse-ipv6", "deploy:docker-compose")' },
3502
+ outcome: { type: 'string', enum: ['success', 'failure', 'partial'], description: 'Result of the attempt (default: success)' },
3503
+ what_worked: { type: 'string', description: 'Exact approach, command, or fix that worked. File paths are stripped automatically.' },
3504
+ what_failed: { type: 'string', description: 'What failed or was wrong — helps others avoid the same trap.' },
3505
+ severity: { type: 'string', enum: ['critical', 'major', 'minor'], description: 'How severe the issue was (default: minor)' },
3506
+ tags: { type: 'array', items: { type: 'string' }, description: 'Up to 10 keywords for better discoverability' },
3507
+ },
3508
+ required: ['topic', 'what_worked'],
3509
+ },
3510
+ },
3511
+ {
3512
+ name: 'syndicate_search',
3513
+ description:
3514
+ 'Search the GLOBAL Cachly Knowledge Commons for solutions contributed by the entire community. ' +
3515
+ 'Returns lessons ranked by confirm_count (trust score) then recency. ' +
3516
+ 'Use this BEFORE debugging any unknown issue — someone in the global brain likely solved it already. ' +
3517
+ 'Example: syndicate_search(q="clickhouse localhost connection refused") → ' +
3518
+ '"fix: use 127.0.0.1 not localhost when IPv6 is disabled · confirmed by 47 instances"',
3519
+ inputSchema: {
3520
+ type: 'object',
3521
+ properties: {
3522
+ q: { type: 'string', description: 'Free-text search query (leave empty for most recent lessons)' },
3523
+ category: { type: 'string', description: 'Filter by category prefix: "fix", "deploy", "debug", "infra", "api", "web"' },
3524
+ limit: { type: 'number', description: 'Max results to return (default: 20, max: 50)' },
3525
+ },
3526
+ required: [],
3527
+ },
3528
+ },
3529
+ {
3530
+ name: 'syndicate_stats',
3531
+ description:
3532
+ 'Show the health of the global Knowledge Commons: total lessons, total confirms, ' +
3533
+ 'top categories, most-trusted lessons, and growth in the last 7 days. ' +
3534
+ 'Use for weekly reviews or to explore what the community knows.',
3535
+ inputSchema: {
3536
+ type: 'object',
3537
+ properties: {},
3538
+ required: [],
3539
+ },
3540
+ },
3487
3541
  ] as const;
3488
3542
 
3489
3543
  // ── Handlers ──────────────────────────────────────────────────────────────────
@@ -7551,6 +7605,143 @@ smart_recall(
7551
7605
  ].join('\n');
7552
7606
  }
7553
7607
 
7608
+ // ── v0.7 Knowledge Syndication: syndicate ────────────────────────────────
7609
+ case 'syndicate': {
7610
+ const { topic, outcome = 'success', what_worked, what_failed = '', severity = 'minor', tags = [] } = args as {
7611
+ topic: string; outcome?: string; what_worked: string; what_failed?: string; severity?: string; tags?: string[];
7612
+ };
7613
+
7614
+ if (!topic || !what_worked) {
7615
+ throw new McpError(ErrorCode.InvalidParams, 'topic and what_worked are required');
7616
+ }
7617
+
7618
+ const body = { topic, outcome, what_worked, what_failed, severity, tags };
7619
+ const res = await apiFetch<{ id: string; topic: string; outcome: string; message: string }>(
7620
+ '/api/v1/syndication/contribute',
7621
+ { method: 'POST', body: JSON.stringify(body) }
7622
+ );
7623
+
7624
+ return [
7625
+ `🌐 **Lesson syndicated to the global Knowledge Commons**`,
7626
+ ``,
7627
+ `**ID:** \`${res.id}\``,
7628
+ `**Topic:** \`${res.topic}\` · **Outcome:** ${res.outcome}`,
7629
+ ``,
7630
+ `Your lesson is now searchable by every AI brain in the network.`,
7631
+ `When another instance confirms it works, its trust score rises automatically.`,
7632
+ ``,
7633
+ `**Tip:** Use \`syndicate_search(q="${topic}")\` to see all community lessons on this topic.`,
7634
+ ].join('\n');
7635
+ }
7636
+
7637
+ // ── v0.7 Knowledge Syndication: syndicate_search ─────────────────────────
7638
+ case 'syndicate_search': {
7639
+ const { q = '', limit = 20, category = '' } = args as { q?: string; limit?: number; category?: string };
7640
+
7641
+ const params = new URLSearchParams();
7642
+ if (q) params.set('q', q);
7643
+ if (category) params.set('category', category);
7644
+ params.set('limit', String(Math.min(Math.max(1, limit), 50)));
7645
+
7646
+ const res = await apiFetch<{ results: Array<{
7647
+ id: string; topic: string; category: string; outcome: string;
7648
+ what_worked: string; what_failed: string; severity: string;
7649
+ confirm_count: number; created_at: string;
7650
+ }>; count: number; query: string }>(`/api/v1/syndication/search?${params}`);
7651
+
7652
+ if (!res.results || res.results.length === 0) {
7653
+ return q
7654
+ ? `No lessons found for "${q}" in the global Knowledge Commons yet.\n\nBe the first to contribute: \`syndicate(topic="...", what_worked="...")\``
7655
+ : `The global Knowledge Commons is empty. Be the first contributor:\n\`syndicate(topic="deploy:api", what_worked="...")\``;
7656
+ }
7657
+
7658
+ const outcomeIcon = (o: string) => o === 'success' ? '✅' : o === 'failure' ? '❌' : '⚠️';
7659
+ const severityLabel = (s: string) => s === 'critical' ? '🔴' : s === 'major' ? '🟡' : '🟢';
7660
+ const confirmBar = (n: number) => {
7661
+ const filled = Math.min(10, Math.round(n / 5));
7662
+ return '█'.repeat(filled) + '░'.repeat(10 - filled) + ` ×${n}`;
7663
+ };
7664
+
7665
+ const header = [q, category].filter(Boolean).join(' · ');
7666
+ const lines: string[] = [
7667
+ `## 🌐 Global Knowledge Commons${header ? ` — ${header}` : ' — Recent'}`,
7668
+ `*${res.count} lesson${res.count === 1 ? '' : 's'} found*`,
7669
+ ``,
7670
+ ];
7671
+
7672
+ for (const lesson of res.results) {
7673
+ lines.push(
7674
+ `### ${outcomeIcon(lesson.outcome)} \`${lesson.topic}\` ${severityLabel(lesson.severity)}`,
7675
+ `**Trust:** ${confirmBar(lesson.confirm_count)}`,
7676
+ lesson.what_worked ? `**What worked:** ${lesson.what_worked}` : '',
7677
+ lesson.what_failed ? `**What failed:** ${lesson.what_failed}` : '',
7678
+ `*Contributed ${new Date(lesson.created_at).toLocaleDateString('de-DE')} · ID: \`${lesson.id}\`*`,
7679
+ ``,
7680
+ );
7681
+ }
7682
+
7683
+ lines.push(
7684
+ `---`,
7685
+ `**Confirm** (this helped you): \`syndicate(topic="${res.results[0]?.topic ?? '...'}", what_worked="...")\` → auto-deduped, trust +1`,
7686
+ `**Contribute your own:** \`syndicate(topic="fix:...", what_worked="...")\``,
7687
+ `**Filter by category:** \`syndicate_search(category="fix")\``,
7688
+ );
7689
+
7690
+ return lines.filter(l => l !== '').join('\n');
7691
+ }
7692
+
7693
+ // ── v0.7 Knowledge Syndication: syndicate_stats ──────────────────────────
7694
+ case 'syndicate_stats': {
7695
+ const res = await apiFetch<{
7696
+ total_lessons: number;
7697
+ total_confirms: number;
7698
+ added_last_7_days: number;
7699
+ top_categories: Array<{ category: string; count: number }>;
7700
+ most_trusted: Array<{
7701
+ id: string; topic: string; outcome: string;
7702
+ what_worked: string; confirm_count: number; created_at: string;
7703
+ }>;
7704
+ }>('/api/v1/syndication/stats');
7705
+
7706
+ const confirmBar = (n: number) => {
7707
+ const filled = Math.min(10, Math.round(n / 5));
7708
+ return '█'.repeat(filled) + '░'.repeat(10 - filled) + ` ×${n}`;
7709
+ };
7710
+
7711
+ const lines: string[] = [
7712
+ `## 🌐 Global Knowledge Commons — Stats`,
7713
+ ``,
7714
+ `| Metric | Value |`,
7715
+ `|---|---|`,
7716
+ `| Total lessons | **${res.total_lessons.toLocaleString()}** |`,
7717
+ `| Total confirms | **${res.total_confirms.toLocaleString()}** |`,
7718
+ `| Added last 7 days | **${res.added_last_7_days}** |`,
7719
+ ``,
7720
+ `### Top Categories`,
7721
+ ];
7722
+
7723
+ for (const cat of res.top_categories ?? []) {
7724
+ lines.push(`- \`${cat.category}\` — ${cat.count} lesson${cat.count === 1 ? '' : 's'}`);
7725
+ }
7726
+
7727
+ lines.push(``, `### Most Trusted Lessons`);
7728
+
7729
+ for (const lesson of res.most_trusted ?? []) {
7730
+ lines.push(
7731
+ `**\`${lesson.topic}\`** ${confirmBar(lesson.confirm_count)}`,
7732
+ `> ${lesson.what_worked.slice(0, 120)}${lesson.what_worked.length > 120 ? '…' : ''}`,
7733
+ ``,
7734
+ );
7735
+ }
7736
+
7737
+ lines.push(
7738
+ `---`,
7739
+ `**Contribute:** \`syndicate(topic="...", what_worked="...")\` | **Search:** \`syndicate_search(q="your problem")\``,
7740
+ );
7741
+
7742
+ return lines.join('\n');
7743
+ }
7744
+
7554
7745
  default:
7555
7746
  return null;
7556
7747
  }