@cachly-dev/mcp-server 0.7.0 → 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/dist/index.js CHANGED
@@ -47,7 +47,7 @@ import { Redis } from 'ioredis';
47
47
  const API_URL = process.env.CACHLY_API_URL ?? 'https://api.cachly.dev';
48
48
  const JWT = process.env.CACHLY_JWT ?? '';
49
49
  const EMBED_MODEL = process.env.CACHLY_EMBED_MODEL ?? '';
50
- const CURRENT_VERSION = '0.7.0';
50
+ const CURRENT_VERSION = '0.7.1';
51
51
  /**
52
52
  * ┌──────────────────────────────────────────────────────────────────────┐
53
53
  * │ EMBEDDING PROVIDER — pluggable, client-side first │
@@ -3431,11 +3431,23 @@ const TOOLS = [
3431
3431
  type: 'object',
3432
3432
  properties: {
3433
3433
  q: { type: 'string', description: 'Free-text search query (leave empty for most recent lessons)' },
3434
+ category: { type: 'string', description: 'Filter by category prefix: "fix", "deploy", "debug", "infra", "api", "web"' },
3434
3435
  limit: { type: 'number', description: 'Max results to return (default: 20, max: 50)' },
3435
3436
  },
3436
3437
  required: [],
3437
3438
  },
3438
3439
  },
3440
+ {
3441
+ name: 'syndicate_stats',
3442
+ description: 'Show the health of the global Knowledge Commons: total lessons, total confirms, ' +
3443
+ 'top categories, most-trusted lessons, and growth in the last 7 days. ' +
3444
+ 'Use for weekly reviews or to explore what the community knows.',
3445
+ inputSchema: {
3446
+ type: 'object',
3447
+ properties: {},
3448
+ required: [],
3449
+ },
3450
+ },
3439
3451
  ];
3440
3452
  // ── Handlers ──────────────────────────────────────────────────────────────────
3441
3453
  function formatInstance(inst) {
@@ -7063,10 +7075,12 @@ smart_recall(
7063
7075
  }
7064
7076
  // ── v0.7 Knowledge Syndication: syndicate_search ─────────────────────────
7065
7077
  case 'syndicate_search': {
7066
- const { q = '', limit = 20 } = args;
7078
+ const { q = '', limit = 20, category = '' } = args;
7067
7079
  const params = new URLSearchParams();
7068
7080
  if (q)
7069
7081
  params.set('q', q);
7082
+ if (category)
7083
+ params.set('category', category);
7070
7084
  params.set('limit', String(Math.min(Math.max(1, limit), 50)));
7071
7085
  const res = await apiFetch(`/api/v1/syndication/search?${params}`);
7072
7086
  if (!res.results || res.results.length === 0) {
@@ -7080,17 +7094,46 @@ smart_recall(
7080
7094
  const filled = Math.min(10, Math.round(n / 5));
7081
7095
  return '█'.repeat(filled) + '░'.repeat(10 - filled) + ` ×${n}`;
7082
7096
  };
7097
+ const header = [q, category].filter(Boolean).join(' · ');
7083
7098
  const lines = [
7084
- `## 🌐 Global Knowledge Commons${q ? ` — "${q}"` : ' — Recent'}`,
7099
+ `## 🌐 Global Knowledge Commons${header ? ` — ${header}` : ' — Recent'}`,
7085
7100
  `*${res.count} lesson${res.count === 1 ? '' : 's'} found*`,
7086
7101
  ``,
7087
7102
  ];
7088
7103
  for (const lesson of res.results) {
7089
- lines.push(`### ${outcomeIcon(lesson.outcome)} \`${lesson.topic}\` ${severityLabel(lesson.severity)}`, `**Trust:** ${confirmBar(lesson.confirm_count)}`, lesson.what_worked ? `**What worked:** ${lesson.what_worked}` : '', lesson.what_failed ? `**What failed:** ${lesson.what_failed}` : '', `*Contributed ${new Date(lesson.created_at).toLocaleDateString('de-DE')}*`, ``);
7104
+ lines.push(`### ${outcomeIcon(lesson.outcome)} \`${lesson.topic}\` ${severityLabel(lesson.severity)}`, `**Trust:** ${confirmBar(lesson.confirm_count)}`, lesson.what_worked ? `**What worked:** ${lesson.what_worked}` : '', lesson.what_failed ? `**What failed:** ${lesson.what_failed}` : '', `*Contributed ${new Date(lesson.created_at).toLocaleDateString('de-DE')} · ID: \`${lesson.id}\`*`, ``);
7090
7105
  }
7091
- lines.push(`---`, `**Confirm a lesson** (it helped you): \`syndicate_search\` → note the ID → \`syndicate_confirm(id="...")\``, `**Contribute your own:** \`syndicate(topic="fix:...", what_worked="...")\``);
7106
+ lines.push(`---`, `**Confirm** (this helped you): \`syndicate(topic="${res.results[0]?.topic ?? '...'}", what_worked="...")\` → auto-deduped, trust +1`, `**Contribute your own:** \`syndicate(topic="fix:...", what_worked="...")\``, `**Filter by category:** \`syndicate_search(category="fix")\``);
7092
7107
  return lines.filter(l => l !== '').join('\n');
7093
7108
  }
7109
+ // ── v0.7 Knowledge Syndication: syndicate_stats ──────────────────────────
7110
+ case 'syndicate_stats': {
7111
+ const res = await apiFetch('/api/v1/syndication/stats');
7112
+ const confirmBar = (n) => {
7113
+ const filled = Math.min(10, Math.round(n / 5));
7114
+ return '█'.repeat(filled) + '░'.repeat(10 - filled) + ` ×${n}`;
7115
+ };
7116
+ const lines = [
7117
+ `## 🌐 Global Knowledge Commons — Stats`,
7118
+ ``,
7119
+ `| Metric | Value |`,
7120
+ `|---|---|`,
7121
+ `| Total lessons | **${res.total_lessons.toLocaleString()}** |`,
7122
+ `| Total confirms | **${res.total_confirms.toLocaleString()}** |`,
7123
+ `| Added last 7 days | **${res.added_last_7_days}** |`,
7124
+ ``,
7125
+ `### Top Categories`,
7126
+ ];
7127
+ for (const cat of res.top_categories ?? []) {
7128
+ lines.push(`- \`${cat.category}\` — ${cat.count} lesson${cat.count === 1 ? '' : 's'}`);
7129
+ }
7130
+ lines.push(``, `### Most Trusted Lessons`);
7131
+ for (const lesson of res.most_trusted ?? []) {
7132
+ lines.push(`**\`${lesson.topic}\`** ${confirmBar(lesson.confirm_count)}`, `> ${lesson.what_worked.slice(0, 120)}${lesson.what_worked.length > 120 ? '…' : ''}`, ``);
7133
+ }
7134
+ lines.push(`---`, `**Contribute:** \`syndicate(topic="...", what_worked="...")\` | **Search:** \`syndicate_search(q="your problem")\``);
7135
+ return lines.join('\n');
7136
+ }
7094
7137
  default:
7095
7138
  return null;
7096
7139
  }