unifi-mcp-worker 1.2.0 → 1.2.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": "unifi-mcp-worker",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "CLI to deploy and manage the UniFi MCP Cloudflare Worker relay",
5
5
  "type": "module",
6
6
  "bin": {
@@ -865,6 +865,13 @@ export class RelayObject extends DurableObject<Env> implements RelayStub {
865
865
  access: "unifi_access_list_events",
866
866
  };
867
867
 
868
+ // Convert time range to within_hours for Network events (which use a lookback window)
869
+ const startDate = new Date(startTime);
870
+ const endDate = new Date(endTime);
871
+ const withinHours = Math.max(1, Math.ceil((endDate.getTime() - startDate.getTime()) / (1000 * 60 * 60)));
872
+ // Hours from now to the start of the window (for Network's "within" param)
873
+ const hoursAgo = Math.max(1, Math.ceil((Date.now() - startDate.getTime()) / (1000 * 60 * 60)));
874
+
868
875
  const targetProducts = products || Object.keys(eventToolMap);
869
876
  const allEvents: Array<Record<string, unknown>> = [];
870
877
 
@@ -881,8 +888,14 @@ export class RelayObject extends DurableObject<Env> implements RelayStub {
881
888
  const targetLocations = locationId ? locations.filter((l) => l === locationId) : locations;
882
889
  if (targetLocations.length === 0) continue;
883
890
 
891
+ // Build product-specific arguments
892
+ // Network uses within_hours lookback; Protect/Access may use start_time/end_time
893
+ const toolArgs: Record<string, unknown> = product === "network"
894
+ ? { within_hours: hoursAgo, limit: 3000 }
895
+ : { start_time: startTime, end_time: endTime };
896
+
884
897
  try {
885
- const result = await this.routeToolCall(toolName, { start_time: startTime, end_time: endTime });
898
+ const result = await this.routeToolCall(toolName, toolArgs);
886
899
 
887
900
  // Extract events from the result (handles both single and fan-out responses)
888
901
  const events = this.extractEvents(result, product);