# Sliding Window Aggregator AI Agent Connect

> Deterministic engine for sliding window metric aggregation, trend analysis, and anomaly detection.

## Overview
- **Category:** analytics
- **Price:** Free
- **Endpoint:** https://edge.vinkius.com/vk_preview_qSzdTgEJR9Mb1QnHPDqIWEWAK1bnC7BDP5vYViDL/ai-agent-connect
- **Tags:** metrics, sliding-window, aggregation, anomaly-detection, alerting

## Description

This MCP server provides a deterministic engine for processing timestamped metric streams into sliding windows. It enables precise monitoring by calculating windowed aggregations like sum, average, and percentiles. Use `process_metrics` to transform raw data into windowed results, `analyze_trends` to determine the direction of metric movement via linear regression, and `check_alerts` to identify sustained threshold violations. The engine also detects sensor malfunctions and data gaps automatically.

## Tools

### check_alerts
Checks for threshold violations

### process_metrics


### analyze_trends
Calculates trend direction

## Prompt Examples

**Prompt:** 
```
Process these metrics: [{'timestampMs': 1672531200000, 'value': 10}, {'timestampMs': 1672531260000, 'value': 20}] with a window size of 60000 and slide interval of 60000 using avg aggregation.
```

**Response:** 
```
{ "windows": [{ "startMs": 1672531200000, "endMs": 1672531260000, "value": 15, "isGap": false, "isMalfunction": false }] }
```

**Prompt:** 
```
Check if these windows trigger an alert for a threshold of 50: [{'timestampMs': 1000, 'value': 60}, {'timestampMs': 2000, 'value': 65}, {'timestampMs': 3000, 'value': 70}].
```

**Response:** 
```
{ "isAlerting": true, "consecutiveViolations": 3 }
```

**Prompt:** 
```
Analyze the trend for these window values: [{'timestampMs': 1000, 'value': 10}, {'timestampMs': 2000, 'value': 20}].
```

**Response:** 
```
{ "slope": 10, "direction": "increasing", "isStable": false }
```

## Frequently Asked Questions

**How does the engine handle window overlaps?**
Overlaps occur when the window size is larger than the slide interval. The engine calculates these windows deterministically based on your provided parameters.

**What triggers an alert?**
An alert is triggered via `check_alerts` if a metric exceeds the specified threshold for three consecutive windows.

**How is a sensor malfunction detected?**
A malfunction flag is set if more than 50% of the data points in a window are identified as statistical outliers.
