thumbnail

AI Incident Assistant

Next.jsTypeScriptSupabaseLangChainMCPVercel AI GatewayTurnstileLangSmith

Production-style incident response playground: authenticated chat, MCP incident tools, template-driven CAN/RCA generation, Supabase sessions + quotas, and gateway-routed model orchestration.

Live preview

What it is

AI Incident Assistant is a production-style incident response playground. Operators sign in, chat with an LLM, create/update Sev1 incidents, load templates (CAN, Sev1 canvas, RCA), and generate document outputs from structured incident data.

The build demonstrates gateway-routed models, MCP-backed tools, Supabase-backed auth/sessions, rolling per-user chat quotas, and hybrid observability (gateway-level metrics plus trace-level tooling).

Capability Matrix

AreaBehavior
Chat OrchestrationRoute handler manages model selection, tool binding, token trimming, and persistent session synchronization.
AuthenticationSupabase Auth + middleware edge guards, fronted by Cloudflare Turnstile protection.
Session MemoryPostgres JSONB envelope stores raw messages alongside a structured memory summary and key facts, re-injected on every turn.
Abuse ControlsRolling per-user window via Supabase RPC directly enforced on the chat API.

MCP Tool Surface

Incident
  • create_incident
  • get_incident
  • update_incident
  • list_incidents
Templates
  • get_can_templates
  • get_sev1_canvas
  • get_rca_templates
  • load_template
Documents
  • generate_can_document
  • generate_rca_document
Meta
  • list_tools

Incident/template storage is local JSON in the MCP server data directory with validation, safer writes, and bounded runtime.

Architecture & Flow

A high-fidelity breakdown of how the AI Incident Assistant orchestrates UI, model generation, and tool execution.

01 / Pipeline

Optimized Request Pipeline

Thin system prompt, LangChain-trimmed history, persisted session memory folded into the system string, then branch into model-only or tool-enabled execution.

02 / Retention

Context Retention Flow

From the browser through load/merge of the envelope, optional CAN guardrails, token trimming, and generation, with memory written back under the same row the user already owns via RLS.

03 / Execution

End-to-End Runtime

Request execution from user submit through API orchestration, decision gates, optional MCP calls, and response delivery.

Environment Controls

ModelsAI_GATEWAY_MODEL, AI_GATEWAY_BASE_URL
SupabaseNEXT_PUBLIC_SUPABASE_URL, NEXT_PUBLIC_SUPABASE_ANON_KEY
QuotaCHAT_QUOTA_MAX, CHAT_QUOTA_WINDOW_HOURS
SecurityTURNSTILE_SECRET_KEY, CAPTCHA_COOKIE_SECRET

Syed Ibtihaj

Design & Code by Syed Ibtihaj

Actively maintaining this site and pushing new work to GitHub as it ships.

Open for exploration.

© 2026. Built with Next.js 16