@cachly-dev/mcp-server 0.9.3 → 0.9.4

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,37 @@ 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.9.3';
50
+ const CURRENT_VERSION = '0.9.4';
51
+ // ── Default Instance Resolution (for Smithery & single-credential setups) ────
52
+ // When CACHLY_BRAIN_INSTANCE_ID is set, tools can omit the instance_id parameter.
53
+ // When neither is set, we auto-fetch the first running instance once per process.
54
+ let _defaultInstanceId = process.env.CACHLY_BRAIN_INSTANCE_ID ?? '';
55
+ let _defaultInstanceFetched = false;
56
+ async function resolveDefaultInstanceId() {
57
+ if (_defaultInstanceId)
58
+ return _defaultInstanceId;
59
+ if (_defaultInstanceFetched)
60
+ return '';
61
+ _defaultInstanceFetched = true;
62
+ if (!JWT)
63
+ return '';
64
+ try {
65
+ const res = await fetch(`${API_URL}/api/v1/instances`, {
66
+ headers: { Authorization: `Bearer ${JWT}`, Accept: 'application/json' },
67
+ signal: AbortSignal.timeout(5000),
68
+ });
69
+ if (!res.ok)
70
+ return '';
71
+ const data = await res.json();
72
+ const running = (data?.data ?? []).filter(i => i.status === 'running');
73
+ if (running.length > 0) {
74
+ _defaultInstanceId = running[0].id;
75
+ return _defaultInstanceId;
76
+ }
77
+ }
78
+ catch { /* non-fatal — caller will surface missing instance_id error */ }
79
+ return '';
80
+ }
51
81
  /**
52
82
  * ┌──────────────────────────────────────────────────────────────────────┐
53
83
  * │ EMBEDDING PROVIDER — pluggable, client-side first │
@@ -3755,6 +3785,12 @@ async function handleTool(name, args) {
3755
3785
  '✨ Free tier includes: 1 Brain instance, persistent memory, semantic search.',
3756
3786
  ].join('\n');
3757
3787
  }
3788
+ // Auto-resolve instance_id from env / API when not provided in args
3789
+ if (!args.instance_id) {
3790
+ const defaultId = await resolveDefaultInstanceId();
3791
+ if (defaultId)
3792
+ args = { ...args, instance_id: defaultId };
3793
+ }
3758
3794
  // Delegate v0.2 bulk/lock/stream tools first
3759
3795
  const bulkResult = await handleBulkLockStream(name, args);
3760
3796
  if (bulkResult !== null)