set_alert
Create custom alerts to monitor market conditions and receive notifications when specific thresholds are met, such as fear_greed dropping below 20 or risk_score exceeding certain levels.
Instructions
Set custom alerts that trigger when market conditions meet your thresholds. Example: [{field: "fear_greed", operator: "<", threshold: 20, label: "Extreme fear"}]. Call get_alerts to check which are triggered.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| alerts | Yes | Array of alert conditions |
Implementation Reference
- src/tools/set-alert.ts:33-58 (handler)The implementation of the set_alert tool handler, which validates input alert conditions and persists them using setAlerts.
export function setAlertTool(alerts: SetAlertInput[]): SetAlertResult { const validated: AlertCondition[] = []; for (const a of alerts) { if (!VALID_FIELDS.has(a.field)) continue; if (!VALID_OPS.has(a.operator)) continue; validated.push({ alert_id: generateAlertId(), field: a.field, operator: a.operator as AlertCondition['operator'], threshold: a.threshold, label: a.label ?? `${a.field} ${a.operator} ${a.threshold}`, }); } const stored = setAlerts(AGENT_ID, validated); return { success: true, agent_id: AGENT_ID, alerts_count: validated.length, updated_at: stored.updated_at, agent_guidance: `${validated.length} alert${validated.length === 1 ? '' : 's'} configured. Call get_alerts to check which conditions are currently triggered. Alerts are evaluated against live market data on each call.`, }; } - src/tools/set-alert.ts:18-31 (schema)Type definitions (schema) for the input and result of the set_alert tool.
export interface SetAlertInput { field: string; operator: string; threshold: string | number; label?: string; } export interface SetAlertResult { success: boolean; agent_id: string; alerts_count: number; updated_at: string; agent_guidance: string; }