@cachly-dev/mcp-server 0.10.5 → 0.10.7

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/src/utils.ts ADDED
@@ -0,0 +1,10 @@
1
+ // Safely parses a JSON string. Returns `fallback` on null, empty, or malformed
2
+ // input instead of throwing a SyntaxError that would fail the entire tool call.
3
+ export function safeJsonParse<T>(raw: string | null | undefined, fallback: T): T {
4
+ if (!raw) return fallback;
5
+ try {
6
+ return JSON.parse(raw) as T;
7
+ } catch {
8
+ return fallback;
9
+ }
10
+ }